$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.'" />'
. '<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
;
$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>';
$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)
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