}
//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";
$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)) {