MDL-28603 - fix regression for SCORM 1.2 test
authorDan Marsden <dan@danmarsden.com>
Fri, 12 Aug 2011 05:15:18 +0000 (17:15 +1200)
committerDan Marsden <dan@danmarsden.com>
Fri, 12 Aug 2011 05:15:18 +0000 (17:15 +1200)
mod/scorm/locallib.php

index 51248fd..fd09321 100644 (file)
@@ -1288,9 +1288,6 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
         $usertracks = array();
         foreach ($scoes as $sco) {
             if (!empty($sco->launch)) {
-                if (empty($scoid)) {
-                    $scoid = $sco->id;
-                }
                 if ($usertrack = scorm_get_tracks($sco->id,$user->id,$attempt)) {
                     if ($usertrack->status == '') {
                         $usertrack->status = 'notattempted';
@@ -1464,10 +1461,10 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
         }
 
         if ($play) {
-            if (empty($scoid)) {
-                $scoid = reset($scoes)->id;
+            // it is possible that $scoid is still not set, in this case we don't want an empty object
+            if ($scoid) {
+                $sco = scorm_get_sco($scoid);
             }
-            $sco = scorm_get_sco($scoid);
             $sco->previd = $previd;
             $sco->nextid = $nextid;
             $result->sco = $sco;