Jan 23, 2009

A Budding Relationship for Captivate and Lectora

I've been working with Lectora and Captivate to create my eLearning content (see Jan 13th I'm not yet Captivated by Lectora). In that post I identified three possible techniques for passing the score/results from Captivate back to Lectora for processing:
  1. Use the e-mail command in Captivate and overwrite the JavaScript function for sending the mail.
  2. Use Javascript calls from within Captivate to write to variables in Lectora.
  3. Call a Javascript flash API from Lectora to pull the values out of the flash object.
Since then I have tried out the first two techniques and have the following to report. Using Send E-mail from Captivate Using the e-mail command works great as advertised in sflowers post in the Trivantis Community Forum. There is also another example of this same approach I found useful in a post by Tim Mushen. I used Captivate 3 to verify this. Summarizing the sflowers e-mail approach you get:
  1. Create Captivate animation
  2. Setup Captivate to use e-mail for results
  3. Publish and insert into Lectora
  4. Create custom HTML header scripting element to insert JavaScript Function
Here's a few additional things you might find helpful:
  • Use the alert() function to test out that the Lectora JavaScript code is functioning correctly before writing the "real" code
  • Understand how to reference Lectora variables in JavaScript. If the variable is c3Accuracy when created in Lectora, then the variable is referenced as Varc3Accuracy in the JavaScript code. Remember the "Var" prefix. See code below.
  • When previewing to test this out I exported to HTML and ran on an Apache server on my local desktop.
Sample sendMail() code to be inserted in Lectora:
function sendMail() {

var stripCoreData = gstrEmailBody.replace("Core Data", "");
var stripQuotes = stripCoreData;
while(stripQuotes.indexOf("\"" ) != -1) {
  stripQuotes = stripQuotes.replace("\"", ""); // remove quotes
}
var results_array = stripQuotes.split(",");
Varc3RawScore.set(results_array[7]);
Varc3MaxScore.set(results_array[8]);
Varc3MinScore.set(results_array[9]);
Varc3Accuracy.set((Varc3RawScore/Varc3MaxScore)*100);
trivNextPage(); // advance to next page
} 
Using JavaScript Calls I was able to use JavaScript calls from Captivate to set Lectora variables. However, I have not yet figured out how to access the scoring variables from inside Captivate. I'll need more research to do that. What I can do is monitor a click event in Captivate and set variables in Lectora and advance to the next Lectora page. I'm using this to track when the learner has completed the Captivate simulation. This way I can prevent the learner from advancing in the course until the simulation is complete. The two major steps are:
  1. Set a click box to execute JavaScript in Captivate
  2. Create a Header Script option in Lectora to execute those commands (optional)
For some reason I had trouble running more than one line of JavaScript from Captivate so to work around it I just call a function from Captivate and use that function to run multiple commands. In Captivate:
In Lectora:
In the screen shot above, simCreateReqComplete is the name of the variable I use in Lectora to track if the simulation has been completed.  If it has been completed then the user can advance to the next part of the course.
I could spend a lot more time explaining this in detail but this is all I have time for today. I think if you look at the two examples for using the e-mail method you'll have a good idea of how to implement that. Please comment if you have any questions or suggestions for better approaches.

1 comment:

Anonymous said...

I am having trouble getting this to work. I am using the latest verison of Lectora and Captivate 2.0.

Any suggestions?