How to resume scorm 2004 where we left previously?

2.5k views Asked by At

Hi,

I'm developing scorm based project, I've to play the scorm 2004 packages. courses are playing
and capturing the data working properly with the using of LMS functions(LMSFinish(), commit()..etc).
Now I've to implement one more function i.e RESUME the package where user left last time.

Sample cmi data

scoid:"1234"

data[cmi.completion_status]:"incomplete"

data[cmi.exit]:"suspend"

data[cmi.location]:"page3"

Hope you help.

4

There are 4 answers

7
Mark On BEST ANSWER

Commonly 'cmi.suspend_data' is used so you can store a string (JSON, or other delimiter format if you want or need structure) to resume answers.
'cmi.location' has 1000 characters for you to also store a string and it can be as simple as "3" or "page3" as you have it.

Your navigation in your content presentation/player would need to be able to respond to having a location to go to. And you can use the suspend_data to put student answers back the way they were when they left.

How you decide if you are 'resuming' is a little tricky since anything except 'cmi.entry' = 'ab-initio' is a resume. Some LMS systems return blank or 'resume' so then you know to fetch your 'cmi.location' and 'cmi.suspend_data' if you use it.

This is all code you have to write, or you can read up a bit on my Wiki. https://github.com/cybercussion/SCOBot/wiki.

0
kishor koshti On

I had some workaround for resume and is working for me . I saved suspended_data and then retrieved that data so player resumed for that position .

0
mertakiner On

Exec solution by Mehonder

// story_content/user.js

let lastSlideLoaded = ''; //global variable
function Script1() {
    if (lastSlideLoaded == '') {
        lastSlideLoaded = 'X';
        var ACT_firstID = window.globals.parsedParams["last_slide"]; //URL Argument
        if (!ACT_firstID == (null || "" || "0")) {
            Jump_Slide(ACT_firstID); //Set Slide
        }
    } else {
        SetLastSlide(); 
    }
}

function SetLastSlide() {
// send to last slide info to server//
    var xhttp = new XMLHttpRequest();
    var PACKID = window.globals.parsedParams["pack_id"];
    var LASTID = window.DS.presentation.playerProps.attributes.CurrentSlideId;
    var lastSlideURL = "/services_index.php?page=last_slide&pack_id=" + PACKID + "&last_slide=" + LASTID;
    xhttp.open('GET', lastSlideURL, true);
    xhttp.send();
}

function Jump_Slide(Target_Slide) {     
// trigger slide change event //                              
    g = DS.pubSub;              
    p = DS.events;              
    i =  "_player." + Target_Slide;              
    g.trigger(p.request.NEXT_SLIDE, i, "_current")
}

2
Eder Cardoso On

@kishor-koshti How did you do that, I mean, tell the player to resume from a given position? I'm being able to capture the suspended_data but I don't know how to set it back the next time I launch that course. The API object that I have on javascript seems to be read only.

    <html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
    <style>
        body { margin: 0; }
    </style>
    <script type="text/javascript">
        var API = {};

        function setupScormApi() {
            API.LMSInitialize = LMSInitialize;
            API.LMSGetValue = LMSGetValue;
            API.LMSSetValue = LMSSetValue;
            API.LMSCommit = LMSCommit;
            API.LMSFinish = LMSFinish;
            API.LMSGetLastError = LMSGetLastError;
            API.LMSGetDiagnostic = LMSGetDiagnostic;
            API.LMSGetErrorString = LMSGetErrorString;
        }
        function LMSInitialize(initializeInput) {
            console.log("LMSInitialize: " + initializeInput);
            // invokeCSharp("LMSInitialize: " + initializeInput);
            return true;
        }
        function LMSGetValue(varname) {
            console.log("LMSGetValue: " + varname);
            //invokeCSharp("LMSGetValue: " + varname);
            return "";
        }
        function LMSSetValue(varname, varvalue) {
            console.log("LMSSetValue: " + varname + "=" + varvalue);
            // invokeCSharp("LMSSetValue: " + varname + "=" + varvalue);
            return "";
        }
        function LMSCommit(commitInput) {
            console.log("LMSCommit: " + commitInput);
            // invokeCSharp("LMSCommit: " + commitInput);
            return true;
        }
        function LMSFinish(finishInput) {
            console.log("LMSFinish: " + finishInput);
            // invokeCSharp("LMSFinish: " + finishInput);
            return true;
        }
        function LMSGetLastError() {
            console.log("LMSGetLastError: ");
            // invokeCSharp("LMSGetLastError: ");
            return 0;
        }
        function LMSGetDiagnostic(errorCode) {
            console.log("LMSGetDiagnostic: " + errorCode);
            // invokeCSharp("LMSGetDiagnostic: " + errorCode);
            return "";
        }
        function LMSGetErrorString(errorCode) {
            console.log("LMSGetErrorString: " + errorCode);
            // invokeCSharp("LMSGetErrorString: " + errorCode);
            return "";
        }

        setupScormApi();
    </script>
    <iframe id="frm1" src="./Content/index_lms.html" style="width: 100%; height: 100%"></iframe>
</body>
</html>