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

Incorrect conversion of scorm_seq_rolluprulecond during scorm import

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 3.1.9, 3.2.6, 3.3.3, 3.4
    • Fix Version/s: None
    • Component/s: SCORM
    • Labels:
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE

      Description

      I think I found an incorrect piece of code in SCORM activity see the line here:

      https://github.com/moodle/moodle/blob/a15c7459360f220a34c138f808340e3848c85b7c/mod/scorm/datamodels/scormlib.php#L667

      The original code looks like this:

      // code placeholder
      if (isset($item->rolluprules)) {
          foreach ($item->rolluprules as $rolluprule) {
              $rollup = new stdClass();
              $rollup->scoid = $id;
              $rollup->childactivityset = $rolluprule->childactivityset;
              $rollup->minimumcount = $rolluprule->minimumcount;
              $rollup->minimumpercent = $rolluprule->minimumpercent;
              $rollup->rollupruleaction = $rolluprule->rollupruleaction;
              $rollup->conditioncombination = $rolluprule->conditioncombination;
       
              $rollupruleid = $DB->insert_record('scorm_seq_rolluprule', $rollup);
              if (isset($rollup->conditions)) {
                  foreach ($rollup->conditions as $condition) {
                      $cond = new stdClass();
                      $cond->scoid = $rollup->scoid;
                      $cond->rollupruleid = $rollupruleid;
                      $cond->operator = $condition->operator;
                      $cond->cond = $condition->cond;
                      $conditionid = $DB->insert_record('scorm_seq_rolluprulecond', $cond);
                  }
              }
          }
      }
       
      
      

      And the fixed one should be looking like this:

      // code placeholder
      if (isset($item->rolluprules)) {
          foreach ($item->rolluprules as $rolluprule) {
              $rollup = new stdClass();
              $rollup->scoid = $id;
              $rollup->childactivityset = $rolluprule->childactivityset;
              $rollup->minimumcount = $rolluprule->minimumcount;
              $rollup->minimumpercent = $rolluprule->minimumpercent;
              $rollup->rollupruleaction = $rolluprule->rollupruleaction;
              $rollup->conditioncombination = $rolluprule->conditioncombination;
       
              $rollupruleid = $DB->insert_record('scorm_seq_rolluprule', $rollup);
              if (isset($rolluprule->conditions)) {
                  foreach ($rolluprule->conditions as $condition) {
                      $cond = new stdClass();
                      $cond->scoid = $rollup->scoid;
                      $cond->rollupruleid = $rollupruleid;
                      $cond->operator = $condition->operator;
                      $cond->cond = $condition->cond;
                      $conditionid = $DB->insert_record('scorm_seq_rolluprulecond', $cond);
                  }
              }
          }
      }
      
      

      The code in question incorrectly checks for $rollup->conditions when it should be looking into $rolluprule->conditions.

       

       

       

       

       

       

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: