Skip to content

Commit

Permalink
MDL-29818: Improve error message when a grade has no answer
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Robert Nicols committed Oct 19, 2011
1 parent 6731a04 commit 5a6084c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion question/type/multichoice/edit_multichoice_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,13 @@ public function validation($data, $files) {
foreach ($answers as $key => $answer) {
//check no of choices
$trimmedanswer = trim($answer['text']);
if (empty($trimmedanswer)) {
$fraction = (float) $data['fraction'][$key];
if (empty($trimmedanswer) && empty($fraction)) {
continue;
}
if (empty($trimmedanswer)) {
$errors['fraction['.$key.']'] = get_string('errgradesetanswerblank', 'qtype_multichoice');
}

$answercount++;

Expand Down
1 change: 1 addition & 0 deletions question/type/multichoice/lang/en/qtype_multichoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$string['correctansweris'] = 'The correct answer is: {$a}.';
$string['correctfeedback'] = 'For any correct response';
$string['editingmultichoice'] = 'Editing a Multiple choice question';
$string['errgradesetanswerblank'] = 'Grade set, but the Answer is blank';
$string['errfractionsaddwrong'] = 'The positive grades you have chosen do not add up to 100%<br />Instead, they add up to {$a}%';
$string['errfractionsnomax'] = 'One of the choices should be 100%, so that it is<br />possible to get a full grade for this question.';
$string['feedback'] = 'Feedback';
Expand Down

0 comments on commit 5a6084c

Please sign in to comment.