Publish Adobe Captivate results with Ruby on Rails

October 27, 2011 § Leave a comment

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 as your Adobe installation has the necessary PHP scripts, but none that I could find concerning the increasingly popular Ruby on Rails framework.  So here we go…
First, we need to tell Captivate 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 we’re trying to create a Rails route so do not append a ‘.rb’ to the end of this.
Second, in your Captivate installation you’ll find the PHP script in question at ‘whereYouInstalledCaptivate\Adobe Captivate 5.5\Templates\’.  Open this and it should look like:
<!--?php # InternalServerReporting.php<br ?--># Copyright 2000-2008 Adobe Systems Incorporated. All rights reserved.
print "

   foreach ($_POST as $k => $v)
    if($k == "CompanyName")
    $CompanyName = $v;
      if($k == "DepartmentName")
    $DepartmentName = $v;
      if($k == "CourseName")
    $CourseName = $v;
      if($k == "Filename")
       $Filename = $v;
      if($k == "Filedata")
 $Filedata = stripslashes($v);
 $Filedata = $v;

 $ResultFolder = "./"."CaptivateResults";
 $CompanyFolder = $ResultFolder."//".$CompanyName;
 $DepartmentFolder = $CompanyFolder."//".$DepartmentName;
 $CourseFolder = $DepartmentFolder."//".$CourseName;
 $FilePath = $CourseFolder."//".$Filename;
 $Handle = fopen($FilePath, 'w');
 fwrite($Handle, $Filedata);

   print "

Now we need to translate this PHP into 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:

match '/InternalServerReporting', :to => 'captivate#InternalServerReporting'

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

 def InternalServerReporting
    company_name = params[:CompanyName]
    department_name = params[:DepartmentName]
    course_name = params[:CourseName]
    file_name = params[:Filename]
    file_data = params[:Filedata]
    file_path = File.join("#{Rails.root}/doc", "Results", company_name, department_name, course_name)
    file_path = File.join(file_path, file_name)
    handle =, 'w' )
    handle << file_data

As you can see, POSTing to InternalServerReporting creates a params hash and we’re going to create a directory of Captivate results with the values of these parameter keys. Now, go to your Rails root and right-click ‘doc’ and change the permissions for the 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. Take 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 “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 these captivate file working in Rails.

EDIT: I’ve made a Ruby Gem of this.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading Publish Adobe Captivate results with Ruby on Rails at seminal.


%d bloggers like this: