Forum Discussion
SCORM/xAPI not passing grade to Brightspace (D2L) gradebook
- 10 months ago
Hi
In my attached course, I’ve tried to set the score using the code from above inside a storyline object. This worked for my own scorm test harness, but not in scorm cloud. Not sure why.
I then tried changing tack. I modified the ./scormdriver/scormdriver.js file to emit an event when SetValue is called so that it’s easier to add custom logic. I then added a script block right before the closing </body> tag to the ./scormdriver/indexAPI.html file that detects the lesson_completed state and also sets a score.
<script>
/* custom event handler for SCORM_CallLMSSetValue */
window.addEventListener('lmssetvalue', function(e) {
const {api,key,value} = e.detail;
switch (key) {
case "cmi.core.lesson_status":
if (value == "completed" || value == "passed") {
console.info('heard lesson_status completed or passed, setting score');
// set the score to 100
api.LMSSetValue("cmi.core.score.raw", "100");
api.LMSSetValue("cmi.core.score.min", "0");
api.LMSSetValue("cmi.core.score.max", "100");
console.info(api.LMSCommit(""));
}
break;
}
});
</script>On scorm cloud, the score is set to 100% when the course completes.
Does this help?
Hmm. I don’t think there’s an event driven way to determine when cmi.core.lesson_status is complete (or when any scorm value changes), so maybe there is something you could do with the first idea.
In storyline you’d craft a file that executes custom javascript on timeline load/end, then publish it and load the storyline file into rise where you want it to execute (like at the end perhaps).
It would find the scorm api and set the score fields directly (if you’re setting raw you have to also set min/max). This is off the top of my head, but something like this might work: