use target="$CFG->framename" instead of $CFG->frametarget when HotPot navigation is set to "Moodle navigation frame"so that Moodle does not get stuck in sub frame

This commit is contained in:
gbateson 2007-10-04 05:32:27 +00:00
parent d9a23b785f
commit b3687f28f1
2 changed files with 14 additions and 5 deletions

View File

@ -1781,7 +1781,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
$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.'" />'
@ -1791,7 +1791,7 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
. '<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
@ -1804,15 +1804,20 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
;
$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 File

@ -156,6 +156,7 @@
$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)
@ -163,13 +164,16 @@
case HOTPOT_NAVIGATION_GIVEUP:
$hp->insert_giveup_form($attemptid, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->');
break;
case HOTPOT_NAVIGATION_FRAME:
$targetframe = $CFG->framename;
// drop through to remove nav buttons too
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