mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-36570' of git://github.com/colchambers/moodle
This commit is contained in:
commit
c001c51a26
@ -243,7 +243,7 @@ class qtype_calculated_edit_form extends qtype_numerical_edit_form {
|
||||
}
|
||||
if (empty($mandatorydatasets)) {
|
||||
foreach ($answers as $key => $answer) {
|
||||
$errors['answer['.$key.']'] =
|
||||
$errors['answeroptions['.$key.']'] =
|
||||
get_string('atleastonewildcard', 'qtype_calculated');
|
||||
}
|
||||
}
|
||||
@ -254,7 +254,7 @@ class qtype_calculated_edit_form extends qtype_numerical_edit_form {
|
||||
if (trim($answer)) {
|
||||
if ($data['correctanswerformat'][$key] == 2 &&
|
||||
$data['correctanswerlength'][$key] == '0') {
|
||||
$errors['correctanswerlength['.$key.']'] =
|
||||
$errors['answerdisplay['.$key.']'] =
|
||||
get_string('zerosignificantfiguresnotallowed', 'qtype_calculated');
|
||||
}
|
||||
}
|
||||
|
@ -82,9 +82,8 @@ class qtype_calculatedmulti_edit_form extends question_edit_form {
|
||||
|
||||
$mform->setType('answer', PARAM_NOTAGS);
|
||||
|
||||
$addrepeated = array();
|
||||
$addrepeated[] = $mform->createElement('hidden', 'tolerance');
|
||||
$addrepeated[] = $mform->createElement('hidden', 'tolerancetype', 1);
|
||||
$repeated[] = $mform->createElement('hidden', 'tolerance');
|
||||
$repeated[] = $mform->createElement('hidden', 'tolerancetype', 1);
|
||||
$repeatedoptions['tolerance']['type'] = PARAM_FLOAT;
|
||||
$repeatedoptions['tolerance']['default'] = 0.01;
|
||||
|
||||
@ -262,7 +261,7 @@ class qtype_calculatedmulti_edit_form extends question_edit_form {
|
||||
}
|
||||
if (count($mandatorydatasets) == 0) {
|
||||
foreach ($answers as $key => $answer) {
|
||||
$errors['answer['.$key.']'] =
|
||||
$errors['answeroptions['.$key.']'] =
|
||||
get_string('atleastonewildcard', 'qtype_calculated');
|
||||
}
|
||||
}
|
||||
@ -275,7 +274,7 @@ class qtype_calculatedmulti_edit_form extends question_edit_form {
|
||||
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.
|
||||
@ -292,10 +291,10 @@ class qtype_calculatedmulti_edit_form extends question_edit_form {
|
||||
$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];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -322,23 +321,23 @@ class qtype_calculatedmulti_edit_form extends question_edit_form {
|
||||
}
|
||||
}
|
||||
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 @@ class qtype_numerical_edit_form extends question_edit_form {
|
||||
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 @@ class qtype_shortanswer_edit_form extends question_edit_form {
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user