MDL-29095: initialise_question_instance should use extra_question_fields
authorOleg Sychev <oasychev@gmail.com>
Mon, 14 Nov 2011 00:44:49 +0000 (03:44 +0300)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Tue, 15 Nov 2011 11:10:14 +0000 (11:10 +0000)
Shortanswer question type converted to use extra question fields.

Signed-off-by: Oleg Sychev <oasychev@gmail.com>
question/type/questiontypebase.php
question/type/shortanswer/edit_shortanswer_form.php
question/type/shortanswer/questiontype.php

index d3090da..5e76deb 100644 (file)
@@ -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);
     }
 
index 49fabf2..2c01634 100644 (file)
@@ -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;
     }
 
index b68413b..b43e3ee 100644 (file)
@@ -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);
     }