From: bobopinna Date: Mon, 7 Jun 2004 12:16:41 +0000 (+0000) Subject: Fixed PHP_SELF and patched some other playing problems X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5d8790cb77c21b845205995cdb0521ed04de32dd;p=moodle.git Fixed PHP_SELF and patched some other playing problems --- diff --git a/mod/scorm/cmi.php b/mod/scorm/cmi.php index 32f08dedd8..2ce1476713 100755 --- a/mod/scorm/cmi.php +++ b/mod/scorm/cmi.php @@ -49,7 +49,7 @@ cmi -
?id=id ?>"> + diff --git a/mod/scorm/coursefiles.php b/mod/scorm/coursefiles.php index 0414315835..b514910f05 100755 --- a/mod/scorm/coursefiles.php +++ b/mod/scorm/coursefiles.php @@ -35,7 +35,7 @@ function html_header($course, $wdir, $formfield=""){ - global $CFG,$THEME; + global $CFG,$THEME,$ME; if (! $site = get_site()) { error("Invalid site!"); @@ -57,9 +57,9 @@ for ($i=1; $i<$numdirs; $i++) { $navigation .= " -> "; $link .= "/".urlencode($dirs[$i]); - $navigation .= "id&wdir=$link\">".$dirs[$i].""; + $navigation .= "id&wdir=$link\">".$dirs[$i].""; } - $fullnav = "id&wdir=/\">$strfiles $navigation"; + $fullnav = "id&wdir=/\">$strfiles $navigation"; } print_header(); @@ -153,7 +153,7 @@ echo "

$struploadafile ($strmaxsize) --> $wdir"; echo "
"; - echo ""; + echo ""; echo " "; echo " "; echo " "; @@ -163,7 +163,7 @@ echo " "; echo ""; echo ""; - echo "
"; + echo ""; echo " "; echo " "; echo " "; @@ -196,8 +196,8 @@ print_simple_box_end(); echo "
"; notice_yesno (get_string("deletecheckfiles"), - "".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&action=delete&confirm=1", - "".basename($_SERVER['PHP_SELF'])."?id=$id&wdir=$wdir&action=cancel"); + "".basename($ME)."?id=$id&wdir=$wdir&action=delete&confirm=1", + "".basename($ME)."?id=$id&wdir=$wdir&action=cancel"); } else { displaydir($wdir); } @@ -253,7 +253,7 @@ html_header($course, $wdir, "form.name"); echo "

$strrenamefileto:"; echo "
"; - echo ""; + echo ""; echo " "; echo " "; echo " "; @@ -262,7 +262,7 @@ echo " "; echo ""; echo ""; - echo "
"; + echo ""; echo " "; echo " "; echo " "; @@ -291,7 +291,7 @@ html_header($course, $wdir, "form.name"); echo "

$strcreatefolder:"; echo "
"; - echo ""; + echo ""; echo " "; echo " "; echo " "; @@ -299,7 +299,7 @@ echo " "; echo ""; echo ""; - echo "
"; + echo ""; echo " "; echo " "; echo " "; @@ -338,7 +338,7 @@ print_heading("$streditfile"); echo "
"; - echo ""; + echo ""; echo " "; echo " "; echo " "; @@ -348,7 +348,7 @@ echo " "; echo ""; echo ""; - echo "
"; + echo ""; echo " "; echo " "; echo " "; @@ -402,7 +402,7 @@ echo "
"; echo "

".get_string("whattocallzip"); echo "
"; - echo ""; + echo ""; echo " "; echo " "; echo " "; @@ -410,7 +410,7 @@ echo " "; echo ""; echo ""; - echo "
"; + echo ""; echo " "; echo " "; echo " "; @@ -476,7 +476,7 @@ print_simple_box_end(); } - echo "
"; + echo "
"; echo " "; echo " "; echo " "; @@ -523,7 +523,7 @@ } echo "
"; } - echo "

"; + echo "
"; echo " "; echo " "; echo " "; @@ -670,7 +670,7 @@ function displaydir ($wdir) { global $basedir; global $id; - global $USER, $CFG; + global $USER, $CFG, $ME; $fullpath = $basedir.$wdir; @@ -707,7 +707,7 @@ function displaydir ($wdir) { $strchoose = get_string("choose"); - echo ""; + echo ""; echo ""; echo ""; echo ""; @@ -737,10 +737,10 @@ function displaydir ($wdir) { echo ""; print_cell("center", ""); - print_cell("left", "pixpath/f/folder.gif\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"Folder\">".htmlspecialchars($dir).""); + print_cell("left", "pixpath/f/folder.gif\" HEIGHT=16 WIDTH=16 BORDER=0 ALT=\"Folder\">".htmlspecialchars($dir).""); print_cell("right", "-"); print_cell("right", $filedate); - print_cell("right", "$strrename"); + print_cell("right", "$strrename"); echo ""; } @@ -790,13 +790,13 @@ function displaydir ($wdir) { $edittext = "$strchoose "; if ($icon == "text.gif" || $icon == "html.gif") { - $edittext .= "$stredit"; + $edittext .= "$stredit"; } else if ($icon == "zip.gif") { - $edittext .= "$strunzip "; - $edittext .= "$strlist "; + $edittext .= "$strunzip "; + $edittext .= "$strlist "; } - print_cell("right", "$edittext $strrename"); + print_cell("right", "$edittext $strrename"); echo ""; } @@ -824,7 +824,7 @@ function displaydir ($wdir) { echo ""; echo ""; echo "
"; if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) { - echo "
"; + echo ""; echo " "; echo " "; echo " "; @@ -832,7 +832,7 @@ function displaydir ($wdir) { echo "
"; } echo "
"; - echo "
"; + echo ""; echo " "; echo " "; echo " "; @@ -840,7 +840,7 @@ function displaydir ($wdir) { echo "
"; echo "
"; - echo "
"; + echo ""; echo " "; echo " "; echo " "; diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index f54bda2768..db85635099 100755 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -227,7 +227,11 @@ function scorm_startElement($parser, $name, $attrs) { if ($name == "ITEM") { $i++; $manifest[$i]["identifier"] = $attrs["IDENTIFIER"]; + if (empty($attrs["IDENTIFIERREF"])) + $attrs["IDENTIFIERREF"] = ""; $manifest[$i]["identifierref"] = $attrs["IDENTIFIERREF"]; + if (empty($attrs["ISVISIBLE"])) + $attrs["ISVISIBLE"] = ""; $manifest[$i]["isvisible"] = $attrs["ISVISIBLE"]; $manifest[$i]["parent"] = $parent[$level]; $level++; @@ -245,9 +249,9 @@ function scorm_endElement($parser, $name) { $level--; } if ($name == "TITLE" && $level>0) - $manifest[$i]["title"] = $datacontent; - if ($name == "ADLCP:HIDERTSUI") - $manifest[$i][$datacontent] = 1; + $manifest[$i]["title"] = $datacontent; + if ($name == "ADLCP:HIDERTSUI") + $manifest[$i][$datacontent] = 1; } function scorm_characterData($parser, $data) { @@ -290,14 +294,22 @@ function scorm_parse($basedir,$file,$scorm_id) { $sco->identifier = $manifest[$j]["identifier"]; $sco->parent = $manifest[$j]["parent"]; $sco->title = $manifest[$j]["title"]; - $sco->launch = $resources[$manifest[$j]["identifierref"]]["href"]; - $sco->type = $resources[$manifest[$j]["identifierref"]]["type"]; - $sco->previous = $manifest[$j]["previous"]; - $sco->next = $manifest[$j]["continue"]; - if (scorm_remove_spaces($manifest[$j]["isvisible"]) != "false") - $id = insert_record("scorm_scoes",$sco); - if ($launch==0 && $sco->launch) - $launch = $id; + if (empty($resources[($manifest[$j]["identifierref"])]["href"])) + $resources[($manifest[$j]["identifierref"])]["href"] = ""; + $sco->launch = $resources[($manifest[$j]["identifierref"])]["href"]; + if (empty($resources[($manifest[$j]["identifierref"])]["type"])) + $resources[($manifest[$j]["identifierref"])]["type"] = ""; + $sco->type = $resources[($manifest[$j]["identifierref"])]["type"]; + if (empty($manifest[$j]["previous"])) + $manifest[$j]["previous"] = 0; + $sco->previous = $manifest[$j]["previous"]; + if (empty($manifest[$j]["continue"])) + $manifest[$j]["continue"] = 0; + $sco->next = $manifest[$j]["continue"]; + if (scorm_remove_spaces($manifest[$j]["isvisible"]) != "false") + $id = insert_record("scorm_scoes",$sco); + if ($launch==0 && $sco->launch) + $launch = $id; } return $launch; } @@ -345,14 +357,14 @@ function scorm_external_link($link) { $result = true; else if (substr($link,0,4) == "www.") $result = true; - else if (substr($link,0,7) == "rstp://") + /*else if (substr($link,0,7) == "rstp://") $result = true; else if (substr($link,0,6) == "rtp://") $result = true; else if (substr($link,0,6) == "ftp://") $result = true; else if (substr($link,0,9) == "gopher://") - $result = true; + $result = true; */ return $result; } ?> diff --git a/mod/scorm/mod.html b/mod/scorm/mod.html index ad7db3c930..efd858e0dd 100755 --- a/mod/scorm/mod.html +++ b/mod/scorm/mod.html @@ -8,6 +8,9 @@ if (empty($form->summary)) { $form->summary = ""; } + if (empty($form->launch)) { + $form->launch = ""; + } if (empty($form->auto)) { $form->auto = ""; } diff --git a/mod/scorm/scormAPI.php b/mod/scorm/scormAPI.php index d4faf10cf6..e61621b8b5 100755 --- a/mod/scorm/scormAPI.php +++ b/mod/scorm/scormAPI.php @@ -35,14 +35,20 @@ require_login($course->id); if ( $scoes_user = get_records_select("scorm_sco_users","userid = ".$USER->id." AND scormid = ".$scorm->id,"scoid ASC") ) { - if ($scoid) { + // + // Already user + // + if (!empty($scoid)) { + // Direct sco request $sco = get_record("scorm_scoes","id",$scoid); } else { + // Search for first incomplete sco foreach ( $scoes_user as $sco_user ) { if (($sco_user->cmi_core_lesson_status != "completed") && ($sco_user->cmi_core_lesson_status != "passed") && ($sco_user->cmi_core_lesson_status != "failed")) { $sco = get_record("scorm_scoes","id",$sco_user->scoid); break; } else { + // If review mode get the first if ($mode == "review") { $sco = get_record("scorm_scoes","id",$sco_user->scoid); break; @@ -50,13 +56,21 @@ } } } - if (!$sco) - $sco = get_record_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' order by id ASC"); - } else { + if (!isset($sco)) { // If no sco was found get the first of SCORM package + $scoes = get_records_select("scorm_scoes","scorm=".$scorm->id." AND launch<>'' order by id ASC"); + $sco = each($scoes); + } + } else { + // + // A new user + // if ($scoes = get_records("scorm_scoes","scorm",$scorm->id,"id ASC")) { + // + // Create user scoes records + // foreach ($scoes as $sco) { if ($sco->launch != "") { - if (!$first) + if (!isset($first)) $first = $sco; $sco_user->userid = $USER->id; $sco_user->scoid = $sco->id; @@ -64,13 +78,14 @@ $element = "cmi_core_lesson_status"; if ($sco->type == "sco") $sco_user->$element = "not attempted"; - else if ($sco->type == "sca") + else if (($sco->type == "sca") || ($sco->type == "asset")) $sco_user->$element = "completed"; $ident = insert_record("scorm_sco_users",$sco_user); } } - $sco = $first; - if ($scoid) { + if (isset($first)) + $sco = $first; + if (!empty($scoid)) { if ($sco = get_record("scorm_scoes","id",$scoid)) unset($first); } @@ -120,6 +135,12 @@ include("api1_2.php"); ?> +function hilightcurrent(popupmenu) { + for (i=0;i < popupmenu.options.length;i++) { + if ( popupmenu.options[i].value == id; ?> ) + popupmenu.options[i].selected = true; + } +} function SCOInitialize() { top.main.location=""; - for (i=0;iid; ?> ) - top.nav.document.navform.courseStructure.options[i].selected = true; - } + hilightcurrent(top.nav.document.navform.courseStructure); + } function changeSco(direction) { diff --git a/mod/scorm/view.php b/mod/scorm/view.php index 9e24551d59..f89a5627b4 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -123,6 +123,8 @@ 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")) + $incomplete = true; } else { echo " \"".get_string("notattempted","scorm")."\""; $incomplete = true;