]> git.mjollnir.org Git - moodle.git/commitdiff
Fixes reopened bug MDL-7472, "Explicitly label radio buttons in Survey" - removes...
authornfreear <nfreear>
Wed, 21 Nov 2007 14:50:32 +0000 (14:50 +0000)
committernfreear <nfreear>
Wed, 21 Nov 2007 14:50:32 +0000 (14:50 +0000)
lang/en_utf8/survey.php
mod/survey/lib.php
theme/standard/styles_layout.css

index 21a3cfc1b700f1e5a82cb7d68bee272b5d8db206..e33f3c1494beae878995a2acd4618f7afcc4b04a 100644 (file)
@@ -193,6 +193,7 @@ $string['question'] = 'Question';
 $string['questions'] = 'Questions';
 $string['questionsnotanswered'] = 'Some of the multiple choice questions have not been answered.';
 $string['report'] = 'Survey report';
+$string['responses'] = 'Responses';
 $string['savednotes'] = 'Your notes were saved';
 $string['scaleagree5'] = 'Strongly disagree,Somewhat disagree,Neither agree nor disagree,Somewhat agree,Strongly agree';
 $string['scales'] = 'Scales';
index 1f42a9ca90b12696777d222ce84a84086b8cb18d..5db869e9a1d9a05abe31316fa6135f6972a25350 100644 (file)
@@ -349,14 +349,15 @@ function survey_shorten_name ($name, $numwords) {
 
 
 function survey_print_multi($question) {
-    GLOBAL $USER, $db, $qnum, $checklist;
+    global $USER, $db, $qnum, $checklist;
 
     $stripreferthat = get_string("ipreferthat", "survey");
     $strifoundthat = get_string("ifoundthat", "survey");
-    echo "<br />\n";
-    echo "<span class='questiontext'><b>$question->text</b></span><br />";
-    echo "<div style=\"text-align:center\">";
-    echo "<table width=\"90%\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\">";
+    $strdefault    = get_string('default');
+    $strresponses  = get_string('responses', 'survey');
+
+    print_heading($question->text, null, 3, 'questiontext');
+    echo "\n<table width=\"90%\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\">";
 
     $options = explode( ",", $question->options);
     $numoptions = count($options);
@@ -367,20 +368,21 @@ function survey_print_multi($question) {
     } else {
         $P = "";
     }
-   
-    if ($oneanswer) { 
-        echo "<tr><td colspan=\"2\">$question->intro</td>";
-    } else {
-        echo "<tr><td colspan=\"3\">$question->intro</td>"; 
-    }
 
+    echo "<tr class=\"smalltext\"><th scope=\"row\">$strresponses</th>";
     while (list ($key, $val) = each ($options)) {
-        echo "<td class=\"smalltextcell\"><span class='smalltext'>$val</span></td>\n";
+        echo "<th scope=\"col\" class=\"hresponse\">$val</th>\n";
+    }
+    echo "<th>&nbsp;</th></tr>\n";
+
+    if ($oneanswer) {
+        echo "<tr><th scope=\"col\" colspan=\"6\">$question->intro</th></tr>\n";
+    } else {
+        echo "<tr><th scope=\"col\" colspan=\"7\">$question->intro</th></tr>\n"; 
     }
-    echo "<td align=\"center\">&nbsp;</td></tr>\n";
 
     $subquestions = get_records_list("survey_questions", "id", $question->multi);
-    
+
     foreach ($subquestions as $q) {
         $qnum++;
         $rowclass = survey_question_rowclass($qnum);
@@ -388,54 +390,61 @@ function survey_print_multi($question) {
             $q->text = get_string($q->text, "survey");
         }
 
-        echo "<tr class=\"$rowclass\">";
+        echo "<tr class=\"$rowclass rblock\">";
         if ($oneanswer) {
 
-            echo "<td class=\"qnumtopcell\"><b>$qnum</b></td>";
-            echo "<td valign=\"top\">$q->text</td>";
-            for ($i=1;$i<=$numoptions;$i++) {            
-                $screenreader = !empty($USER->screenreader)?"<label for=\"q$P" . $q->id . "_$i\">".$options[$i-1]."</label><br/>":'';
-                echo "<td class=\"screenreadertext\">".$screenreader."<input type=\"radio\" name=\"q$P$q->id\" id=\"q$P" . $q->id . "_$i\" value=\"$i\" alt=\"$i\" /></td>";
+            echo "<th scope=\"row\" class=\"optioncell\">";
+            echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
+            echo $q->text ."</th>\n";
+            for ($i=1;$i<=$numoptions;$i++) {
+                $hiddentext = get_accesshide($options[$i-1]);
+                $id = "q$P" . $q->id . "_$i";
+                echo "<td><label for=\"$id\"><input type=\"radio\" name=\"q$P$q->id\" id=\"$id\" value=\"$i\" />$hiddentext</label></td>";
             }
-            echo "<td class=\"whitecell\"><input type=\"radio\" name=\"q$P$q->id\" value=\"0\" checked=\"checked\" alt=\"0\" /></td>";
+            $default = get_accesshide($strdefault, 'label', '', "for=\"q$P$q->id\"");
+            echo "<td class=\"whitecell\"><input type=\"radio\" name=\"q$P$q->id\" id=\"q$P" . $q->id . "_D\" value=\"0\" checked=\"checked\" />$default</td>";
             $checklist["q$P$q->id"] = $numoptions;
         
         } else { 
             // yu : fix for MDL-7501, possibly need to use user flag as this is quite ugly.
-            echo "<td class=\"qnummiddlecell\"><b>$qnum</b></td>";
+            echo "<th scope=\"row\" class=\"optioncell\">";
+            echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
             $qnum++;
-            echo "<td class=\"preferthat\"><span class='smalltext'>$stripreferthat&nbsp;</span></td>";
-            echo "<td class=\"optioncell\">$q->text</td>";
+            echo "<span class=\"preferthat smalltext\">$stripreferthat</span> &nbsp; ";
+            echo "<span class=\"option\">$q->text</span></th>\n";
             for ($i=1;$i<=$numoptions;$i++) {
-                $screenreader = !empty($USER->screenreader)?"<label for=\"qP" . $q->id . "_$i\">".$options[$i-1]."</label><br/>":'';
-                echo "<td class=\"screenreadertext\">".$screenreader."<input type=\"radio\" name=\"qP$q->id\" id=\"qP" . $q->id . "_$i\" value=\"$i\" alt=\"$i\"/></td>";
+                $hiddentext = get_accesshide($options[$i-1]);
+                $id = "qP" . $q->id . "_$i";
+                echo "<td><label for=\"$id\"><input type=\"radio\" name=\"qP$q->id\" id=\"$id\" value=\"$i\" />$hiddentext</label></td>";
             }
-            echo "<td><input type=\"radio\" name=\"qP$q->id\" value=\"0\" checked=\"checked\" alt=\"0\" /></td>";
+            $default = get_accesshide($strdefault, 'label', '', "for=\"qP$q->id\"");
+            echo "<td><input type=\"radio\" name=\"qP$q->id\" id=\"qP$q->id\" value=\"0\" checked=\"checked\" />$default</td>";
             echo "</tr>";
 
-            echo "<tr class=\"$rowclass\">";
-            echo "<td class=\"qnumtopcell\"><b>$qnum</b></td>";
-            echo "<td class=\"foundthat\"><span class='smalltext'>$strifoundthat&nbsp;</span></td>";
-            echo "<td class=\"optioncell\">$q->text</td>";
+            echo "<tr class=\"$rowclass rblock\">";
+            echo "<th scope=\"row\" class=\"optioncell\">";
+            echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
+            echo "<span class=\"foundthat smalltext\">$strifoundthat</span> &nbsp; ";
+            echo "<span class=\"option\">$q->text</span></th>\n";
             for ($i=1;$i<=$numoptions;$i++) {
-                $screenreader = !empty($USER->screenreader)?"<label for=\"q" . $q->id . "_$i\">".$options[$i-1]."</label><br/>":'';
-                echo "<td class=\"screenreadertext\">".$screenreader."<input type=\"radio\" name=\"q$q->id\" id=\"q" . $q->id . "_$i\" value=\"$i\" alt=\"$i\" /></td>";
+                $hiddentext = get_accesshide($options[$i-1]);
+                $id = "q" . $q->id . "_$i";
+                echo "<td><label for=\"$id\"><input type=\"radio\" name=\"q$q->id\" id=\"$id\" value=\"$i\" />$hiddentext</label></td>";
             }
-            echo "<td class=\"buttoncell\"><input type=\"radio\" name=\"q$q->id\" value=\"0\" checked=\"checked\" alt=\"0\" /></td>";
+            $default = get_accesshide($strdefault, 'label', '', "for=\"q$q->id\"");
+            echo "<td class=\"buttoncell\"><input type=\"radio\" name=\"q$q->id\" id=\"q$q->id\" value=\"0\" checked=\"checked\" />$default</td>";
             $checklist["qP$q->id"] = $numoptions;
             $checklist["q$q->id"] = $numoptions;            
         }
         echo "</tr>\n";
-        
     }
     echo "</table>";
-    echo "</div>";
 }
 
 
 
 function survey_print_single($question) {
-    GLOBAL $db, $qnum;
+    global $db, $qnum;
 
     $rowclass = survey_question_rowclass(0);
 
@@ -444,17 +453,17 @@ function survey_print_single($question) {
     echo "<br />\n";
     echo "<table width=\"90%\" cellpadding=\"4\" cellspacing=\"0\">\n";
     echo "<tr class=\"$rowclass\">";
-    echo "<td valign=\"top\"><b>$qnum</b></td>";
-    echo "<td class=\"questioncell\">$question->text</td>\n";
-    echo "<td class=\"questioncell\"><span class='smalltext'>\n";
+    echo "<th scope=\"row\" class=\"optioncell\"><label for=\"q$question->id\"><b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
+    echo "<span class=\"questioncell\">$question->text</span></label></th>\n";
+    echo "<td class=\"questioncell smalltext\">\n";
 
 
     if ($question->type == 0) {           // Plain text field
-        echo "<textarea rows=\"3\" cols=\"30\" name=\"q$question->id\">$question->options</textarea>";
+        echo "<textarea rows=\"3\" cols=\"30\" name=\"q$question->id\" id=\"q$question->id\">$question->options</textarea>";
 
     } else if ($question->type > 0) {     // Choose one of a number
         $strchoose = get_string("choose");
-        echo "<select name=\"q$question->id\">";
+        echo "<select name=\"q$question->id\" id=\"q$question->id\">";
         echo "<option value=\"0\" selected=\"selected\">$strchoose...</option>";
         $options = explode( ",", $question->options);
         foreach ($options as $key => $val) {
@@ -468,7 +477,7 @@ function survey_print_single($question) {
         notify("This question type not supported yet");
     }
 
-    echo "</span></td></tr></table>";
+    echo "</td></tr></table>";
 
 }
 
index c2d6521a4c14c582d16bd7680fc80d37329d0273..3116d48873818245851e891ff8579ddc566454c6 100644 (file)
@@ -4023,34 +4023,35 @@ table.quizreviewsummary td.cell {
 }
 
 .smalltext {
-  font-size:0.6em;
+  font-size: 0.75em;
 }
 
-.smalltextcell,
-.screenreadertext {
-  width:10%;
-  text-align:center;
+#surveyform th {
+  font-weight: normal;
+  text-align: left;
+}
+#surveyform th.hresponse {
+  text-align: center;
+  width: 9%;
+}
+
+.rblock label {
+  display: block;
+  text-align: center;
 }
 
 .foundthat,
 .preferthat {
-  width:10%;
   white-space: nowrap;
 }
 
-.qnumtopcell {
-  width:10px;
-  vertical-align:top;
-}
-
 .qnummiddlecell {
-  width:10px;
   vertical-align:middle;
 }
 
 .optioncell {
-  width:40%;
-  vertical-align:middle;
+  width: 50%;
+  vertical-align: top;
 }
 
 .buttoncell {