]> git.mjollnir.org Git - moodle.git/commitdiff
fixes for XHTML strict: add <fieldset> arround hidden form fields, use "id" instead...
authorgbateson <gbateson>
Sun, 24 May 2009 09:03:09 +0000 (09:03 +0000)
committergbateson <gbateson>
Sun, 24 May 2009 09:03:09 +0000 (09:03 +0000)
mod/hotpot/hotpot-full.js
mod/hotpot/lib.php
mod/hotpot/template/v6.php

index 61879e2a7ddcc52b6d9d43f706b735650c4fae18..bb66e65fd5d39159328b0021ce58476281ba0142 100644 (file)
@@ -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; i<w.frames.length; i++) {
-                               f = hpFindForm(formname, w.frames[i]);
-                               if (f) break;
+                               var f = hpFindForm(formname, w.frames[i]);
+                               if (f) {
+                    return f;
+                }
                }
        }
-       return f;
+       return null;
 }
 function Finish(quizstatus) {
        var mark = hpScore();
index f1ebad4eb371d34f0dfbe6a73ef1ee633e1c4ee2..6bb952a698b7d31fc3e4edd87bf163986785aaa3 100644 (file)
@@ -1817,19 +1817,21 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
         $this->html = preg_replace('|</head>|i', $script.'</head>', $this->html, 1);
     }
     function insert_submission_form($attemptid, $startblock, $endblock, $keep_contents=false, $targetframe='') {
-        $form_name = 'store';
+        $form_id = 'store';
         $form_fields = ''
+        .   '<fieldset style="display:none">'
         .   '<input type="hidden" name="attemptid" value="'.$attemptid.'" />'
         .   '<input type="hidden" name="starttime" value="" />'
         .   '<input type="hidden" name="endtime" value="" />'
         .   '<input type="hidden" name="mark" value="" />'
         .   '<input type="hidden" name="detail" value="" />'
         .   '<input type="hidden" name="status" value="" />'
+        .   '</fieldset>'
         ;
-        $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 <form> tag will be generated
+        $form_id = ''; // no <form> tag will be generated
         $form_fields = ''
         .   '<button onclick="Finish('.HOTPOT_STATUS_ABANDONED.')" class="FuncButton" '
         .   'onfocus="FuncBtnOver(this)" onblur="FuncBtnOut(this)" '
@@ -1837,9 +1839,9 @@ class hotpot_xml_quiz extends hotpot_xml_tree {
         .   'onmousedown="FuncBtnDown(this)" onmouseup="FuncBtnOut(this)">'
         .   get_string('giveup', 'hotpot').'</button>'
         ;
-        $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 = '<form action="'.$CFG->wwwroot.'/mod/hotpot/attempt.php" method="post" name="'.$form_name.'"'.$frametarget.'>'.$replace.'</form>';
+        if ($form_id) {
+            $replace = '<form action="'.$CFG->wwwroot.'/mod/hotpot/attempt.php" method="post" id="'.$form_id.'"'.$frametarget.'>'.$replace.'</form>';
         }
         if ($center) {
             $replace = '<div style="margin-left:auto; margin-right:auto; text-align: center;">'.$replace.'</div>';
index 69d177c208900f734aa723379bdbe30bb328de17..f77cf72a1fea8155127cebfbd9546b2da4b971d1 100644 (file)
@@ -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(
+            '/<!DOCTYPE[^>]*>/',
+            '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
+            $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('<=', '&lt;=', $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=='=>' ? '=&gt;' : $caption);
+        return str_replace('=>', '=&gt;', $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');