MDL-40714 pass through simulated data to sub questions
authorJamie Pratt <me@jamiep.org>
Wed, 17 Jul 2013 11:23:06 +0000 (18:23 +0700)
committerDan Poltawski <dan@moodle.com>
Tue, 23 Jul 2013 07:29:28 +0000 (15:29 +0800)
in multi-answer question type

question/type/multianswer/question.php

index 43c2ca7..3be216e 100644 (file)
@@ -140,6 +140,17 @@ class qtype_multianswer_question extends question_graded_automatically_with_coun
         return $right;
     }
 
+    public function prepare_simulated_post_data($simulatedresponse) {
+        $postdata = array();
+        foreach ($this->subquestions as $i => $subq) {
+            $substep = $this->get_substep(null, $i);
+            foreach ($subq->prepare_simulated_post_data($simulatedresponse[$i]) as $name => $value) {
+                $postdata[$substep->add_prefix($name)] = $value;
+            }
+        }
+        return $postdata;
+    }
+
     public function is_complete_response(array $response) {
         foreach ($this->subquestions as $i => $subq) {
             $substep = $this->get_substep(null, $i);