MDL-20636 Fix editing of multichoice questions.

This commit is contained in:
Tim Hunt
2011-01-13 18:36:13 +00:00
parent ce5e4fb620
commit 8b9dfc2bf6
3 changed files with 16 additions and 7 deletions
+13 -6
View File
@@ -486,8 +486,8 @@ abstract class question_edit_form extends moodleform {
foreach (array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback') as $feedbackname) {
$draftid = file_get_submitted_draft_itemid($feedbackname);
$question->$feedbackname = array();
$question->$feedbackname['text'] = file_prepare_draft_area(
$feedback = array();
$feedback['text'] = file_prepare_draft_area(
$draftid, // draftid
$this->context->id, // context
'qtype_multichoice', // component
@@ -497,8 +497,10 @@ abstract class question_edit_form extends moodleform {
$question->options->$feedbackname // text
);
$feedbackformat = $feedbackname . 'format';
$question->$feedbackname['format'] = $question->options->$feedbackformat;
$question->$feedbackname['itemid'] = $draftid;
$feedback['format'] = $question->options->$feedbackformat;
$feedback['itemid'] = $draftid;
$question->$feedbackname = $feedback;
}
if ($withshownumcorrect) {
@@ -531,9 +533,14 @@ abstract class question_edit_form extends moodleform {
$question->hint[$key]['itemid'] = $draftitemid;
$question->hint[$key]['format'] = $hint->hintformat;
$key++;
}
// TODO $withclearwrong, $withshownumpartscorrect
if ($withclearwrong) {
$question->hintclearwrong[] = $hint->clearwrong;
}
if ($withshownumpartscorrect) {
$question->hintshownumcorrect[] = $hint->shownumcorrect;
}
}
return $question;
}
@@ -67,7 +67,7 @@ class question_edit_multichoice_form extends question_edit_form {
$question = parent::data_preprocessing($question);
$question = $this->data_preprocessing_answers($question, true);
$question = $this->data_preprocessing_combined_feedback($question, true);
$question = $this->data_preprocessing_hints($question);
$question = $this->data_preprocessing_hints($question, true, true);
if (!empty($question->options)) {
$question->single = $question->options->single;
@@ -140,6 +140,8 @@ class qtype_multichoice extends question_type {
$DB->update_record('question_multichoice', $options);
$this->save_hints($question, true);
/// Perform sanity checks on fractional grades
if ($options->single) {
if ($maxfraction != 1) {