Skip to content
Browse files

in order to allow hotpots to appear in a frame when navigation is set…

… to "Moodle navigation frame", it is necessary to use target="$CFG->framename" instead of CFG->frametarget
  • Loading branch information...
1 parent 3f9fd19 commit efedb7089509466e209b1ba0156ef5a3aebc5246 gbateson committed Oct 4, 2007
Showing with 14 additions and 5 deletions.
  1. +9 −4 mod/hotpot/lib.php
  2. +5 −1 mod/hotpot/view.php
View
13 mod/hotpot/lib.php
@@ -1675,7 +1675,7 @@ function insert_script($src=HOTPOT_JS) {
$script = '<script src="'.$src.'" type="text/javascript"></script>'."\n";
$this->html = preg_replace('|</head>|i', $script.'</head>', $this->html, 1);
}
- function insert_submission_form($attemptid, $startblock, $endblock, $keep_contents=false) {
+ function insert_submission_form($attemptid, $startblock, $endblock, $keep_contents=false, $targetframe='') {
$form_name = 'store';
$form_fields = ''
. '<input type="hidden" name="attemptid" value="'.$attemptid.'" />'
@@ -1685,7 +1685,7 @@ function insert_submission_form($attemptid, $startblock, $endblock, $keep_conten
. '<input type="hidden" name="detail" value="" />'
. '<input type="hidden" name="status" value="" />'
;
- $this->insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents);
+ $this->insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents, false, $targetframe);
}
function insert_giveup_form($attemptid, $startblock, $endblock, $keep_contents=false) {
$form_name = ''; // no <form> tag will be generated
@@ -1698,15 +1698,20 @@ function insert_giveup_form($attemptid, $startblock, $endblock, $keep_contents=f
;
$this->insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents, true);
}
- function insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents, $center=false) {
+ function insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents, $center=false, $targetframe='') {
global $CFG;
$search = '#('.preg_quote($startblock).')(.*?)('.preg_quote($endblock).')#s';
$replace = $form_fields;
if ($keep_contents) {
$replace .= '\\2';
}
+ if ($targetframe) {
+ $frametarget = ' target="'.$targetframe.'"';
+ } else {
+ $frametarget = $CFG->frametarget;
+ }
if ($form_name) {
- $replace = '<form action="'.$CFG->wwwroot.'/mod/hotpot/attempt.php" method="post" name="'.$form_name.'"'.$CFG->frametarget.'>'.$replace.'</form>';
+ $replace = '<form action="'.$CFG->wwwroot.'/mod/hotpot/attempt.php" method="post" name="'.$form_name.'"'.$frametarget.'>'.$replace.'</form>';
}
if ($center) {
$replace = '<div style="margin-left:auto; margin-right:auto; text-align: center;">'.$replace.'</div>';
View
6 mod/hotpot/view.php
@@ -153,20 +153,24 @@
$hp->adjust_media_urls();
if (empty($frameset)) {
// HP6 v6
+ $targetframe = '';
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, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->');
break;
+ case HOTPOT_NAVIGATION_FRAME:
+ $targetframe = $CFG->framename;
+ break;
default:
$hp->remove_nav_buttons();
}
if (isset($hp->real_outputformat) && $hp->real_outputformat==HOTPOT_OUTPUTFORMAT_MOBILE) {
$hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->', true);
} else {
- $hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->');
+ $hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->', false, $targetframe);
}
} else {
// HP5 v5

0 comments on commit efedb70

Please sign in to comment.
Something went wrong with that request. Please try again.