Forum Discussion
Setting a project variable as a tracked score for an LMS?
You need to sum all variables into one in Storyline.
This can be done using regular triggers. For example, you have variables score1, score2, and score3. You create a variable called score. You create a trigger to assign the value of score1 to the score variable when the slide time starts. Then, you create a second trigger to add score2 to the score variable. And a third trigger to add the value of score3 to the score variable.
Then, on the slide where you want to send the final result to the LMS, you need to insert the code in the trigger when the slide starts.
When the slide time starts, execute JavaScript.
And insert this code into JavaScript:
var player = GetPlayer();
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
var score = player.GetVar("sum");
lmsAPI.SetScore(score,20,0);
lmsAPI.CommitData();
SetStatus("passed");
SCORM2004_Finish();