From d64bc8aea65ac07797de65f04457cb11f607291c Mon Sep 17 00:00:00 2001 From: bobopinna Date: Wed, 25 Aug 2004 08:34:52 +0000 Subject: [PATCH] Patched a problem with asset resources --- mod/scorm/lib.php | 2 +- mod/scorm/pix/asset.gif | Bin 0 -> 178 bytes mod/scorm/playscorm.php | 15 ++++++++++----- mod/scorm/scormAPI.php | 33 +++++++++++++++++++++------------ mod/scorm/view.php | 8 ++++++-- 5 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 mod/scorm/pix/asset.gif diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 9a096cac27..ba6c67359a 100755 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -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 index 0000000000000000000000000000000000000000..c39106788e2f8213f550bc227e1f643ffd02d41c GIT binary patch literal 178 zcmZ?wbhEHb6krfw*v!E2|Ns9pKy>E+%rpPffN17_V<1ZV&j3WmGZ~E27#NHhz{-Fm z5Gej+VHIKEWzYd}KxQzo#BVsM=`Cpzd}OQGoQJ8bTN) literal 0 HcmV?d00001 diff --git a/mod/scorm/playscorm.php b/mod/scorm/playscorm.php index 43fc87dc0e..d16c81ab87 100755 --- a/mod/scorm/playscorm.php +++ b/mod/scorm/playscorm.php @@ -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 framename}\" href=\"view.php?id=$cm->id\" title=\"$scorm->summary\">$scorm->name", @@ -173,8 +173,9 @@ } $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 " 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 == "") { @@ -188,8 +189,12 @@ $score = "(".get_string("score","scorm").": ".$sco_user->cmi_core_score_raw.")"; } } else { - echo " \"".get_string("notattempted","scorm")."\""; - $incomplete = true; + if ($sco->type == 'sco') { + echo " \"".get_string("notattempted","scorm")."\""; + $incomplete = true; + } else { + echo " \"".get_string("asset","scorm")."\""; + } } echo "  $startboldid.");\">$sco->title $score$endbold\n \n"; } else { @@ -267,7 +272,7 @@ echo "\n"; echo "$course->shortname: $scorm->name\n"; echo "\n"; - echo "scorm_framesize,*\" onLoad=\"SCOInitialize();\" onUnload=\"API.SaveTotalTime();\" onbeforeUnload=\"API.SaveTotalTime();\">\n"; + echo "scorm_framesize,*\" onLoad=\"SCOInitialize();\" onUnload=\"SCOFinish();\" onbeforeUnload=\"SCOFinish();\">\n"; echo "\t id&mode=".$mode.'¤torg='.$currentorg."&frameset=top\">\n"; echo "\t \n"; echo "\n"; diff --git a/mod/scorm/scormAPI.php b/mod/scorm/scormAPI.php index 5d43cebed6..4fe90af14d 100755 --- a/mod/scorm/scormAPI.php +++ b/mod/scorm/scormAPI.php @@ -83,25 +83,25 @@ // 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); + } } } } @@ -147,10 +147,13 @@ } } $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") document.navform.scoid.value=""; diff --git a/mod/scorm/view.php b/mod/scorm/view.php index b89c9aa631..0b2849e20c 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -163,8 +163,12 @@ $score = "(".get_string("score","scorm").": ".$sco_user->cmi_core_score_raw.")"; } } else { - echo " \"".get_string("notattempted","scorm")."\""; - $incomplete = true; + if ($sco->type == 'sco') { + echo " \"".get_string("notattempted","scorm")."\""; + $incomplete = true; + } else { + echo " \"".get_string("asset","scorm")."\""; + } } echo "  id.")\">$sco->title $score\n \n"; } else { -- 2.39.5