From c9e4ba362db4524eeaa9fb0f50498fa96275add3 Mon Sep 17 00:00:00 2001 From: pichetp <pichetp> Date: Thu, 29 Mar 2007 09:09:16 +0000 Subject: [PATCH] integrate the new $question->export_process parameter for export --- question/format/xml/format.php | 6 +++--- question/type/calculated/questiontype.php | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/question/format/xml/format.php b/question/format/xml/format.php index c4b4e6cda1..07b84c69be 100755 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -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"; diff --git a/question/type/calculated/questiontype.php b/question/type/calculated/questiontype.php index 94218aa789..d914b62a21 100644 --- a/question/type/calculated/questiontype.php +++ b/question/type/calculated/questiontype.php @@ -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)) { -- 2.39.5