mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-36570' of git://github.com/colchambers/moodle
This commit is contained in:
commit
c001c51a26
4 changed files with 22 additions and 23 deletions
|
@ -243,7 +243,7 @@ class qtype_calculated_edit_form extends qtype_numerical_edit_form {
|
||||||
}
|
}
|
||||||
if (empty($mandatorydatasets)) {
|
if (empty($mandatorydatasets)) {
|
||||||
foreach ($answers as $key => $answer) {
|
foreach ($answers as $key => $answer) {
|
||||||
$errors['answer['.$key.']'] =
|
$errors['answeroptions['.$key.']'] =
|
||||||
get_string('atleastonewildcard', 'qtype_calculated');
|
get_string('atleastonewildcard', 'qtype_calculated');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ class qtype_calculated_edit_form extends qtype_numerical_edit_form {
|
||||||
if (trim($answer)) {
|
if (trim($answer)) {
|
||||||
if ($data['correctanswerformat'][$key] == 2 &&
|
if ($data['correctanswerformat'][$key] == 2 &&
|
||||||
$data['correctanswerlength'][$key] == '0') {
|
$data['correctanswerlength'][$key] == '0') {
|
||||||
$errors['correctanswerlength['.$key.']'] =
|
$errors['answerdisplay['.$key.']'] =
|
||||||
get_string('zerosignificantfiguresnotallowed', 'qtype_calculated');
|
get_string('zerosignificantfiguresnotallowed', 'qtype_calculated');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,9 +82,8 @@ class qtype_calculatedmulti_edit_form extends question_edit_form {
|
||||||
|
|
||||||
$mform->setType('answer', PARAM_NOTAGS);
|
$mform->setType('answer', PARAM_NOTAGS);
|
||||||
|
|
||||||
$addrepeated = array();
|
$repeated[] = $mform->createElement('hidden', 'tolerance');
|
||||||
$addrepeated[] = $mform->createElement('hidden', 'tolerance');
|
$repeated[] = $mform->createElement('hidden', 'tolerancetype', 1);
|
||||||
$addrepeated[] = $mform->createElement('hidden', 'tolerancetype', 1);
|
|
||||||
$repeatedoptions['tolerance']['type'] = PARAM_FLOAT;
|
$repeatedoptions['tolerance']['type'] = PARAM_FLOAT;
|
||||||
$repeatedoptions['tolerance']['default'] = 0.01;
|
$repeatedoptions['tolerance']['default'] = 0.01;
|
||||||
|
|
||||||
|
@ -262,7 +261,7 @@ class qtype_calculatedmulti_edit_form extends question_edit_form {
|
||||||
}
|
}
|
||||||
if (count($mandatorydatasets) == 0) {
|
if (count($mandatorydatasets) == 0) {
|
||||||
foreach ($answers as $key => $answer) {
|
foreach ($answers as $key => $answer) {
|
||||||
$errors['answer['.$key.']'] =
|
$errors['answeroptions['.$key.']'] =
|
||||||
get_string('atleastonewildcard', 'qtype_calculated');
|
get_string('atleastonewildcard', 'qtype_calculated');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +274,7 @@ class qtype_calculatedmulti_edit_form extends question_edit_form {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (empty($trimmedanswer)) {
|
if (empty($trimmedanswer)) {
|
||||||
$errors['fraction['.$key.']'] = get_string('errgradesetanswerblank', 'qtype_multichoice');
|
$errors['answeroptions['.$key.']'] = get_string('errgradesetanswerblank', 'qtype_multichoice');
|
||||||
}
|
}
|
||||||
if ($trimmedanswer != '' || $answercount == 0) {
|
if ($trimmedanswer != '' || $answercount == 0) {
|
||||||
// Verifying for errors in {=...} in answer text.
|
// Verifying for errors in {=...} in answer text.
|
||||||
|
@ -292,10 +291,10 @@ class qtype_calculatedmulti_edit_form extends question_edit_form {
|
||||||
$qanswerremaining = $qanswersplits[1];
|
$qanswerremaining = $qanswersplits[1];
|
||||||
if (!empty($regs1[1]) && $formulaerrors =
|
if (!empty($regs1[1]) && $formulaerrors =
|
||||||
qtype_calculated_find_formula_errors($regs1[1])) {
|
qtype_calculated_find_formula_errors($regs1[1])) {
|
||||||
if (!isset($errors['answer['.$key.']'])) {
|
if (!isset($errors['answeroptions['.$key.']'])) {
|
||||||
$errors['answer['.$key.']'] = $formulaerrors.':'.$regs1[1];
|
$errors['answeroptions['.$key.']'] = $formulaerrors.':'.$regs1[1];
|
||||||
} else {
|
} 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) {
|
if ($answercount == 0) {
|
||||||
$errors['answer[0]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
|
$errors['answeroptions[0]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
|
||||||
$errors['answer[1]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
|
$errors['answeroptions[1]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
|
||||||
} else if ($answercount == 1) {
|
} 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.
|
// Perform sanity checks on fractional grades.
|
||||||
if ($data['single']== 1 ) {
|
if ($data['single']== 1 ) {
|
||||||
if ($maxfraction != 1) {
|
if ($maxfraction != 1) {
|
||||||
$errors['fraction[0]'] = get_string('errfractionsnomax', 'qtype_multichoice',
|
$errors['answeroptions[0]'] = get_string('errfractionsnomax', 'qtype_multichoice',
|
||||||
$maxfraction * 100);
|
$maxfraction * 100);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$totalfraction = round($totalfraction, 2);
|
$totalfraction = round($totalfraction, 2);
|
||||||
if ($totalfraction != 1) {
|
if ($totalfraction != 1) {
|
||||||
$totalfraction = $totalfraction * 100;
|
$totalfraction = $totalfraction * 100;
|
||||||
$errors['fraction[0]'] =
|
$errors['answeroptions[0]'] =
|
||||||
get_string('errfractionsaddwrong', 'qtype_multichoice', $totalfraction);
|
get_string('errfractionsaddwrong', 'qtype_multichoice', $totalfraction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,27 +288,27 @@ class qtype_numerical_edit_form extends question_edit_form {
|
||||||
if ($trimmedanswer != '') {
|
if ($trimmedanswer != '') {
|
||||||
$answercount++;
|
$answercount++;
|
||||||
if (!$this->is_valid_answer($trimmedanswer, $data)) {
|
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) {
|
if ($data['fraction'][$key] == 1) {
|
||||||
$maxgrade = true;
|
$maxgrade = true;
|
||||||
}
|
}
|
||||||
if ($answer !== '*' && !is_numeric($data['tolerance'][$key])) {
|
if ($answer !== '*' && !is_numeric($data['tolerance'][$key])) {
|
||||||
$errors['tolerance['.$key.']'] =
|
$errors['answeroptions['.$key.']'] =
|
||||||
get_string('xmustbenumeric', 'qtype_numerical',
|
get_string('xmustbenumeric', 'qtype_numerical',
|
||||||
get_string('acceptederror', 'qtype_numerical'));
|
get_string('acceptederror', 'qtype_numerical'));
|
||||||
}
|
}
|
||||||
} else if ($data['fraction'][$key] != 0 ||
|
} else if ($data['fraction'][$key] != 0 ||
|
||||||
!html_is_blank($data['feedback'][$key]['text'])) {
|
!html_is_blank($data['feedback'][$key]['text'])) {
|
||||||
$errors['answer[' . $key . ']'] = $this->valid_answer_message($trimmedanswer);
|
$errors['answeroptions[' . $key . ']'] = $this->valid_answer_message($trimmedanswer);
|
||||||
$answercount++;
|
$answercount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($answercount == 0) {
|
if ($answercount == 0) {
|
||||||
$errors['answer[0]'] = get_string('notenoughanswers', 'qtype_numerical');
|
$errors['answeroptions[0]'] = get_string('notenoughanswers', 'qtype_numerical');
|
||||||
}
|
}
|
||||||
if ($maxgrade == false) {
|
if ($maxgrade == false) {
|
||||||
$errors['fraction[0]'] = get_string('fractionsnomax', 'question');
|
$errors['answeroptions[0]'] = get_string('fractionsnomax', 'question');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $errors;
|
return $errors;
|
||||||
|
|
|
@ -80,15 +80,15 @@ class qtype_shortanswer_edit_form extends question_edit_form {
|
||||||
}
|
}
|
||||||
} else if ($data['fraction'][$key] != 0 ||
|
} else if ($data['fraction'][$key] != 0 ||
|
||||||
!html_is_blank($data['feedback'][$key]['text'])) {
|
!html_is_blank($data['feedback'][$key]['text'])) {
|
||||||
$errors["answer[$key]"] = get_string('answermustbegiven', 'qtype_shortanswer');
|
$errors["answeroptions[$key]"] = get_string('answermustbegiven', 'qtype_shortanswer');
|
||||||
$answercount++;
|
$answercount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($answercount==0) {
|
if ($answercount==0) {
|
||||||
$errors['answer[0]'] = get_string('notenoughanswers', 'qtype_shortanswer', 1);
|
$errors['answeroptions[0]'] = get_string('notenoughanswers', 'qtype_shortanswer', 1);
|
||||||
}
|
}
|
||||||
if ($maxgrade == false) {
|
if ($maxgrade == false) {
|
||||||
$errors['fraction[0]'] = get_string('fractionsnomax', 'question');
|
$errors['answeroptions[0]'] = get_string('fractionsnomax', 'question');
|
||||||
}
|
}
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue