Forum Discussion
SL: JavaScript to send Numerical score to LMS (Scorm 1.2)
If you are just looking to send the quiz score to the LMS you shouldn't need to get your hands dirty with JS. If you have a quiz in your module, and the quiz questions are processed by a results slide, the SCORE will be sent to the LMS. Ensure the SCORM 1.2 publish settings are set to "When the learner completes a quiz" under the Tracking tab.
Here's a quick video demo:https://app.screencast.com/dZY1HKfV40p0o
And the demo Storyline file attached at the bottom of this post.
If you are looking to send the quiz points to the LMS, this is not supported by SCORM 1.2, as the score field will only accept a number between 0-100. This is why most LMS will display the number with the "%" symbol, as it is expected the score is a percentage.
If your "points" happen to fall between 0-100 and will not go over 100, then, technically, you can do it, but understand that you are not using the field correctly, and could experience issues using this method as some other functionalities sometimes depend on that score, for example mastery_score.
Here's the technically possible way to do it using JavaScript (use at your own risk, i.e test it lots!):
Firstly, you need to assign the quiz score, for example "Quiz1.ScorePoints", to a new user defined "Number" variable in Storyline. We'll use "quizScore". This would be done on the results slide for example:
Then the JavaScript, you can run this "When the timeline starts" too, directly after the trigger above.
// Set the score
const player = GetPlayer();
const quizScore = player.GetVar('quizScore');
SCORM_CallLMSSetValue("cmi.core.score.raw", quizScore);
You would need to ensure that the you also manage the completion of the course yourself, and ensure you do not publish using a results slide to track completion, or this will overwrite the score you set with JavaScript.
Here's a video of this result (the LMS is automatically displaying "%"): https://app.screencast.com/q2szkMJbrpZiy