Sending Points to the LMS using Javascript
I have a quiz that contains 14 free-form questions and one custom built question for a total of 15 points.
Variable: customScore stores the custom question result.
Variable: quiz.ScorePoints stores the built in quiz result.
Variable: finalScore combines both values.
On the result slide i can see all of these variables working as intended and being combined correctly. When i try and print the score to Moodle however the score repeatedly returns 0.
I have played around with switching Results.ScorePercent with quiz.ScorePercent and quiz.ScorePoints without luck.
Can anyone see any error in the script?
Here is the code:
var player = GetPlayer();
var customScore = player.GetVar("customScore");
var quizScore = player.GetVar("Results.ScorePercent");
var finalScore = quizScore + customScore;
// Set the final score (0-100 scale)
lmsAPI.SetScore(finalScore, 100, 0);
// Mark the course as completed
lmsAPI.SetReachedEnd();