]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11137 Unable to locate API error - force a sort order on the cmi elements, and...
authorpiers <piers>
Thu, 24 Jul 2008 23:08:30 +0000 (23:08 +0000)
committerpiers <piers>
Thu, 24 Jul 2008 23:08:30 +0000 (23:08 +0000)
mod/scorm/datamodels/aicc.js.php
mod/scorm/datamodels/scorm_12.js.php
mod/scorm/datamodels/scorm_13.js.php
mod/scorm/locallib.php

index bc78c1801b0409a8c2f48f69ba5ca999ed42a69c..dfebd349e27b46cef6f16319505f11a43d40bdd5 100644 (file)
@@ -147,13 +147,15 @@ function AICCapi() {
     }
 
 <?php
+    $current_objective = '';
     $count = 0;
     $objectives = '';
     foreach($userdata as $element => $value){
         if (substr($element,0,14) == 'cmi.objectives') {
-            preg_match('/.(\d+)./',$element,$matches);
-            $element = preg_replace('/.(\d+)./',"_\$1.",$element);
-            if ($matches[1] == $count) {
+            $element = preg_replace('/\.(\d+)\./', "_\$1.", $element);
+            preg_match('/\_(\d+)\./', $element, $matches);
+            if (count($matches) > 0 && $current_objective != $matches[1]) {
+                $current_objective = $matches[1];
                 $count++;
                 $end = strpos($element,$matches[1])+strlen($matches[1]);
                 $subelement = substr($element,0,$end);
index 856841a5c8296003d4a55c0aa0dd262bf622eb5b..3ee58a6e31a855a7a2fb9edebdc448f403adaac9 100644 (file)
@@ -129,13 +129,15 @@ function SCORMapi1_2() {
     }
 
 <?php
+    $current_objective = '';
     $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 (isset($matches[1]) && $matches[1] == $count) {
+            preg_match('/\_(\d+)\./', $element, $matches);
+            if (count($matches) > 0 && $current_objective != $matches[1]) {
+                $current_objective = $matches[1];
                 $count++;
                 $end = strpos($element,$matches[1])+strlen($matches[1]);
                 $subelement = substr($element,0,$end);
index c5e7a22aff80cd2b6b4c30ccb1722c15ff208f59..29e2168de8664cc73893c46f51f1780138a6693e 100644 (file)
@@ -206,13 +206,15 @@ function SCORMapi1_3() {
     }
 
 <?php
+    $current_objective = '';
     $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 (isset($matches[1]) && $matches[1] == $count) {
+            preg_match('/\_(\d+)\./', $element, $matches);
+            if (count($matches) > 0 && $current_objective != $matches[1]) {
+                $current_objective = $matches[1];
                 $count++;
                 $end = strpos($element,$matches[1])+strlen($matches[1]);
                 $subelement = substr($element,0,$end);
index 9f7df6ae8c7d35d680248e18334f5d8bd962fb5a..f28e28ab7c0b0fc996324287a0d58d25fba6757d 100755 (executable)
@@ -278,7 +278,8 @@ function scorm_get_tracks($scoid,$userid,$attempt='') {
             if (isset($track->timemodified) && ($track->timemodified > $usertrack->timemodified)) {
                 $usertrack->timemodified = $track->timemodified;
             }       
-        }       
+        }
+        ksort($userdata);
         return $usertrack;
     } else {
         return false;