From b98eebbf93918e0bbf3f0e5785f3e64fbf055076 Mon Sep 17 00:00:00 2001 From: bobopinna Date: Mon, 28 Jun 2004 11:20:52 +0000 Subject: [PATCH] Fixed some popup window problems (some still fixing) --- mod/scorm/api1_2.php | 6 +- mod/scorm/details.php | 73 +++++++++++----------- mod/scorm/lib.php | 40 ++++++------ mod/scorm/mod.html | 1 + mod/scorm/playscorm.php | 134 +++++++++++++++++++++------------------- mod/scorm/scormAPI.php | 22 ++++--- 6 files changed, 147 insertions(+), 129 deletions(-) diff --git a/mod/scorm/api1_2.php b/mod/scorm/api1_2.php index 360e981a6c3..f10e3085910 100644 --- a/mod/scorm/api1_2.php +++ b/mod/scorm/api1_2.php @@ -177,8 +177,8 @@ function SCORMapi() { return "false"; } if (Initialized) { - if (top.nav.cmi.document.theform) { - cmiform = top.nav.cmi.document.forms[0]; + if (cmi.document.theform) { + cmiform = cmi.document.forms[0]; cmiform.scoid.value = "id; ?>"; cmiform.cmi_core_lesson_location.value = cmi.core.lesson_location; cmiform.cmi_core_lesson_status.value = cmi.core.lesson_status; @@ -211,7 +211,7 @@ function SCORMapi() { auto) { if ($sco != $last) { - print "setTimeout('top.nav.document.navform.next.click();',500);\n"; + print "setTimeout('".$navObj."document.navform.next.click();',500);\n"; } else { print "exitloc = '".$CFG->wwwroot."/mod/scorm/view.php?id=$cm->id';\n"; print "setTimeout('top.location = exitloc;',500);\n"; diff --git a/mod/scorm/details.php b/mod/scorm/details.php index f2bc1f59c5f..9d29190be04 100755 --- a/mod/scorm/details.php +++ b/mod/scorm/details.php @@ -88,7 +88,7 @@ } echo "
destination\">\n"; - $form->popup = $CFG->scorm_popup; + //$form->popup = $CFG->scorm_popup; $strnewwindow = get_string("newwindow", "scorm"); $strnewwindowopen = get_string("newwindowopen", "scorm"); foreach ($SCORM_WINDOW_OPTIONS as $optionname) { @@ -98,7 +98,7 @@ $jsoption[] = "\"$optionname\""; } $alljsoptions = implode(",", $jsoption); - + if ($form->instance) { // Re-editing if ($form->popup == "") { $newwindow = ""; // Disable the new window @@ -107,12 +107,12 @@ $rawoptions = explode(',', $form->popup); foreach ($rawoptions as $rawoption) { $option = explode('=', trim($rawoption)); - if ((option != 'location') && (option != 'menubar') && (option != 'toolbar')) { + if (($option[0] != 'location') && ($option[0] != 'menubar') && ($option[0] != 'toolbar')) { $optionname = $option[0]; $optionvalue = $option[1]; if ($optionname == "height" or $optionname == "width") { $window->$optionname = $optionvalue; - } else if ($optionvalue) { + } else if ($optionvalue == 1) { $window->$optionname = "checked"; } } @@ -152,10 +152,14 @@ else document.theform.auto.disabled=false; } + + - - - onclick="autowindow();return lockoptions('theform','newwindow', subitems);"> + + onclick="autowindow();return lockoptions('theform','newwindow', subitems);" /> @@ -189,22 +190,22 @@ - - - - - - - - - - - - -
- "> - "> -
+ + + + + + + + + + + + +
+ " /> + " /> +
setnewwindow)) { - $optionlist = array(); - foreach ($SCORM_WINDOW_OPTIONS as $option) { - if (isset($scorm->$option)) { - $optionlist[] = $option."=".$scorm->$option; - } + $scorm->popup = ""; + + $optionlist = array(); + foreach ($SCORM_WINDOW_OPTIONS as $option) { + if (isset($scorm->$option)) { + $optionlist[] = $option."=".$scorm->$option; } - $scorm->popup = implode(',', $optionlist); - $scorm->popup .= ',location=0,menubar=0,toolbar=0'; - $scorm->auto = '0'; } + $scorm->popup = implode(',', $optionlist); + $scorm->auto = '0'; + + if ($scorm->popup != "") + $scorm->popup .= ',location=0,menubar=0,toolbar=0'; return insert_record("scorm", $scorm); } @@ -64,17 +66,19 @@ function scorm_update_instance($scorm) { # May have to add extra stuff in here # global $SCORM_WINDOW_OPTIONS; - if (isset($scorm->setnewwindow)) { - $optionlist = array(); - foreach ($SCORM_WINDOW_OPTIONS as $option) { - if (isset($scorm->$option)) { - $optionlist[] = $option."=".$scorm->$option; - } + $scorm->popup = ""; + + $optionlist = array(); + foreach ($SCORM_WINDOW_OPTIONS as $option) { + if (isset($scorm->$option)) { + $optionlist[] = $option."=".$scorm->$option; } - $scorm->popup = implode(',', $optionlist); - $scorm->popup .= ',location=0,menubar=0,toolbar=0'; - $scorm->auto = '0'; } + $scorm->popup = implode(',', $optionlist); + $scorm->auto = '0'; + + if ($scorm->popup != "") + $scorm->popup .= ',location=0,menubar=0,toolbar=0'; return update_record("scorm", $scorm); } diff --git a/mod/scorm/mod.html b/mod/scorm/mod.html index b6f874d8f61..0d9f1c9bf97 100755 --- a/mod/scorm/mod.html +++ b/mod/scorm/mod.html @@ -60,6 +60,7 @@ + diff --git a/mod/scorm/playscorm.php b/mod/scorm/playscorm.php index 8f7862a32ef..f0d29bbd054 100755 --- a/mod/scorm/playscorm.php +++ b/mod/scorm/playscorm.php @@ -55,7 +55,15 @@ update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm)); notice(get_string("activityiscurrentlyhidden")); } - if ($frameset == "top") { + + if (!empty($_POST["scoid"])) + $scoid = "&scoid=".$_POST["scoid"]; + if (($scorm->popup != "") && (!empty($_POST["mode"]))) + $mode = $_POST["mode"]; + if (($scorm->popup == "") && (!empty($_GET["mode"]))) + $mode = $_GET["mode"]; + + if (($frameset == "top") || ($scorm->popup != "")) { add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id"); // // Print the page header @@ -65,51 +73,15 @@ "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm, '_top')); echo "\n \n"; - if ($_GET["mode"] == "browse") + if ($mode == "browse") echo "\n"; echo " \n
".text_to_html($scorm->summary, true, false)."".get_string("browsemode","scorm")."
\n"; - - - echo "\n \n"; - echo " \n"; - - echo "\n
- -
id\" target=\"_top\"> - - -  \n"; - - if ($scorm->popup == "") { - 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; - } - } - 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"; - if ($scorm->popup != "") { + if ($scorm->popup != "") { + echo "\n"; $currentSCO = ""; - if (!empty($_GET['scoid'])) - $currentSCO = $_GET['scoid']; + if (!empty($_POST['scoid'])) + $currentSCO = $_POST['scoid']; ?>
+ \n\n"; } else { - if ($_POST["scoid"]) - $scoid = "&scoid=".$_POST["scoid"]; - echo "\n"; - echo "$course->shortname: $scorm->name\n"; - echo "\n"; - if ($scorm->popup == "") { // // Frameset // + echo "\n"; + echo "$course->shortname: $scorm->name\n"; + echo "\n"; echo "scorm_framesize,*\" onLoad=\"SCOInitialize();\">\n"; - echo " id&mode=".$_POST["mode"]."&frameset=top\">\n"; + echo " id&mode=".$mode."&frameset=top\">\n"; echo " \n"; - } else { - echo "'; - echo "\n\n"; - echo " id&mode=".$_POST["mode"]."&frameset=top".$scoid."\">\n"; + echo "\n"; + echo "\n"; } - echo "\n"; - echo "\n"; } ?> diff --git a/mod/scorm/scormAPI.php b/mod/scorm/scormAPI.php index 92880dfa6b3..ac5e33bf075 100755 --- a/mod/scorm/scormAPI.php +++ b/mod/scorm/scormAPI.php @@ -132,6 +132,10 @@ $result = "$CFG->wwwroot/file.php?file=/$scorm->course/moddata/scorm$scorm->datadir/$sco->launch"; } } + $navObj = "top."; + if ($scorm->popup == "") + $navObj = "top.nav."; + include("api1_2.php"); ?> @@ -146,26 +150,26 @@ function hilightcurrent(popupmenu) { function SCOInitialize() { previous || $first) { - print "\ttop.nav.document.navform.prev.disabled = true;\n"; - print "\ttop.nav.document.navform.prev.style.display = 'none';\n"; + print "\t".$navObj."document.navform.prev.disabled = true;\n"; + print "\t".$navObj."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"; + print "\t".$navObj."document.navform.next.disabled = true;\n"; + print "\t".$navObj."document.navform.next.style.display = 'none';\n"; } ?> top.main.location=""; popup == "") { ?> - hilightcurrent(top.nav.document.navform.courseStructure); + hilightcurrent(document.navform.courseStructure); } function changeSco(direction) { if (direction == "prev") - top.nav.document.navform.scoid.value=""; + document.navform.scoid.value=""; else - top.nav.document.navform.scoid.value=""; + document.navform.scoid.value=""; - //alert ("Prev: \nNext: \nNew SCO: "+top.nav.document.navform.scoid.value); - top.nav.document.navform.submit(); + //alert ("Prev: \nNext: \nNew SCO: "+document.navform.scoid.value); + document.navform.submit(); } \ No newline at end of file