Thursday, October 27, 2011

Publish Adobe Captivate results with Ruby on Rails

Adobe allows you to use the results derived from Captivate quizzes without requiring each of your students to have a separate Adobe ID.  

There are several tutorials showing how to publish these results using PHP - and your Adobe installation comes with the necessary PHP scripts for making this happen - but if you prefer Rails, then you were out of luck, so let's see what I did or install the Ruby gem.

First, Captivate needs to know that we want to report quiz results. In your Captivate quiz project, hit edit > Preferences > Reporting (located 4th from the bottom of the left-hand menu), then at the top check ‘Enable reporting for this project’.  After checking this, check ‘Internal Server’ and then hit ‘configure’.  In the popup window that comes up, you’ll see 4 mandatory fields.  The first field is the most important as this is where you'll link Captivate to the familiar Rails routes - type  PHP projects will have a ‘.php’ appended to the end of that URL but since we're creating a Rails route, there is no need to append an ‘.rb’ to the end of this.

Second, in your Captivate installation you’ll find the PHP script with the right logic at ‘<yourCaptivateInstallation>\Adobe Captivate 5.5\Templates\’.  Open this and it should look like:

Now we need to translate the PHP to Ruby for our Rails controller.  Create a Rails controller such as ‘captivate_controller.rb’ so that we have a place where ‘’ will be routed to.  Don’t forget to add:

(or whatever you named your controller and data-processing method) to config/routes.rb.  Now for the Ruby translation of the PHP file:

As you can see, POSTing to InternalServerReporting creates a params hash and then creates a directory for Captivate results with the values of these parameter keys. Now, go to your Rails root and change the permissions for your 'doc' directory to ‘read, write, and execute, - make sure the change is recursive so that it affects all the directories within the ‘doc’ directory.  

Everything is finished so let’s test.  Go through a quiz on your site as if you were a student and on the last slide you’ll see a ‘Post Result’ button that was automatically added when you checked ‘Enable Reporting For This Project’.  Use whatever username and email combo you want and then exit the quiz and look in your ‘doc’ folder of your Rails root and you should see a "Results" directory followed by the three directories that you named (after you specified your site’s URL) followed by an XML file with the results of the quiz you just took. Or you can spec this out.

In future posts, I’ll discuss how to send an email with these results to the student who took the quiz. I’ll also post about ensuring that the username and email submitted by your students matches the username and email that they used to sign up for your site.  And how to get those captivate SWF files working in Rails.

Check out my Ruby gem for this