diff --git a/mod/hotpot/iframe.js b/mod/hotpot/iframe.js index 472de858781..10f337e34f6 100644 --- a/mod/hotpot/iframe.js +++ b/mod/hotpot/iframe.js @@ -16,16 +16,16 @@ function px(i) { return i + "px"; } function setSize(obj, w, h) { - if (is.n4) with (obj) { - if (w) width = w; - if (h) height = h; - } else if (is.opera) with (obj.style) { + if (is.n4) { + if (w) obj.width = w; + if (h) obj.height = h; + } else if (is.opera) { // opera 5 needs pixelWidth/Height - if (w) pixelWidth = w; - if (h) pixelHeight = h; - } else with (obj.style) { - if (w) width = px(w); - if (h) height = px(h); + if (w) obj.style.pixelWidth = w; + if (h) obj.style.pixelHeight = h; + } else { + if (w) obj.style.width = px(w); + if (h) obj.style.height = px(h); } } function getElement(id, lyr) { @@ -37,13 +37,15 @@ is = new domSniffer(); function set_iframe_height(id) { var iframe = getElement(id); if (iframe) { - obj = iframe.document; - if (obj.body) { - obj = obj.body; - } - var h = getContentH(obj); - if (h) { - setSize(iframe, 0, h); + var obj = iframe.document || iframe.contentDocument || null; // IE || FireFox + if (obj) { + if (obj.body) { + obj = obj.body; + } + var h = getContentH(obj); + if (h) { + setSize(iframe, 0, h); + } } } } diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php index 63fc4ee03e2..769db26465c 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -49,10 +49,10 @@ $HOTPOT_OUTPUTFORMAT = array ( HOTPOT_OUTPUTFORMAT_BEST => get_string("outputformat_best", "hotpot"), HOTPOT_OUTPUTFORMAT_V6_PLUS => get_string("outputformat_v6_plus", "hotpot"), HOTPOT_OUTPUTFORMAT_V6 => get_string("outputformat_v6", "hotpot"), - // HOTPOT_OUTPUTFORMAT_V5_PLUS => get_string("outputformat_v5_plus", "hotpot"), - // HOTPOT_OUTPUTFORMAT_V5 => get_string("outputformat_v5", "hotpot"), - // HOTPOT_OUTPUTFORMAT_V4 => get_string("outputformat_v4", "hotpot"), - // HOTPOT_OUTPUTFORMAT_V3 => get_string("outputformat_v3", "hotpot"), + HOTPOT_OUTPUTFORMAT_V5_PLUS => get_string("outputformat_v5_plus", "hotpot"), + HOTPOT_OUTPUTFORMAT_V5 => get_string("outputformat_v5", "hotpot"), + HOTPOT_OUTPUTFORMAT_V4 => get_string("outputformat_v4", "hotpot"), + HOTPOT_OUTPUTFORMAT_V3 => get_string("outputformat_v3", "hotpot"), // HOTPOT_OUTPUTFORMAT_FLASH => get_string("outputformat_flash", "hotpot"), // HOTPOT_OUTPUTFORMAT_MOBILE => get_string("outputformat_mobile", "hotpot"), ); @@ -1627,8 +1627,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree { } function insert_form($startblock, $endblock, $form_name, $form_fields, $center=false) { global $CFG; - $char = substr($endblock, 0, 1); - $search = '#(?<='.preg_quote($startblock).')'."[^$char]*".'(?='.preg_quote($endblock).')#'; + $search = '#(?<='.preg_quote($startblock).')(.+?)(?='.preg_quote($endblock).')#s'; $replace = '
'.$form_fields.'
'; if ($center) { $replace = '
'.$replace.'
'; diff --git a/mod/hotpot/view.php b/mod/hotpot/view.php index dbf2390af8b..b8e1a0b1ab6 100644 --- a/mod/hotpot/view.php +++ b/mod/hotpot/view.php @@ -140,7 +140,7 @@ $get_css = optional_param('css'); $framename = optional_param('framename'); - // look for (v5) + // look for (HP5 v5) $frameset = ''; $frameset_tags = ''; if (preg_match_all('|]*)>(.*?)|is', $hp->html, $matches)) { @@ -176,26 +176,30 @@ if (empty($frameset)) { // HP6 v6 - if ($hotpot->navigation==HOTPOT_NAVIGATION_BUTTONS) { - // convert URLs in nav buttons - } else { - $hp->remove_nav_buttons(); - } - if ($hotpot->navigation==HOTPOT_NAVIGATION_GIVEUP) { - $hp->insert_giveup_form($attemptid, '', ''); + switch ($hotpot->navigation) { + case HOTPOT_NAVIGATION_BUTTONS: + // do nothing (i.e. leave buttons as they are) + break; + case HOTPOT_NAVIGATION_GIVEUP: + $hp->insert_giveup_form($attemptid, '', ''); + break; + default: + $hp->remove_nav_buttons(); } $hp->insert_submission_form($attemptid, '', ''); } else { // HP5 v5 - if ($hotpot->navigation==HOTPOT_NAVIGATION_BUTTONS) { - // convert URLs in nav buttons - } else { - // remove navigation buttons - $hp->html = preg_replace('#NavBar\+=(.*);#', '', $hp->html); - } - if ($hotpot->navigation==HOTPOT_NAVIGATION_GIVEUP) { - // $hp->insert_giveup_form($attemptid, '', ''); + switch ($hotpot->navigation) { + case HOTPOT_NAVIGATION_BUTTONS: + // convert URLs in nav buttons + break; + case HOTPOT_NAVIGATION_GIVEUP: + // $hp->insert_giveup_form($attemptid, '', ''); + break; + default: + // remove navigation buttons + $hp->html = preg_replace('#NavBar\+=(.*);#', '', $hp->html); } $hp->insert_submission_form($attemptid, "var NavBar='", "';"); } @@ -325,6 +329,7 @@ $footer = ''; if ($frameset) { + // HP5 v5 switch ($framename) { case 'top': print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas); @@ -348,7 +353,7 @@ print "$frameset\n"; print "\n"; break; - } // end switch $frameset + } // end switch $framename exit; // is there a (HP6 and HP5: v6 and v4) @@ -431,12 +436,12 @@ print "\n"; print "\n"; break; - } // end switch $frameset + } // end switch $framename break; case HOTPOT_NAVIGATION_IFRAME: - switch ($frameset) { + switch ($framename) { case 'main'; print $hp->html; break; @@ -445,7 +450,7 @@ $iframe_id = 'hotpot_iframe'; $body_tags = " onload=\"set_iframe_height('$iframe_id')\""; - $iframe_js = ''."\n"; print_header( $title, $heading, $navigation, @@ -455,13 +460,13 @@ if (!empty($available_msg)) { notify($available_msg); } - print "\n"; print $footer; break; - } // end switch $frameset + } // end switch $framename break; default: