Javascript alerts caused by displaying scorm in iframe?

oschuit3968
oschuit3968 Community Member Posts: 3
I've got a curious problem. If I play a scorm package authored with Lectora Online for the first time inside Moodle, the scorm throws a bunch of javascript alerts (see attached image).

I have embedded the scorm player in an iframe, so I suspect this is the culprit. The exact same scorm package works fine in the regular contexts (either the Moodle scorm activity setting "current window" - without any further iframes - or "new window"). The only difference is that in my Moodle installation I am displaying all Moodle activities in a colorbox popup (so, inside an iframe). I've adapted the Moodle Grid course format to achieve this (I'm a full time Moodle plugin developer).

So my question is: what should I do to solve or circumvent this problem? Should I hack the scorm package's javascript? Looking at the scorm's javascript (so, Trivantis' code), I'd say there's something going wrong in the p.save function, maybe getTitleMgrHandle doesn't return the right handle?

Comments

  • ssneg
    ssneg Community Member Posts: 1,456 ♪ Opening Act ♪
    I think Lectora's SCORM API discovery doesn't expect your scenario (the extra iframe between the course and the SCORM API). So you might want to edit the api wrapper js file.
  • oschuit3968
    oschuit3968 Community Member Posts: 3
    Actually, I think the scorm api is still in the same place: the entire Moodle scorm activity page is placed inside an iframe. There's no extra layer (i.e. iframe) between the scorm content and the scorm player.

    It's just that "above" this iframe there's another document. If Lectora's javascript makes the assumption that "the API is one step above my current place", then there shouldn't be any problem. However, if they start looking for the API in the top window, then they won't find it there. Could that be what's going on here?
  • oschuit3968
    oschuit3968 Community Member Posts: 3
    Turns out that trivantis-cookie.js is the culprit. I have added a crude fix by looking for "parent.parent.parent.titlemgrframe":
    function getTitleMgr(A, B) {
    if (!A) {
    return null;
    }
    if (A.jTitleManager) {
    return A.jTitleManager;
    } else if (A.document.titleMgr) {
    return A.document.titleMgr;
    } else {
    var C;
    <span style="color: #0000ff;">if (parent.parent.parent) {
    C = eval("parent.parent.parent.titlemgrframe");
    }</span> else if (this.frameElement && this.frameElement.id && this.frameElement.id.indexOf('DLG_content') == 0 && parent.parent) {
    C = eval("parent.parent.titlemgrframe");
    } else {
    C = eval("parent.titlemgrframe");
    }
    try {
    if (!C) C = A.parent.titlemgrframe;
    } catch (e) {};
    if (C) {
    if (C.jTitleManager) return C.jTitleManager;
    else return C.document.TitleMgr;
    } else {
    if (A.name.indexOf('Trivantis_Dlg_') == 0) return getTitleMgr(A.parent, B + 1);
    else {
    if (A.name.indexOf('Trivantis_') == 0) return getTitleMgr(A.opener, B + 1);
    else if (B < 2) return getTitleMgr(A.parent, B + 1);
    }
    }
    };
    return null;
    };
    Warning: this works in my situation, but if you add yet another nested iframe, you're going to have to adjust the code.
  • ssneg
    ssneg Community Member Posts: 1,456 ♪ Opening Act ♪
    Yep, didn't think of that, glad that it worked out well.