Permalink
Browse files

MDL-36570 Grouped question type answer fields now display errors

  • Loading branch information...
1 parent c3f21ec commit 11a66e2c5a26029454a0cb6b1393ae35b6c17656 Colin Chambers committed Apr 4, 2013
@@ -243,7 +243,7 @@ public function validation($data, $files) {
}
if (empty($mandatorydatasets)) {
foreach ($answers as $key => $answer) {
- $errors['answer['.$key.']'] =
+ $errors['answeroptions['.$key.']'] =
get_string('atleastonewildcard', 'qtype_calculated');
}
}
@@ -254,7 +254,7 @@ public function validation($data, $files) {
if (trim($answer)) {
if ($data['correctanswerformat'][$key] == 2 &&
$data['correctanswerlength'][$key] == '0') {
- $errors['correctanswerlength['.$key.']'] =
+ $errors['answerdisplay['.$key.']'] =
get_string('zerosignificantfiguresnotallowed', 'qtype_calculated');
}
}
@@ -261,7 +261,7 @@ public function validation($data, $files) {
}
if (count($mandatorydatasets) == 0) {
foreach ($answers as $key => $answer) {
- $errors['answer['.$key.']'] =
+ $errors['answeroptions['.$key.']'] =
get_string('atleastonewildcard', 'qtype_calculated');
}
}
@@ -274,7 +274,7 @@ public function validation($data, $files) {
continue;
}
if (empty($trimmedanswer)) {
- $errors['fraction['.$key.']'] = get_string('errgradesetanswerblank', 'qtype_multichoice');
+ $errors['answeroptions['.$key.']'] = get_string('errgradesetanswerblank', 'qtype_multichoice');
}
if ($trimmedanswer != '' || $answercount == 0) {
// Verifying for errors in {=...} in answer text.
@@ -291,10 +291,10 @@ public function validation($data, $files) {
$qanswerremaining = $qanswersplits[1];
if (!empty($regs1[1]) && $formulaerrors =
qtype_calculated_find_formula_errors($regs1[1])) {
- if (!isset($errors['answer['.$key.']'])) {
- $errors['answer['.$key.']'] = $formulaerrors.':'.$regs1[1];
+ if (!isset($errors['answeroptions['.$key.']'])) {
+ $errors['answeroptions['.$key.']'] = $formulaerrors.':'.$regs1[1];
} else {
- $errors['answer['.$key.']'] .= '<br/>'.$formulaerrors.':'.$regs1[1];
+ $errors['answeroptions['.$key.']'] .= '<br/>'.$formulaerrors.':'.$regs1[1];
}
}
}
@@ -321,23 +321,23 @@ public function validation($data, $files) {
}
}
if ($answercount == 0) {
- $errors['answer[0]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
- $errors['answer[1]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
+ $errors['answeroptions[0]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
+ $errors['answeroptions[1]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
} else if ($answercount == 1) {
- $errors['answer[1]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
+ $errors['answeroptions[1]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
}
// Perform sanity checks on fractional grades.
if ($data['single']== 1 ) {
if ($maxfraction != 1) {
- $errors['fraction[0]'] = get_string('errfractionsnomax', 'qtype_multichoice',
+ $errors['answeroptions[0]'] = get_string('errfractionsnomax', 'qtype_multichoice',
$maxfraction * 100);
}
} else {
$totalfraction = round($totalfraction, 2);
if ($totalfraction != 1) {
$totalfraction = $totalfraction * 100;
- $errors['fraction[0]'] =
+ $errors['answeroptions[0]'] =
get_string('errfractionsaddwrong', 'qtype_multichoice', $totalfraction);
}
}
@@ -288,27 +288,27 @@ protected function validate_answers($data, $errors) {
if ($trimmedanswer != '') {
$answercount++;
if (!$this->is_valid_answer($trimmedanswer, $data)) {
- $errors['answer[' . $key . ']'] = $this->valid_answer_message($trimmedanswer);
+ $errors['answeroptions[' . $key . ']'] = $this->valid_answer_message($trimmedanswer);
}
if ($data['fraction'][$key] == 1) {
$maxgrade = true;
}
if ($answer !== '*' && !is_numeric($data['tolerance'][$key])) {
- $errors['tolerance['.$key.']'] =
+ $errors['answeroptions['.$key.']'] =
get_string('xmustbenumeric', 'qtype_numerical',
get_string('acceptederror', 'qtype_numerical'));
}
} else if ($data['fraction'][$key] != 0 ||
!html_is_blank($data['feedback'][$key]['text'])) {
- $errors['answer[' . $key . ']'] = $this->valid_answer_message($trimmedanswer);
+ $errors['answeroptions[' . $key . ']'] = $this->valid_answer_message($trimmedanswer);
$answercount++;
}
}
if ($answercount == 0) {
- $errors['answer[0]'] = get_string('notenoughanswers', 'qtype_numerical');
+ $errors['answeroptions[0]'] = get_string('notenoughanswers', 'qtype_numerical');
}
if ($maxgrade == false) {
- $errors['fraction[0]'] = get_string('fractionsnomax', 'question');
+ $errors['answeroptions[0]'] = get_string('fractionsnomax', 'question');
}
return $errors;
@@ -80,15 +80,15 @@ public function validation($data, $files) {
}
} else if ($data['fraction'][$key] != 0 ||
!html_is_blank($data['feedback'][$key]['text'])) {
- $errors["answer[$key]"] = get_string('answermustbegiven', 'qtype_shortanswer');
+ $errors["answeroptions[$key]"] = get_string('answermustbegiven', 'qtype_shortanswer');
$answercount++;
}
}
if ($answercount==0) {
- $errors['answer[0]'] = get_string('notenoughanswers', 'qtype_shortanswer', 1);
+ $errors['answeroptions[0]'] = get_string('notenoughanswers', 'qtype_shortanswer', 1);
}
if ($maxgrade == false) {
- $errors['fraction[0]'] = get_string('fractionsnomax', 'question');
+ $errors['answeroptions[0]'] = get_string('fractionsnomax', 'question');
}
return $errors;
}

0 comments on commit 11a66e2

Please sign in to comment.