From 9c1c6c7f75731ab70f95d44f9e3f6d03f2978303 Mon Sep 17 00:00:00 2001 From: pichetp Date: Tue, 2 Jun 2009 17:12:27 +0000 Subject: [PATCH] MDL-17366 allow calculatedsimple question type XML import and export --- question/format/xml/format.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/question/format/xml/format.php b/question/format/xml/format.php index 787e8af8f2..3309797857 100755 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -561,6 +561,10 @@ class qformat_xml extends qformat_default { elseif ($question_type=='calculated') { $qo = $this->import_calculated( $question ); } + elseif ($question_type=='calculatedsimple') { + $qo = $this->import_calculated( $question ); + $qo->qtype = CALCULATEDSIMPLE ; + } elseif ($question_type=='category') { $qo = $this->import_category( $question ); } @@ -628,6 +632,9 @@ class qformat_xml extends qformat_default { case CALCULATED: $name = 'calculated'; break; + case CALCULATEDSIMPLE: + $name = 'calculatedsimple'; + break; default: $name = false; } @@ -940,6 +947,7 @@ class qformat_xml extends qformat_default { } break; case CALCULATED: + case CALCULATEDSIMPLE: foreach ($question->options->answers as $answer) { $tolerance = $answer->tolerance; $tolerancetype = $answer->tolerancetype; @@ -967,18 +975,20 @@ class qformat_xml extends qformat_default { } $expout .= "\n"; } - //echo "
 question calc";print_r($question);echo "
"; - //First, we a new function to get all the data itmes in the database - // $question_datasetdefs =$QTYPES['calculated']->get_datasets_for_export ($question); - // echo "
 question defs";print_r($question_datasetdefs);echo "
"; - //If there are question_datasets + //The tag $question->export_process has been set so we get all the data items in the database + // from the function $QTYPES['calculated']->get_question_options(&$question); + // calculatedsimple defaults to calculated if( isset($question->options->datasets)&&count($question->options->datasets)){// there should be $expout .= "\n"; foreach ($question->options->datasets as $def) { $expout .= "\n"; $expout .= " ".$this->writetext($def->status)."\n"; $expout .= " ".$this->writetext($def->name)."\n"; - $expout .= " calculated\n"; + if ( $question->qtype == CALCULATED){ + $expout .= " calculated\n"; + }else { + $expout .= " calculatedsimple\n"; + } $expout .= " ".$this->writetext($def->distribution)."\n"; $expout .= " ".$this->writetext($def->minimum)."\n"; $expout .= " ".$this->writetext($def->maximum)."\n"; -- 2.39.5