]> git.mjollnir.org Git - moodle.git/commitdiff
Patched a problem with asset resources
authorbobopinna <bobopinna>
Wed, 25 Aug 2004 08:34:52 +0000 (08:34 +0000)
committerbobopinna <bobopinna>
Wed, 25 Aug 2004 08:34:52 +0000 (08:34 +0000)
mod/scorm/lib.php
mod/scorm/pix/asset.gif [new file with mode: 0644]
mod/scorm/playscorm.php
mod/scorm/scormAPI.php
mod/scorm/view.php

index 9a096cac275fbd26efd69822695dc310772ee3cb..ba6c67359a2e7dd8f69cc391f3a9e77145b42841 100755 (executable)
@@ -543,7 +543,7 @@ function scorm_parse($basedir,$file,$scorm_id) {
        }
     } else {
        foreach ($resources as $label => $resource) {
-           if ((isset($resource['type'])) && ($resource['type'] == 'sco')) {
+           if (!empty($resource['href'])) {
                $sco->identifier = $label;
                $sco->title = $label;
                $sco->parent = '/';
diff --git a/mod/scorm/pix/asset.gif b/mod/scorm/pix/asset.gif
new file mode 100644 (file)
index 0000000..c391067
Binary files /dev/null and b/mod/scorm/pix/asset.gif differ
index 43fc87dc0eb4f5f45faf457483e1de9800b55eef..d16c81ab87368c4219b8c36d9f61e27e82c20419 100755 (executable)
@@ -73,7 +73,7 @@
        //
        $bodyscripts = "";
        if ($scorm->popup != "") {
-           $bodyscripts = "onLoad='SCOInitialize();' onUnload='API.SaveTotalTime(); closeMain();' onbeforeUnload='API.SaveTotalTime();'";
+           $bodyscripts = "onLoad='SCOInitialize();' onUnload='SCOFinish(); closeMain();' onbeforeUnload='SCOFinish();'";
        }
        print_header($pagetitle, "$course->fullname",
                "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\" title=\"$scorm->summary\">$scorm->name</a>",
                        }
                        $score = "";
                        if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
-                           if ( $sco_user->cmi_core_lesson_status == "")
+                           if ( $sco_user->cmi_core_lesson_status == "") {
                                $sco_user->cmi_core_lesson_status = "not attempted";
+                           }
                            echo "      <img src=\"pix/".scorm_remove_spaces($sco_user->cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" />\n";
                            if (($sco_user->cmi_core_lesson_status == "not attempted") || ($sco_user->cmi_core_lesson_status == "incomplete")) {
                                if ($currentSCO == "") {
                                $score = "(".get_string("score","scorm").":&nbsp;".$sco_user->cmi_core_score_raw.")";
                            }
                        } else {
-                           echo "      <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
-                           $incomplete = true;
+                           if ($sco->type == 'sco') {
+                               echo "      <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
+                               $incomplete = true;
+                           } else {
+                               echo "      <img src=\"pix/asset.gif\" alt=\"".get_string("asset","scorm")."\" />";
+                           }
                        }
                        echo "      &nbsp;$startbold<a href=\"javascript:playSCO(".$sco->id.");\">$sco->title</a> $score$endbold\n    </li>\n";
                    } else {
            echo "<html>\n";
             echo "<head><title>$course->shortname: $scorm->name</title></head>\n";
             echo "<script id=\"scormAPI\" language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&mode=".$mode.$scoid."\"></script>\n";
-           echo "<frameset rows=\"$CFG->scorm_framesize,*\" onLoad=\"SCOInitialize();\" onUnload=\"API.SaveTotalTime();\" onbeforeUnload=\"API.SaveTotalTime();\">\n";
+           echo "<frameset rows=\"$CFG->scorm_framesize,*\" onLoad=\"SCOInitialize();\" onUnload=\"SCOFinish();\" onbeforeUnload=\"SCOFinish();\">\n";
             echo "\t    <frame name=\"navigation\" src=\"playscorm.php?id=$cm->id&mode=".$mode.'&currentorg='.$currentorg."&frameset=top\">\n";
             echo "\t    <frame name=\"main\" src=\"\">\n";
             echo "</frameset>\n";
index 5d43cebed6b7842e24f0299ebf9c54a340c8b90d..4fe90af14df86e393e83778890dd10564ff8df3d 100755 (executable)
            // Create user scoes records
            //
            foreach ($scoes as $sco) {
-               if ($sco->launch != "") {
-                   if (!isset($first))
+               if (($sco->launch != "") && ($sco->type != "sca") && ($sco->type != "asset")){
+                   if (!isset($first)) {
                        $first = $sco;
+                   }
                    $sco_user->userid = $USER->id;
                    $sco_user->scoid = $sco->id;
                    $sco_user->scormid = $scorm->id;
                    $element = "cmi_core_lesson_status";
-                   if ($sco->type == "sco") 
-                       $sco_user->$element = "not attempted";
-                   else if (($sco->type == "sca") || ($sco->type == "asset"))
-                       $sco_user->$element = "completed";
+                   $sco_user->$element = "not attempted";
                    $ident = insert_record("scorm_sco_users",$sco_user);
                }
            }
-           if (isset($first))
+           if (isset($first)) {
                $sco = $first;
+           }
            if (!empty($scoid)) {
-               if ($sco = get_record("scorm_scoes","id",$scoid))
+               if ($sco = get_record("scorm_scoes","id",$scoid)) {
                    unset($first);
+               }
            }
        }
     }
        }
     }
     $navObj = "top.";
-    if ($scorm->popup == "")
-        $navObj = "top.navigation.";
-        
-    include("api1_2.php");
+    if ($scorm->popup == "") {
+       $navObj = "top.navigation.";
+    }
+    
+    if ($sco->type == 'sco') {
+       include("api1_2.php");
+    }
 
 ?>
 
@@ -186,6 +189,12 @@ function SCOInitialize() {
 ?>
 } 
 
+function SCOFinish(){
+    if (typeof API != "undefined") {
+       SaveTotalTime();
+    }
+}
+
 function changeSco(direction) {
     if (direction == "previous")
        <?php echo $navObj ?>document.navform.scoid.value="<?php echo $prevsco; ?>";
index b89c9aa631cf54bcdb140d8650b7d92c5f12c4c2..0b2849e20c7fca4037e14470d310deee37d73b18 100755 (executable)
                            $score = "(".get_string("score","scorm").":&nbsp;".$sco_user->cmi_core_score_raw.")";
                        }
                    } else {
-                       echo "      <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
-                       $incomplete = true;
+                       if ($sco->type == 'sco') {
+                           echo "      <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
+                           $incomplete = true;
+                       } else {
+                           echo "      <img src=\"pix/asset.gif\" alt=\"".get_string("asset","scorm")."\" />";
+                       }
                    }
                    echo "      &nbsp;<a href=\"javascript:playSCO(".$sco->id.")\">$sco->title</a> $score\n    </li>\n";
                } else {