From 14fa46fa002958adb34d37559eb2bcd7d94952b3 Mon Sep 17 00:00:00 2001 From: gbateson Date: Sun, 24 May 2009 09:03:09 +0000 Subject: [PATCH] fixes for XHTML strict: add
arround hidden form fields, use "id" instead of "name" to locate forms, use HTML entities in button captions <= and => --- mod/hotpot/hotpot-full.js | 19 ++++++++++++++----- mod/hotpot/lib.php | 24 +++++++++++++++--------- mod/hotpot/template/v6.php | 11 ++++++++--- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/mod/hotpot/hotpot-full.js b/mod/hotpot/hotpot-full.js index 61879e2a7d..bb66e65fd5 100644 --- a/mod/hotpot/hotpot-full.js +++ b/mod/hotpot/hotpot-full.js @@ -2922,14 +2922,23 @@ hpInterceptClues(); hpInterceptChecks(); function hpFindForm(formname, w) { if (w==null) w = self; - var f = w.document.forms[formname]; - if (f==null && w.frames) { + var f = w.document.getElementById(formname); + if (f) { + return f; + } + var f = w.document.forms[formname]; + if (f) { + return f; + } + if (w.frames) { for (var i=0; ihtml = preg_replace('||i', $script.'', $this->html, 1); } function insert_submission_form($attemptid, $startblock, $endblock, $keep_contents=false, $targetframe='') { - $form_name = 'store'; + $form_id = 'store'; $form_fields = '' + . '
' . '' . '' . '' . '' . '' . '' + . '
' ; - $this->insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents, false, $targetframe); + $this->insert_form($startblock, $endblock, $form_id, $form_fields, $keep_contents, false, $targetframe); } function insert_giveup_form($attemptid, $startblock, $endblock, $keep_contents=false) { - $form_name = ''; // no
tag will be generated + $form_id = ''; // no tag will be generated $form_fields = '' . '' ; - $this->insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents, true); + $this->insert_form($startblock, $endblock, $form_id, $form_fields, $keep_contents, true); } - function insert_form($startblock, $endblock, $form_name, $form_fields, $keep_contents, $center=false, $targetframe='') { + function insert_form($startblock, $endblock, $form_id, $form_fields, $keep_contents, $center=false, $targetframe='') { global $CFG; $search = '#('.preg_quote($startblock).')(.*?)('.preg_quote($endblock).')#s'; $replace = $form_fields; @@ -1847,12 +1849,16 @@ class hotpot_xml_quiz extends hotpot_xml_tree { $replace .= '\\2'; } if ($targetframe) { - $frametarget = ' target="'.$targetframe.'"'; - } else { + $frametarget = ' onsubmit="'."this.target='$targetframe';".'"'; + } else if (! empty($CFG->framename)) { + $frametarget = ' onsubmit="'."this.target='$CFG->framename';".'"'; + } else if (! empty($CFG->frametarget)) { $frametarget = $CFG->frametarget; + } else { + $frametarget = ''; } - if ($form_name) { - $replace = ''.$replace.'
'; + if ($form_id) { + $replace = '
'.$replace.'
'; } if ($center) { $replace = '
'.$replace.'
'; diff --git a/mod/hotpot/template/v6.php b/mod/hotpot/template/v6.php index 69d177c208..f77cf72a1f 100644 --- a/mod/hotpot/template/v6.php +++ b/mod/hotpot/template/v6.php @@ -48,6 +48,12 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default { if (!empty($pattern)) { $this->expand_strings('html', $pattern); } + // fix doctype (convert short dtd to long dtd) + $this->html = preg_replace( + '/]*>/', + '', + $this->html, 1 + ); } // captions and messages @@ -68,7 +74,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default { return $this->int_value('hotpot-config-file,global,include-back'); } function v6_expand_BackCaption() { - return $this->parent->xml_value('hotpot-config-file,global,back-caption'); + return str_replace('<=', '<=', $this->parent->xml_value('hotpot-config-file,global,back-caption')); } function v6_expand_ClickToAdd() { return $this->parent->xml_value('hotpot-config-file,'.$this->parent->quiztype.',click-to-add'); @@ -115,8 +121,7 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default { return $this->int_value('hotpot-config-file,global,include-next-ex'); } function v6_expand_NextExCaption() { - $caption = $this->parent->xml_value('hotpot-config-file,global,next-ex-caption'); - return ($caption=='=>' ? '=>' : $caption); + return str_replace('=>', '=>', $this->parent->xml_value('hotpot-config-file,global,next-ex-caption')); } function v6_expand_NextQCaption() { return $this->parent->xml_value('hotpot-config-file,global,next-q-caption'); -- 2.39.5