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?
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?
Hi Tim_,
Thanks for your explanation and example SCORM-package. However the SCORM did not report a score to our Brightspace Gradebook. Can you confirm this works for your Bsp instance?
Our Bsp is using the 'new' Rustici SCORM-engine.
Thanks in advance, Lars
- LukeWestfall2 days agoCommunity Member
Keep in mind you're doing two things to two different parts of the SCORM package here, and they have to go in the right place.
- Add a JavaScript CustomEvent to the SCORM Driver (scormdriver.js) when the SetValue variable is changed. This will happen whenever the lesson_status variable is being updated.
- Add a JavaScript EventListener to the indexAPI.html file that listens for that event and subsequently sets the raw course score to 100%.
Make sure the SCORM object is linked to a Gradebook item. The gradebook listens only for that cmi.core.score.raw value to be passed, which this custom code is forcing to 100% upon completion.