wheatblog

personal weblog of James "Wheatbread" Martin

Cp2DB: Adobe Captivate Quiz Reporting with PHP/MySQL (Version 2)

A lot of people liked my initial effort at creating a PHP/MySQL reporting solution for quizzes created with Adobe Captivate 4. The holiday break gave me a little extra time to work on the project, so I’m happy to release a new version. I even created a separate page for the project, but I’m still be using the blog to keep you informed about it. (Based on very limited testing, this code seems to work for quizzes created in Captivate 3 as well.)

New Features

  1. Captures both “Core data” and “Interaction data” (explained below). Version 1 only captured “Core data.”
  2. Relational database structure. Version 1 captured everything in one table.
  3. Debug mode. Allows you to see the contents of the array pre- and post-submission.

Core data is aggregate data for the entire quiz. It includes values for the user’s overall score, along with the maximum possible score, the minimum possible score, the total time the user spent on the quiz, and whether he or she passed the quiz (based on a pass/fail percentage you define in Captivate’s quiz preferences).

Interaction data is data specific to each question/interaction in the quiz. It includes the user’s answer, the correct answer, the result (i.e. was the user’s answer correct or not), the time spent on that question, the interaction type (e.g. T/F, multiple-choice, etc.), and some other metadata specific to the question.

In order to store all of this in a useful way, I’ve expanded the database a bit. It now has three tables (one for core data, one for interaction data, and one for person data). I’ve expanded the score submission form to include an optional employee ID, but, behind the scenes, I will be using the user-submitted email to uniquely identify the user. This provides a way to connect user data to quiz data without resorting to a login/authentication scheme of some sort.

Here are the steps for setting it up:

  1. Create a quiz in Captivate 4.
    (I’ve included a sample project: cp2db_v2_rc3.cp.)
  2. Choose Quiz –> Quiz Preferences.
    Under the Reporting category:
    Select the “Enable reporting for this project” checkbox.
    Select the “E-mail” radio button and specify an email address.
    Under “Report to LMS as,” select the “Score” radio button.
    Under “Reporting Level,” select “Interactions and score.”
    Under the Pass or Fail category, set a pass/fail percentage.
    Click the OK button to confirm your preferences.
  3. Save and publish your project as a Flash (SWF).  Be sure “Export HTML” is checked in the publish options.  If you save your project as foo.cp, the HTML file will be named foo.htm.
  4. Download and unzip the Cp2DB files.
  5. Open sendmail_v2.js in your favorite text editor. Select all and copy the entire file to your clipboard.
  6. Locate and select the sendMail() function in foo.htm. It should occupy lines 27-42.
    (If you are using the sample project, the code has already been pasted into cp2db_v2_rc3.htm, so you can skip this step.)
  7. Use paste to replace the default sendMail() function with the new-and-improved one on your clipboard.
  8. Save your changes to foo.htm.
  9. Create a MySQL database called cp2db. It will contain three tables: tblcore, tblinteraction, and tblperson. You will find the SQL for creating the tables and fields in db_schemas.sql.
  10. Edit insert_v4.php. On line 20, change “localhost,” “username,” and “password” to your MySQL host, username, and password values.
  11. Edit the same values in lines 66-68 of display_v4.php.
  12. Upload your Captivate oputput files (i.e. foo.htm, foo.swf, and standard.js), insert_v4.php, and display_v4.php to your web server and test your quiz. Once you have submitted some data, you can use display_v4.php to pull it back out.
  13. Once you get it up and running, take a look at the code in insert_v4.php and the new sendMail() function. There’s a setting for turning the new debug mode on and off. (You’ll want it on for testing, of course.)
  14. Feedback is welcome. Use the comment thread of this post for your bug reports, feature requests, and other feedback.

Known Issues/Limitations

  1. For now, Cp2DB only handles the multiple-choice question type. If there’s sufficient interest, I’ll work on adding other interaction types in future releases.
  2. As far as I know, it only works with Captivate 4. I haven’t tested it with earlier versions.
  3. The script for echoing out the database data is still in its fledgeling stages. A fully-functional back-end remains to be written. I’ll work on that for the next version.

Standard Disclaimer

As before, this code is beta at best. There are no warranties expressed or implied, and you should have someone with better coding chops than me look it over before you put it into production–especially out in the wild. I hope you enjoy it, find it useful, and can leverage it to solve your own problems. But if it blows anything up, that’s on you.

Popularity: 70% [?]

Possibly Related Posts:

  1. Adobe Captivate 4: Storing Quiz Scores with PHP/MySQL
  2. Adobe Captivate 4 Aggregator Issue
  3. PauseMeNow (AS3) widget for Adobe Captivate, Version 1

Leave one

9 Responses

  1. This looks very interesting James. I will definitely try this out.

    Thanks a lot for your efforts!

    /Michael

  2. Tom Zmyslo

     /  February 2, 2010

    Any chance you can port this tutorial from php to Ruby on Rails? I would appreciate it. Thanks.

  3. I might be willing to take a stab at it as a consulting gig, if you’re looking to hire someone.

  4. Thanks, Michael. I love your site, BTW. I’ve only recently discovered it. I’m looking forward to trying out some of your tutorials on advanced interactions.

  5. Marc

     /  March 17, 2010

    Hi
    I followed this and got it sort of working, but i get the error

    Successfully connected to the database.
    Could not insert data into tblperson. Died with this error: No database selected

    when sending the results.

    Any idea what i have done wrong ? Any help would be great.

  6. Hi, Marc. My guess would be that the database itself hasn’t been created, or, if it has been, its name on the database server doesn’t match the one in the script preferences. Can you double-check that? The fact that it is connecting to the database server is good.

  7. Marc

     /  March 18, 2010

    Hi again. A database has been created called cp2db and has 3 tables, tblcore, tblinteraction and tblperson. I checked as far as i can and (im no expert on this) the preferences seem ok. It still connects but wont write data to the database. Still says

    “Could not insert data into tblperson. Died with this error: No database selected”.

    I must be overlooking something easy.

  8. David

     /  May 21, 2010

    Nice, easy to follow and helped me write my own version for our site thanks!

  9. Thanks, David. Glad it worked out for you.

Leave a Reply