diff --git a/lang/en_utf8/qtype_multichoice.php b/lang/en_utf8/qtype_multichoice.php
index 7b04cd2a1b4..ff25aea1ec3 100644
--- a/lang/en_utf8/qtype_multichoice.php
+++ b/lang/en_utf8/qtype_multichoice.php
@@ -11,6 +11,8 @@ $string['choices'] = 'Available choices';
$string['clozeaid'] = 'Enter missing word';
$string['correctfeedback'] = 'For any correct answer';
$string['editingmultichoice'] = 'Editing a Multiple Choice question';
+$string['errfractionsaddwrong'] = 'The positive grades you have chosen do not add up to 100%%
Instead, they add up to $a%%';
+$string['errfractionsnomax'] = 'One of the answers should be 100%%, so that it is
possible to get a full grade for this question.';
$string['feedback'] = 'Feedback';
$string['fillouttwochoices'] = 'You must fill out at least two choices. Choices left blank will not be used.';
$string['fractionsaddwrong'] = 'The positive grades you have chosen do not add up to 100%%
Instead, they add up to $a%%
Do you want to go back and fix this question?';
diff --git a/question/type/multichoice/edit_multichoice_form.php b/question/type/multichoice/edit_multichoice_form.php
index b3701cb9fe6..b11790e698f 100644
--- a/question/type/multichoice/edit_multichoice_form.php
+++ b/question/type/multichoice/edit_multichoice_form.php
@@ -78,7 +78,7 @@ class question_edit_multichoice_form extends question_edit_form {
$default_values['shuffleanswers'] = $question->options->shuffleanswers;
$default_values['correctfeedback'] = $question->options->correctfeedback;
$default_values['partiallycorrectfeedback'] = $question->options->partiallycorrectfeedback;
- $default_values['overallincorrectfeedback'] = $question->options->overallincorrectfeedback;
+ $default_values['incorrectfeedback'] = $question->options->incorrectfeedback;
$question = (object)((array)$question + $default_values);
}
parent::set_defaults($question);
@@ -92,12 +92,27 @@ class question_edit_multichoice_form extends question_edit_form {
$errors = array();
$answers = $data['answer'];
$answercount = 0;
- foreach ($answers as $answer){
+
+ $totalfraction = 0;
+ $maxfraction = -1;
+
+ foreach ($answers as $key => $answer){
+ //check no of choices
$trimmedanswer = trim($answer);
if (!empty($trimmedanswer)){
$answercount++;
}
+ //check grades
+ if ($answer != '') {
+ if ($data['fraction'][$key] > 0) {
+ $totalfraction += $data['fraction'][$key];
+ }
+ if ($data['fraction'][$key] > $maxfraction) {
+ $maxfraction = $data['fraction'][$key];
+ }
+ }
}
+
if ($answercount==0){
$errors['answer[0]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
$errors['answer[1]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
@@ -105,6 +120,20 @@ class question_edit_multichoice_form extends question_edit_form {
$errors['answer[1]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
}
+
+ /// Perform sanity checks on fractional grades
+ if ($data['single']) {
+ if ($maxfraction != 1) {
+ $maxfraction = $maxfraction * 100;
+ $errors['fraction[0]'] = get_string('errfractionsnomax', 'qtype_multichoice', $maxfraction);
+ }
+ } else {
+ $totalfraction = round($totalfraction,2);
+ if ($totalfraction != 1) {
+ $totalfraction = $totalfraction * 100;
+ $errors['fraction[0]'] = get_string('errfractionsaddwrong', 'qtype_multichoice', $totalfraction);
+ }
+ }
return $errors;
}
}
diff --git a/question/type/random/edit_random_form.php b/question/type/random/edit_random_form.php
index 39dadd74854..707957bde4e 100644
--- a/question/type/random/edit_random_form.php
+++ b/question/type/random/edit_random_form.php
@@ -41,6 +41,9 @@ class question_edit_random_form extends question_edit_form {
$mform->addElement('advcheckbox', 'questiontext', get_string("recurse", "quiz"), null, null, array(0, 1));
// Standard fields at the end of the form.
+ $mform->addElement('hidden', 'questiontextformat', 0);
+ $mform->setType('questiontextformat', PARAM_INT);
+
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
@@ -55,9 +58,7 @@ class question_edit_random_form extends question_edit_form {
$buttonarray = array();
$buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
- if (!empty($this->question->id)) {
- $buttonarray[] = &$mform->createElement('submit', 'makecopy', get_string('makecopy', 'quiz'));
- }
+
$buttonarray[] = &$mform->createElement('cancel');
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$mform->closeHeaderBefore('buttonar');