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 bc78c18..dfebd34 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 856841a..3ee58a6 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 c5e7a22..29e2168 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 9f7df6a..f28e28a 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;