]> git.mjollnir.org Git - moodle.git/commitdiff
integrate the new $question->export_process parameter for export
authorpichetp <pichetp>
Thu, 29 Mar 2007 09:09:16 +0000 (09:09 +0000)
committerpichetp <pichetp>
Thu, 29 Mar 2007 09:09:16 +0000 (09:09 +0000)
question/format/xml/format.php
question/type/calculated/questiontype.php

index c4b4e6cda11284fd04605d330d1a129bc1e33a5e..07b84c69bea98e0077ff84913c2ece8aa944bdc7 100755 (executable)
@@ -991,12 +991,12 @@ class qformat_xml extends qformat_default {
              } 
         //echo "<pre> question calc";print_r($question);echo "</pre>"; 
         //First, we a new function to get all the   data itmes in the database
-            $question_datasetdefs =$QTYPES['calculated']->get_datasets_for_export ($question->id);
+         //   $question_datasetdefs =$QTYPES['calculated']->get_datasets_for_export ($question);
         //    echo "<pre> question defs";print_r($question_datasetdefs);echo "</pre>";      
         //If there are question_datasets
-            if (count($question_datasetdefs)) {// there should be
+            if( isset($question->options->datasets)&&count($question->options->datasets)){// there should be
                 $expout .= "<dataset_definitions>\n";
-                foreach ($question_datasetdefs as $def) {
+                foreach ($question->options->datasets as $def) {
                     $expout .= "<dataset_definition>\n";
                     $expout .= "    <status>".$this->writetext($def->status)."</status>\n";
                     $expout .= "    <name>".$this->writetext($def->name)."</name>\n";
index 94218aa789128944988ceaf862a4cc31dbc372d2..d914b62a21a9fe1a47b031231df73a0ca92478d6 100644 (file)
@@ -47,18 +47,21 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
 
         $virtualqtype = $this->get_virtual_qtype();
         $virtualqtype->get_numerical_units($question);
-
+        
+        if( isset($question->export_process)&&$question->export_process){
+            $question->options->datasets = $this->get_datasets_for_export($question);
+        }   
         return true;
     }
     
-    function get_datasets_for_export($questionid){
+    function get_datasets_for_export(&$question){
         $datasetdefs = array();
-        if (!empty($questionid)) {
+        if (!empty($question->id)) {
             global $CFG;
             $sql = "SELECT i.*
                     FROM {$CFG->prefix}question_datasets d,
                          {$CFG->prefix}question_dataset_definitions i
-                    WHERE d.question = '$questionid'
+                    WHERE d.question = '$question->id'
                     AND   d.datasetdefinition = i.id
                    ";
             if ($records = get_records_sql($sql)) {