While running, Cenario content detects if it is iframed within another project, for example in a Lectora, Captivate, or Storyline course, and posts messages to its parent detailing what is happening in the content. All messages are posted as JSON, and are indexed by the “type” data member. The following messages are passed:

ATTEMPTED

Sent once at the start of a session

  • type - cenariovr:attempted
  • scenario - (name of scenario)

EXPERIENCED

Sent for each time a scene is visited

  • type - cenariovr:experienced
  • scenario - (name of scenario)
  • scene - (name of scene)
  • duration - (# of seconds in scene)

CLICKED

Sent each time an object is clicked on in a scene

  • type - cenariovr:clicked
  • scenario - (name of scenario)
  • scene - (name of scene)
  • object - (name of object clicked on) 

ANSWERED

Sent each time a question is answered

  • type - cenariovr:answered
  • scenario - (name of scenario)
  • scene - (name of scene)
  • questname- (name of question)
  • questtext - (text of question)
  • choicetext - (text of selected choice)
  • iscorrect - (true or false)
  • duration - (# of seconds to answer question)

UPDATED

Sent each time a variable is updated

  • type - cenariovr:updated
  • scenario - (name of scenario)
  • scene - (name of scene)
  • variable - (name of variable)
  • value - (value of variable)

FINISH

Sent once at the completion of a session

  • type - cenariovr:finish
  • scenario - (name of scenario)
  • score - (percentage relative to 100)
  • result - (completed,passed,failed)
  • duration - (# of seconds to complete scenario)
  • variables - (an array of name value pairs)
    • name - (name of variable)
    • value - (value of variable)

Sample JavaScript to catch messages from CenarioVR content

window.addEventListener('message', function(event) {
   var data = JSON.parse(event.data);
   var messagedatatype = data.type;
   if (messagedatatype=='cenariovr:attempted') {
           console.log("Scenario Attempted: " + data.scenario);
   }else if (messagedatatype=='cenariovr:experienced') {
           console.log("Scene Experienced: " + data.scene + ", Duration: " + data.duration );
   }else if (messagedatatype=='cenariovr:clicked') {
           console.log("Hotspot Clicked: " + data.object );
   } else if (messagedatatype=='cenariovr:answered') {
           console.log("Question Answered: " + data.questname + ", Correct: " + data.iscorrect  + ", Duration: " + data.duration );
 } else if (messagedatatype=='cenariovr:updated') {
           console.log("Variable Updated: " + data.variable + " :  " + data.value );
   } else if (messagedatatype=='cenariovr:finish') {
var strVars = "";
 for( var index=0; data.variables && index<data.variables.length; index++){
if( index != 0 ) strVars += ", ";
strVars += data.variables[index].name + " = " + data.variables[index].value;
}
  console.log("Scenario Finished: " + data.scenario + ", Score: " + data.score + ", Result: " + data.result + ", Duration: " + data.duration + ", Variables: { " + strVars + " }");
   }
} );