Whilst recently converting a Captivate 9 elearning project to use xAPI, I wanted to capture custom verbs for the xAPI. I came across this great article that makes it easy to use. So I won’t repeat it here, just go check it out!

Captivate Javascript xAPI Customization | Best Practices for xAPI

With the new Tin Can object being passed, I wanted to redirect the user to a another page based on the object they clicked on, almost like branching but I wanted to capture this.

So I set about updating all the javascript and used the following as an executable javascript on the Action item of each object

var tincan = new TinCan({url: window.location.href});



//Change this only
/*****************************************************/

var slideTitle = " Title";
var NextSlide = 0;

/*****************************************************/

tincan.sendStatement(
{
verb: {
id :"http://maywebsite.com/elearning/clicked.htm",
display: {"en-US":"clicked"}
},
object :{
id: "http://maywebsite.com/elearning/multiscreen.html",
definition :{
name: {"en-US": "Viewed " + " " + slideTitle},
description: {"en-US": "Clicked and Viewed the " + slideTitle }
}

}
}
);

window.cpAPIInterface.setVariableValue('cpCmndGotoSlide',NextSlide);

This all worked with the new clicked statement working but the redirect was going to the wrong page. I know I was linking to the number of the slide in captivate, so why wasn’t it working.

Then it dawned on me that I need to reference the object number, not the slide number. So instead of counting the first slide as 1, you count it as 0 (zero), and all will work as planned!

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Connect with Julian Davis

© Copyright The Digital Learning Guy

ABN 364 4183 4283