From 106777513117c4d8ca5f38a569e9db5be15ab3ab Mon Sep 17 00:00:00 2001 From: Oleg Sychev Date: Mon, 14 Nov 2011 03:44:49 +0300 Subject: [PATCH] MDL-29095: initialise_question_instance should use extra_question_fields Shortanswer question type converted to use extra question fields. Signed-off-by: Oleg Sychev --- question/type/questiontypebase.php | 10 ++++++++++ question/type/shortanswer/edit_shortanswer_form.php | 4 ---- question/type/shortanswer/questiontype.php | 1 - 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/question/type/questiontypebase.php b/question/type/questiontypebase.php index d3090da887f..5e76deb5fdb 100644 --- a/question/type/questiontypebase.php +++ b/question/type/questiontypebase.php @@ -702,6 +702,16 @@ class question_type { $question->createdby = $questiondata->createdby; $question->modifiedby = $questiondata->modifiedby; + //Fill extra question fields values + $extraquestionfields = $this->extra_question_fields(); + if (is_array($extraquestionfields)) { + //omit table name + array_shift($extraquestionfields); + foreach($extraquestionfields as $field) { + $question->$field = $questiondata->options->$field; + } + } + $this->initialise_question_hints($question, $questiondata); } diff --git a/question/type/shortanswer/edit_shortanswer_form.php b/question/type/shortanswer/edit_shortanswer_form.php index 49fabf2abae..2c01634bc47 100644 --- a/question/type/shortanswer/edit_shortanswer_form.php +++ b/question/type/shortanswer/edit_shortanswer_form.php @@ -59,10 +59,6 @@ class qtype_shortanswer_edit_form extends question_edit_form { $question = $this->data_preprocessing_answers($question); $question = $this->data_preprocessing_hints($question); - if (!empty($question->options)) { - $question->usecase = $question->options->usecase; - } - return $question; } diff --git a/question/type/shortanswer/questiontype.php b/question/type/shortanswer/questiontype.php index b68413b1ab1..b43e3ee59c6 100644 --- a/question/type/shortanswer/questiontype.php +++ b/question/type/shortanswer/questiontype.php @@ -124,7 +124,6 @@ class qtype_shortanswer extends question_type { protected function initialise_question_instance(question_definition $question, $questiondata) { parent::initialise_question_instance($question, $questiondata); - $question->usecase = $questiondata->options->usecase; $this->initialise_question_answers($question, $questiondata); }