Forum Discussion
Dblatt
1 month agoCommunity Member
Changing Course Behavior Based On Previous Completion
We have a number of courses that we require employees to take year over year from a compliance standpoint. We’re moving to allow employees to test out in years 2 and beyond.
I’d love to keep t...
Dblatt
19 days agoCommunity Member
This is an internal client, so that makes a lot of the buy-in and maintenance easier.
I have only the most rudimentary understanding of Javascript, so I've relied on Co-Pilot and Gemini to provide me with the code. This is what they've come up with. This is very good at identifying the completion state of the current attempt, but it doesn't check for historical completions that took place before the current attempt.
I should add that this is built for SCORM 1.2, which is what we've historically used in our LMS (Saba -- for the next year)
function getAPI() {
var win = window;
var attempts = 0;
while (attempts < 10) {
if (win.API) return win.API;
if (win.parent && win.parent != win) {
attempts++;
win = win.parent;
} else {
break;
}
}
// also try the opener
if (window.opener && window.opener.API) {
return window.opener.API;
}
return null;
}
var api = getAPI();
/*******************************
* Read completion status
*******************************/
var status = null;
if (api) {
status = api.LMSGetValue("cmi.core.lesson_status");
console.log("Status from LMS:", status);
} else {
console.warn("SCORM API not found.");
}
/*******************************
* Set Storyline variable
*******************************/
var player = GetPlayer();
var IsCourseComplete = false;
// SCORM 1.2 considers completed or passed as "done"
if (status === "completed" || status === "passed") {
IsCourseComplete = true;
}
player.SetVar("IsCourseComplete", IsCourseComplete);
Related Content
- 1 month ago
- 1 year ago