From a334095242265b6408f7f1ad61a77dc8ad0b0cff 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 ++++++++++ .../type/shortanswer/edit_shortanswer_form.php | 4 ---- question/type/shortanswer/questiontype.php | 3 +-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/question/type/questiontypebase.php b/question/type/questiontypebase.php index 4358552..f78c8f8 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 49fabf2..2c01634 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 b68413b..015bdf6 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); } -- 1.7.7.1.msysgit.0