Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-20487 - improve accessibility issue for survey page layout and st…

…ring.
  • Loading branch information...
commit 6438c34f36d26de09dcbecd34edc724dd66c3ea4 1 parent 6595a56
Rossiani Wijaya authored
View
2  mod/survey/lang/en/survey.php
@@ -243,3 +243,5 @@
$string['thanksforanswers'] = 'Thanks for answering this survey, {$a}';
$string['time'] = 'Time';
$string['viewsurveyresponses'] = 'View {$a} survey responses';
+$string['notyetanswered'] = 'Not yet answered';
+$string['allquestionrequireanswer'] = 'All questions are required and must be answered';
View
38 mod/survey/lib.php
@@ -524,7 +524,7 @@ function survey_print_multi($question) {
$stripreferthat = get_string("ipreferthat", "survey");
$strifoundthat = get_string("ifoundthat", "survey");
- $strdefault = get_string('default');
+ $strdefault = get_string('notyetanswered', 'survey');
$strresponses = get_string('responses', 'survey');
echo $OUTPUT->heading($question->text, 3, 'questiontext');
@@ -541,13 +541,14 @@ function survey_print_multi($question) {
}
echo "<tr class=\"smalltext\"><th scope=\"row\">$strresponses</th>";
+ echo "<th scope=\"col\" class=\"hresponse\">". get_string('notyetanswered', 'survey'). "</th>";
while (list ($key, $val) = each ($options)) {
echo "<th scope=\"col\" class=\"hresponse\">$val</th>\n";
}
- echo "<th>&nbsp;</th></tr>\n";
+ echo "</tr>\n";
if ($oneanswer) {
- echo "<tr><th scope=\"col\" colspan=\"6\">$question->intro</th></tr>\n";
+ echo "<tr><th scope=\"col\" colspan=\"7\">$question->intro</th></tr>\n";
} else {
echo "<tr><th scope=\"col\" colspan=\"7\">$question->intro</th></tr>\n";
}
@@ -563,33 +564,37 @@ function survey_print_multi($question) {
echo "<tr class=\"$rowclass rblock\">";
if ($oneanswer) {
-
echo "<th scope=\"row\" class=\"optioncell\">";
echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
echo $q->text ."</th>\n";
+
+ $default = get_accesshide($strdefault);
+ echo "<td class=\"whitecell\"><label for=\"q$P$q->id\"><input type=\"radio\" name=\"q$P$q->id\" id=\"q$P" . $q->id . "_D\" value=\"0\" checked=\"checked\" />$default</label></td>";
+
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>";
- }
- $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;
+ }
+ $checklist["q$P$q->id"] = 0;
- } else {
+ } else {
// yu : fix for MDL-7501, possibly need to use user flag as this is quite ugly.
echo "<th scope=\"row\" class=\"optioncell\">";
echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
$qnum++;
echo "<span class=\"preferthat smalltext\">$stripreferthat</span> &nbsp; ";
echo "<span class=\"option\">$q->text</span></th>\n";
+
+ $default = get_accesshide($strdefault);
+ echo '<td class="whitecell"><label for="qP'. $P.$q->id .'"><input type="radio" name="qP'.$P.$q->id. '" id="qP'. $q->id .'" value="0" checked="checked" />'.$default.'</label></td>';
+
+
for ($i=1;$i<=$numoptions;$i++) {
$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>";
}
- $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 rblock\">";
@@ -597,15 +602,18 @@ function survey_print_multi($question) {
echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
echo "<span class=\"foundthat smalltext\">$strifoundthat</span> &nbsp; ";
echo "<span class=\"option\">$q->text</span></th>\n";
+
+ $default = get_accesshide($strdefault);
+ echo '<td class="whitecell"><label for="q'. $q->id .'"><input type="radio" name="q'.$q->id. '" id="q'. $q->id .'" value="0" checked="checked" />'.$default.'</label></td>';
+
for ($i=1;$i<=$numoptions;$i++) {
$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>";
}
- $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;
+
+ $checklist["qP$q->id"] = 0;
+ $checklist["q$q->id"] = 0;
}
echo "</tr>\n";
}
View
35 mod/survey/save.php
@@ -73,8 +73,8 @@
$answers = array();
- foreach ($formdata as $key => $val) {
- if ($key <> "userid" && $key <> "id") {
+ foreach ($formdata as $key => $val) {
+ if ($key <> "userid" && $key <> "id") {
if ( substr($key,0,1) == "q") {
$key = clean_param(substr($key,1), PARAM_ALPHANUM); // keep everything but the 'q', number or Pnumber
}
@@ -92,23 +92,24 @@
$timenow = time();
foreach ($answers as $key => $val) {
+ if ($key != 'sesskey') {
+ $newdata->time = $timenow;
+ $newdata->userid = $USER->id;
+ $newdata->survey = $survey->id;
+ $newdata->question = $key;
+ if (!empty($val[0])) {
+ $newdata->answer1 = $val[0];
+ } else {
+ $newdata->answer1 = "";
+ }
+ if (!empty($val[1])) {
+ $newdata->answer2 = $val[1];
+ } else {
+ $newdata->answer2 = "";
+ }
- $newdata->time = $timenow;
- $newdata->userid = $USER->id;
- $newdata->survey = $survey->id;
- $newdata->question = $key;
- if (!empty($val[0])) {
- $newdata->answer1 = $val[0];
- } else {
- $newdata->answer1 = "";
- }
- if (!empty($val[1])) {
- $newdata->answer2 = $val[1];
- } else {
- $newdata->answer2 = "";
+ $DB->insert_record("survey_answers", $newdata);
}
-
- $DB->insert_record("survey_answers", $newdata);
}
// Print the page and finish up.
View
2  mod/survey/survey.js
@@ -4,7 +4,7 @@ function checkform(e) {
var surveyform = document.getElementById('surveyform');
for (var i=0; i < surveycheck.questions.length; i++) {
var tempquestion = surveycheck.questions[i];
- if (surveyform[tempquestion.question][tempquestion.default].checked) {
+ if (surveyform[tempquestion['question']][tempquestion['default']].checked) {
error = true;
}
}
View
1  mod/survey/view.php
@@ -135,6 +135,7 @@
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />";
echo $OUTPUT->box(format_module_intro('survey', $survey, $cm->id), 'generalbox boxaligncenter bowidthnormal', 'intro');
+ echo '<div>'. get_string('allquestionrequireanswer', 'survey'). '</div>';
// Get all the major questions and their proper order
if (! $questions = $DB->get_records_list("survey_questions", "id", explode(',', $survey->questions))) {
Please sign in to comment.
Something went wrong with that request. Please try again.