Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

CMI learner_id/student_id not supported #24

Closed
TakeshiDaveau opened this issue Dec 12, 2019 · 3 comments
Closed

CMI learner_id/student_id not supported #24

TakeshiDaveau opened this issue Dec 12, 2019 · 3 comments

Comments

@TakeshiDaveau
Copy link

Hi guys,

Is this package support CMI event listed here : https://scorm.com/scorm-explained/technical-scorm/run-time/run-time-reference/ ?
I juste tested it and I can't access the learner_id/student_id

If not is there any means to get the student id ?

Thanks in advance

@TakeshiDaveau TakeshiDaveau changed the title CMI not supported CMI learner_id/student_id not supported Dec 16, 2019
@mrsinguyen
Copy link

mrsinguyen commented Jul 26, 2021

Since the edx_xblock_scorm does not support learner_id/student_id when playing a scorm file. I suggest for short term solution to fix this issue in the SCORM package, we can use cookie to store student_id based on generated a random UUID.

The code like this

genID: function() {
    var S4 = function () {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
    };
    return (
        S4() +
        S4() +
        "-" +
        S4() +
        "-" +
        S4() +
        "-" +
        S4() +
        "-" +
        S4() +
        S4() +
        S4()
    );
},

 setCookie: function (key, value, exp) {
    let date = new Date();
    date.setTime(date.getTime() + (exp * 24 * 60 * 60 * 1000));
    const expires = "expires=" + date.toUTCString();
    document.cookie = key + "=" + value + "; " + expires + "; path=/;";
},

getCookie: function(key) {
    const name = key + "=";
    const decode = decodeURIComponent(document.cookie);
    const arr = decode.split('; ');
    let res;
    arr.forEach(val => {
        if (val.indexOf(name) === 0) {
            res = val.substring(name.length);
        }
    })
    return res;
  }
};

if (!getCookie('student_anonymous_id')) {
    setCookie('student_anonymous_id', genID(), 30);
}

We can get a student_id like this

student_id: LMSGetValue('cmi.core.student_id') || getCookie('student_anonymous_id'),

@mrsinguyen
Copy link

Or change to use localStorage to avoid 3rd cookie blocking issue with browser

@TakeshiDaveau
Copy link
Author

Since this is an open source package I already did a pull request #26 and I modify by myself the package before uploading it on OpenEDX.

You solution is not a quick fix at all since it will only keep the student ID on 1 device/browser. What a poor experience for a student to lose is progress every time he changes device.

But I don't care anymore about this so I close this issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants