Forum Discussion
Setting 'Results.ScorePoints' to equal my custom score variable
This subject seems to have been discussed for several years (which suggests a SL improvement is needed ...) but I would appreciate some guidance.
I will have 10 custom quiz questions which can't be handled by standard SL quiz types (individual answer scoring and ticks/crosses within each question screen).
I accumulate the score from these 10 in a variable called 'My_Score'. I will also have another 30 questions which will use SL question templates and which accumulate their overall score in 'Results.ScorePoints'.
So when I reach the Results slide I have my custom variable plus the SL 'Results.ScorePoints' variable. I can add them together with a Trigger to make 'My_Score' equal to the total score for all 40 questions but what is the simplest way to get this variable back into 'Results.ScorePoints' so that it appears in the Results and goes back to the SCORM LMS?
Could I force a 'dummy' quiz question with a data entry field to be set to the 'My_Score' value, so that the 'Results.ScorePoints' takes on this value?
JavaScript I don't believe can modify the 'Results.ScorePoints' variable?
Many thanks, Tim
29 Replies
Hi Tim,
Thanks for reaching out here, and as you mentioned it's been discussed before as Storyline doesn't currently allow for you to edit the Results.ScorePoints using triggers as it's set based on the questions you've inserted and points associated with them.
I'll defer to the community for their expertise and will be curious to see what you all come up with!
- TimNeillCommunity Member
I'm hope the answer is going to be in setting the 'NumericEntry' variable to equal my custom 'My-Score' value (as if I had typed it in). I can do this OK. I have created a Numeric entry slide and this slide is included in the 'Results' slide but the 'Results.ScorePoin†s' still doesn't include the 'NumericEntry' value. Aaaaargh!
- PhilMayorSuper Hero
Tim, you can use javascript to set a score in an LMS. You could use this to set the custom value to your LMS
- TimNeillCommunity Member
Thanks Phil. When I get to the Results slide I will have two variables holding quiz question scores ('Results.ScorePoints' that is accumulated from the standard SL questions and 'My_Score' accumulated from my custom question slides with their individual marking, e.g.: score 0-10 on each screen). I need to combine these two into a single points value and then mark this as a Pass or Fail to the LMS.
- DigitalChoraliaCommunity Member
I have worked around this by setting up a Pick One Freeform Question, where the correct question only appears if the custom Points variable is over the desired threshold, but it actually looks like a Submit answer button, which then leads to the Results page.
Of course, this only sends the LMS a binary information: have I reached or not reached the threshold.
If you wish a finer grain of tracking, you can also work with a Pick Many Freeform Question, and you have one different button per each points bracket, of course if your Results variable can range anywhere from 0 to 100, that would mean setting up 100 buttons - not the best!
- DaveCoxCommunity Member
You can use javascript to set your score in the LMS. To do this, you will need to keep track of the scores on your own.
Storyline lets you access Results.ScorePoints to display it on the screen, but you can't read or write it with javascript.
What you can do however, is add a trigger to the correct and incorrect feedback layers to collect that information into your own custom variable. Then you can use it however you want.
- TimNeillCommunity Member
Thanks Dave. I am collecting certain correctly-answered question points in my custom variable called 'My-Score'. Other questions use standard SL templates and they are accumulating in 'Results.ScorePoints'.
On the Results screen I am using a Trigger to Add the contents of 'Results.ScorePoints' to 'My-Score' (although I really wanted to do it the other way around). So I do end up with the correct total scored points from custom and standard questions.
But which variables are returned via the LMS from the Results screen? The SCORM 1.2 Tracking screens just names the Results screen but not the variables. The other standard SL variables for ScorePercent, etc. would also not carry my custom data. Does SCORM send back ALL variables it finds on the Results screen?
- DaveCoxCommunity Member
Storyline sends the score from the default score variables for the results slide that you have set up as the slide to report to the LMS. You can override that value with javascript, but to prevent Storyline from overwriting it, you have to be careful to send it after Storyline. I do this by placing it after the submit results trigger on the results slide.
This statement:
lmsAPI.SCORM_SetScore(My-Score,100,0);
will send the value of the javascript variable My-Score, a max value of 100 and a min value to the LMS.
I hope that this helps.
- TimNeillCommunity Member
Thanks for your rapid help Dave, most appreciated. I'll try this.
- TimNeillCommunity Member
Not working yet.
Dave - is anything else required in the Javascript other than 'lmsAPI.SCORM_SetScore(My-Score,100,0);'? Opening the Player, defining vars, etc?
- DaveCoxCommunity Member
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