Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-11892

JavaScript error on SCORM tree list

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8.3, 1.9.1, 2.0
    • 1.8.7, 1.9.3, 2.0
    • SCORM
    • None
    • Firefox / Internet Explorer and probably other browsers.
    • MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE
    • MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

    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).

      Attachments

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

        Activity

          People

            piers Piers Harding
            daibach David Boyer
            Dan Marsden Dan Marsden
            Dan Marsden, Matteo Scaramuccia, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              15/Oct/08