Moodle
  1. Moodle
  2. MDL-11892

JavaScript error on SCORM tree list

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.3, 1.9.1, 2.0
    • Fix Version/s: 1.8.7, 1.9.3, 2.0
    • Component/s: SCORM
    • Labels:
      None
    • Environment:
      Firefox / Internet Explorer and probably other browsers.
    • Affected Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • Rank:
      30022

      Description

      Clicking the +/- icon next to items in the SCORM package list does not expand/contract the items and throws an error.

      This is originates from the "scorm_get_toc" function, within the files scorm_13lib.php and scorm_12lib.php.

      scorm_13lib.php line 117 (creating a link using javascript:expandCollide)
      The second parameter needs to be passed as a string, but isn't surrounded by single quotes which makes the browser think it's a undeclared variable.
      $result->toc .= '<a href="javascript:expandCollide(img'.$sublist.',\'s'.$sublist.'\','.$nextsco->id.');">'.

      Same as above but for scorm_12lib.php line 266.

      Then in both files, the JavaScript function expandCollide is incorrect and badly written (switches between trying to find a suitable method for getting an element by ID, but then just uses document.getElementById anyway for changing the image).

      I updated both to the following (since I didn't know what level of browser Moodle wants to support when it comes to JavaScript).

      function expandCollide(which,list,item) {
      var el = document.ids ? document.ids[list] : document.getElementById ? document.getElementById(list) : document.all[list];
      which = which.substring(0,(which.length));
      var el2 = document.ids ? document.ids[which] : document.getElementById ? document.getElementById(which) : document.all[which];
      if (el.style.display != "none")

      { el2.src = "'.$scormpixdir.'/plus.gif"; el.style.display=\'none\'; new cookie("hide:SCORMitem" + item, 1, 356, "/").set(); }

      else

      { el2.src = "'.$scormpixdir.'/minus.gif"; el.style.display=\'block\'; new cookie("hide:SCORMitem" + item, 1, -1, "/").set(); }

      }

      I've attached two updated files for inspection (updated files from 1.8.3+ 2007-10-24).

      1. MDL-11892-head.patch
        6 kB
        Piers Harding
      2. MDL-11892-moodle16.patch
        6 kB
        Piers Harding
      3. MDL-11892-moodle17.patch
        12 kB
        Piers Harding
      4. MDL-11892-moodle18.patch
        6 kB
        Piers Harding
      5. MDL-11892-moodle19.patch
        6 kB
        Piers Harding
      6. scorm_12lib.php
        17 kB
        David Boyer
      7. scorm_13lib.php
        11 kB
        David Boyer

        Activity

          People

          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: