From: moodler Date: Fri, 21 May 2004 01:42:17 +0000 (+0000) Subject: Putting in Bobo's latest changes (from the contrib version) X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c5163bfdbe9b4cd86ec1ca48d65ff9ab61840d4d;p=moodle.git Putting in Bobo's latest changes (from the contrib version) --- diff --git a/mod/scorm/api1_2.php b/mod/scorm/api1_2.php index 25231d1f8c..34dae806db 100644 --- a/mod/scorm/api1_2.php +++ b/mod/scorm/api1_2.php @@ -119,6 +119,12 @@ function SCORMapi() { if ((parseFloat(value,10)).toString() != value) { errorCode = 405; return "false"; + } else { + rawvalue = parseFloat(value,10); + if ((rawvalue<0) || (rawvalue>100)) { + errorCode = 405; + return "false"; + } } eval(param+'="'+value+'";'); errorCode = 0; @@ -278,27 +284,3 @@ function SCORMapi() { } var API = new SCORMapi(); - -function SCOInitialize() { -previous || $first) { - print "\ttop.nav.document.navform.prev.disabled = true;\n"; - print "\ttop.nav.document.navform.prev.style.display = 'none';\n"; - } - if ( $sco->next || $last) { - print "\ttop.nav.document.navform.next.disabled = true;\n"; - print "\ttop.nav.document.navform.next.style.display = 'none';\n"; - } -?> - top.main.location=""; -} - -function changeSco(direction) { - if (direction == "prev") - top.nav.document.navform.scoid.value=""; - else - top.nav.document.navform.scoid.value=""; - - //alert ("Prev: \nNext: \nNew SCO: "+top.nav.document.navform.scoid.value); - top.nav.document.navform.submit(); -} diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 7adc519abc..111d2a8a24 100755 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -4,9 +4,7 @@ /// (replace scorm with the name of your module and delete this line) -$scorm_CONSTANT = 7; /// for example -$SCORM_TOP_FRAME_SIZE = 120; -$SCORM_LEFT_FRAME_SIZE = 210; +$SCORM_FRAME_SIZE = 140; function scorm_add_instance($scorm) { /// Given an object containing all the necessary data, @@ -175,12 +173,13 @@ function scorm_randstring($len = "8") function scorm_mkdirs($strPath) { + global $CFG; if (is_dir($strPath)) return true; $pStrPath = dirname($strPath); if (!scorm_mkdirs($pStrPath)) return false; - return mkdir($strPath); + return mkdir($strPath, $CFG->directorypermissions); } function scorm_datadir($strPath, $existingdir="", $prefix = "SCORM") @@ -192,7 +191,7 @@ function scorm_datadir($strPath, $existingdir="", $prefix = "SCORM") do { $datadir="/".$prefix.scorm_randstring(); } while (file_exists($strPath.$datadir)); - mkdir($strPath.$datadir); + mkdir($strPath.$datadir, $CFG->directorypermissions); return $strPath.$datadir; } else { return false; diff --git a/mod/scorm/playscorm.php b/mod/scorm/playscorm.php index 4d5edecb0c..83294be35a 100755 --- a/mod/scorm/playscorm.php +++ b/mod/scorm/playscorm.php @@ -54,150 +54,65 @@ update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); notice(get_string("activityiscurrentlyhidden")); } - switch ($frameset) { - case "top": - add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id"); - // - // Print the page header - // - print_header($pagetitle, "$course->fullname", + if ($frameset) { + add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id"); + // + // Print the page header + // + print_header($pagetitle, "$course->fullname", "$navigation framename}\" href=\"view.php?id=$cm->id\" title=\"$scorm->summary\">$scorm->name", - "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); + "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm, '_top')); - echo "
".text_to_html($scorm->summary, true, false)."
\n"; - echo "\n\n"; - break; - case "left": - // - // Print SCORM Nav button - // - if (file_exists("$CFG->dirroot/theme/$CFG->theme/styles.php")) { - $styles = $CFG->stylesheet; - require_once("$CFG->dirroot/theme/$CFG->theme/config.php"); - } else { - $styles = "$CFG->wwwroot/theme/standard/styles.php"; - require_once("$CFG->dirroot/theme/standard/config.php"); - } - if ( get_string("thisdirection") == "rtl" ) { - $direction = " dir=\"rtl\""; - } else { - $direction = " dir=\"ltr\""; - } - $meta = "\n$meta\n"; - echo "\n\n"; - echo $meta; - echo "Navigator\n"; - echo "\n"; - //echo "\n"; - echo "\nbody."\" leftmargin=\"0\">\n"; - echo "\n"; - if ($_GET["mode"] == "browse") - echo " "; - echo " \n"; + if ($_GET["mode"] == "browse") + echo "\n"; + echo "\n
".get_string("browsemode","scorm")."
+ echo "\n
".text_to_html($scorm->summary, true, false)."
\n"; + + if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){ + $level=0; + $parents[$level]="/"; + foreach ($scoes as $sco) { + if ($parents[$level]!=$sco->parent) { + if ($level>0 && $parents[$level-1]==$sco->parent) { + $level--; + } else { + $level++; + $parents[$level]=$sco->parent; + } + } + $indenting = ""; + for ($i=0;$i<$level;$i++) { + $indenting .= "-"; + } + $options[$sco->id] = $indenting."> ".$sco->title; + } + } + + echo "\n \n"; + echo " \n"; - echo "
id\" target=\"_top\"> -   - +  \n"; + choose_from_menu($options, "courseStructure", "", "", "document.navform.scoid.value=document.navform.courseStructure.options[document.navform.courseStructure.selectedIndex].value;document.navform.submit();"); + echo "  
-
\n"; - echo "\n"; - echo "
    \n"; - if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){ - $level=0; - $sublist=0; - $parents[$level]="/"; - $incomplete=false; - foreach ($scoes as $sco) { - if ($parents[$level]!=$sco->parent) { - if ($level>0 && $parents[$level-1]==$sco->parent) { - echo "
\n"; - $level--; - } else { - echo "
    \n"; - $level++; - $parents[$level]=$sco->parent; - } - } - echo "
  • "; - $nextsco = next($scoes); - if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && ($nextsco->parent != $parents[$level-1])) { - $sublist++; - echo ""; - } else - echo ""; - if ($sco->launch) { - if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) { - 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")."\" />"; - switch ($sco_user->cmi_core_lesson_status) { - case "not attempted": - case "incomplete": - case "browsed": - $incomplete = true; - } - } else { - echo "\"".get_string("notattempted","scorm")."\""; - $incomplete = true; - } - echo " id.")\">$sco->title
  • \n"; - } else { - echo " $sco->title\n"; - } - } - - for ($i=0;$i<$level;$i++){ - echo "
\n"; - } - } - echo "

\n"; - echo "\n"; - echo "\n\n"; - break; - default: - // - // Frameset - // - if ($_POST["scoid"]) - $scoid = "&scoid=".$_POST["scoid"]; - echo "\n"; - echo "$course->shortname: $scorm->name\n"; - echo "\n"; - echo "\n"; - echo " id&mode=".$_POST["mode"]."&frameset=top\">\n"; - echo " \n"; - echo " id&mode=".$_POST["mode"]."&frameset=left\">\n"; - echo " \n"; - echo " \n"; - echo "\n"; - echo "\n"; - break; +
".get_string("browsemode","scorm")."
\n"; + echo "\n\n"; + } else { + // + // Frameset + // + if ($_POST["scoid"]) + $scoid = "&scoid=".$_POST["scoid"]; + echo "\n"; + echo "$course->shortname: $scorm->name\n"; + echo "\n"; + echo "\n"; + echo " id&mode=".$_POST["mode"]."&frameset=top\">\n"; + echo " \n"; + echo "\n"; + echo "\n"; } ?> diff --git a/mod/scorm/report.php b/mod/scorm/report.php index c757c40554..c03b973456 100755 --- a/mod/scorm/report.php +++ b/mod/scorm/report.php @@ -87,10 +87,12 @@ $row[] = "wwwroot/user/view.php?id=$data->userid&course=$course->id\">". "$data->firstname $data->lastname"; foreach ($user_data as $data) { - $row[]="cmi_core_lesson_status).".gif\" + if ($data->cmi_core_score_raw > 0) + $scoreview = "
".get_string("score","scorm").": ".$data->cmi_core_score_raw; + $row[]="cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($data->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($data->cmi_core_lesson_status),"scorm")."\"> " - .$data->cmi_core_total_time; + .$data->cmi_core_total_time.$scoreview; } } $table->data[] = $row; diff --git a/mod/scorm/scormAPI.php b/mod/scorm/scormAPI.php index 2681c22152..bb5d9f835e 100755 --- a/mod/scorm/scormAPI.php +++ b/mod/scorm/scormAPI.php @@ -65,11 +65,13 @@ else if ($sco->type == "sca") $sco_user->$element = "completed"; $ident = insert_record("scorm_sco_users",$sco_user); - } + } } $sco = $first; - if ($_GET["scoid"]) - $sco = get_record("scorm_scoes","id",$_GET["scoid"]); + if ($_GET["scoid"]) { + if ($sco = get_record("scorm_scoes","id",$_GET["scoid"])) + unset($first); + } } } // @@ -95,8 +97,9 @@ if ($sco->id == $max) $last = $sco; - // Get User data + // Get current sco User data $sco_user = get_record("scorm_sco_users","userid",$USER->id,"scoid",$sco->id); + if (scorm_external_link($sco->launch)) { $result = $sco->launch; } else { @@ -107,4 +110,33 @@ } } include("api1_2.php"); + ?> + +function SCOInitialize() { +previous || $first) { + print "\ttop.nav.document.navform.prev.disabled = true;\n"; + print "\ttop.nav.document.navform.prev.style.display = 'none';\n"; + } + if ( $sco->next || $last) { + print "\ttop.nav.document.navform.next.disabled = true;\n"; + print "\ttop.nav.document.navform.next.style.display = 'none';\n"; + } +?> + top.main.location=""; + for (i=0;iid; ?> ) + top.nav.document.navform.courseStructure.options[i].selected = true; + } +} + +function changeSco(direction) { + if (direction == "prev") + top.nav.document.navform.scoid.value=""; + else + top.nav.document.navform.scoid.value=""; + + //alert ("Prev: \nNext: \nNew SCO: "+top.nav.document.navform.scoid.value); + top.nav.document.navform.submit(); +} \ No newline at end of file diff --git a/mod/scorm/view.php b/mod/scorm/view.php index c1cca74995..c5b14ec60a 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -89,22 +89,22 @@ exit; } echo "
"; + echo "\n"; print_simple_box_start("CENTER"); echo "\n"; echo " \n"; - echo " \n"; + echo "\n"; echo "
".get_string("coursestruct","scorm")."
\n
    \n"; + echo "
\n
    \n"; if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){ $level=0; $sublist=0; $parents[$level]="/"; - $incomplete=false; foreach ($scoes as $sco) { if ($parents[$level]!=$sco->parent) { if ($level>0 && $parents[$level-1]==$sco->parent) { echo "
\n"; $level--; } else { - echo "
    \n"; + echo "
      \n"; $level++; $parents[$level]=$sco->parent; } @@ -121,12 +121,6 @@ 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"; - switch ($sco_user->cmi_core_lesson_status) { - case "not attempted": - case "incomplete": - case "browsed": - $incomplete = true; - } } else { echo " \"".get_string("notattempted","scorm")."\""; $incomplete = true; @@ -136,8 +130,11 @@ echo "  $sco->title\n \n"; } } + for ($i=0;$i<$level;$i++){ + echo "
    \n"; + } } - echo "
\n
\n"; print_simple_box_end(); echo "
id\">\n";