Forum Discussion
Setting 'Results.ScorePoints' to equal my custom score variable
Well, sure, That statement only sends the score to the lms.
To do this, I create 3 variables in the storyline player. CurrentScore, CurrentScorePercent, and PassScorePercent.
Then I add a javascript trigger to each question slide on the correct answer layer to add 10 points to my variable CurrentScore. You need to keep track of this in your own variable, as Storyline does not make the internal score variable available to javascript.
Then I add this script in a javascript trigger that runs after the submit action on the results slide
var p = GetPlayer();
var cs = p.GetVar("CurrentScore");
var currentScorePercent = p.GetVar("CurrentScorePercent");
var passScorePercent = p.GetVar("PassScorePercent");
var ns = 10; // Number of Question Slides
var currentScorePercent = Math.round(cs / ns * 10);
p.SetVar("CurrentScorePercent", currentScorePercent );
console.log("Current Score Percent " + currentScorePercent);
lmsAPI.SCORM_SetScore(currentScorePercent, passScorePercent, 0);
console.log("Score Saved");
You will notice that I've added a couple of "console.log" statements. These are very useful when debugging your code. When you've added the scripts, publish your course for web or lms. Start your course in the browser. When it first starts, press F12 on your keyboard. This will open the debugging tools. (You may need to download these for firefox. Chrome's security settings may refuse to play the flash content with the new security settings if your are running from a local file.) With the debugger window open, select the console tab. The results of the console.log statement may be viewed in the console window.
Since I'm sending a score percentage, I need to calculate the percent from the actual score. Set the var ns to the number of slide that you have.
I like to debug in Chrome, but with the new security settings, you need to run the module from an actual URL (HTTP//) not a file (file//) designation. I get around this by running it in localhost on my PC. This saves me from having to upload it to the LMS for each test. If you want to set up the localhost server, you will need to add a mime type for .mp4 media content, but once you do it works great for testing.
(I did this from memory, so you may need to check it for typos.)
I hope that this information helps.
Related Content
- 10 months ago
- 10 months ago