Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.2, 1.8.3
    • Fix Version/s: 1.8.6, 1.9.1
    • Component/s: SCORM
    • Labels:
      None
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE

      Description

      In the \moodle\mod\scorm\datamodels\scorm_12.js.php file at line 131 there is a PHP block designed to initialise the data model's objectives.

      However, the last check-in of this code introduced a bug whereby $subelement is always empty-string and the for..each block only matches the first objective initialisation. This is due to the regular expression exclusively matching full-stops (now \., previously .), rather than the underscore as captured by the data model from a previous session write-back (cmi.objectives_0.id). Also the replacement is performed after the regex matcher for the objective identifiers, introducing needless complexity. Consequently the following JS code is produced by api.php when revisiting a SCORM 1.2 package making use of the cmi.objectives data model section:

      = new Object();
      .score = new Object();
      .score._children = score_children;
      .score.raw = '';
      .score.min = '';
      .score.max = '';

      Note: There is no actual or intended 'with' block, nor should there be.

      I propose the following code fix:

      <?php
      $count = 0;
      $objectives = '';
      foreach($userdata as $element => $value) {
      if (substr($element, 0, 14) == 'cmi.objectives') {
      $element = preg_replace('/\.(\d+)\./', "_\$1.", $element);
      preg_match('/_(\d+)\./', $element, $matches);
      if ($matches[1] == $count)

      { $count++; $end = strpos($element, $matches[1]) + strlen($matches[1]); $subelement = substr($element, 0, $end); echo ' '.$subelement." = new Object();\n"; echo ' '.$subelement.".score = new Object();\n"; echo ' '.$subelement.".score._children = score_children;\n"; echo ' '.$subelement.".score.raw = '';\n"; echo ' '.$subelement.".score.min = '';\n"; echo ' '.$subelement.".score.max = '';\n"; }

      echo ' '.$element.' = \''.$value."';\n";
      }
      }
      if ($count > 0)

      { echo ' cmi.objectives._count = '.$count.";\n"; }

      ?>

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  15/May/08