From: pichetp Date: Fri, 9 Mar 2007 05:28:40 +0000 (+0000) Subject: modifs MDL-5650 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=46551466d833837b0c630515c37e7d561958c049;p=moodle.git modifs MDL-5650 --- diff --git a/question/format/webct/format.php b/question/format/webct/format.php index 508d9de4eb..104f765b73 100644 --- a/question/format/webct/format.php +++ b/question/format/webct/format.php @@ -246,7 +246,6 @@ class qformat_webct extends qformat_default { } function readquestions ($lines) { - global $QTYPES; $qtypecalculated = new qformat_webct_modified_calculated_qtype(); $webctnumberregex = @@ -263,11 +262,12 @@ class qformat_webct extends qformat_default { $nQuestionStartLine = 0; $bIsHTMLText = FALSE; $lines[] = ":EOF:"; // for an easiest processing of the last line - // $question = $this->defaultquestion(); + // $question = $this->defaultquestion(); + foreach ($lines as $line) { $nLineCounter++; - + $line = iconv("Windows-1252","UTF-8",$line); // Processing multiples lines strings if (isset($questiontext) and is_string($questiontext)) { @@ -392,7 +392,7 @@ class qformat_webct extends qformat_default { case CALCULATED: foreach ($question->answers as $answer) { - if ($formulaerror = qtype_calculated_find_formula_errors($answer->answer)) { + if ($formulaerror =qtype_calculated_find_formula_errors($answer->answer)) { $warnings[] = "'$question->name': ". $formulaerror; $QuestionOK = FALSE; } @@ -445,8 +445,10 @@ class qformat_webct extends qformat_default { if (eregi("^:TYPE:C",$line)) { // Calculated Question - $question = $this->defaultquestion(); - $question->qtype = CALCULATED; + $warnings[] = get_string("calculatedquestion", "quiz", $nLineCounter); + unset($question); + $ignore_rest_of_question = TRUE; // Question Type not handled by Moodle + /* $question->qtype = CALCULATED; $question->answers = array(); // No problem as they go as :FORMULA: from webct $question->units = array(); $question->datasets = array(); @@ -456,7 +458,7 @@ class qformat_webct extends qformat_default { $question->fraction = array('1.0'); $currentchoice = -1; - $ignore_rest_of_question = FALSE; + $ignore_rest_of_question = FALSE;*/ continue; } @@ -471,6 +473,7 @@ class qformat_webct extends qformat_default { if (eregi("^:TYPE:P",$line)) { // Paragraph Question $warnings[] = get_string("paragraphquestion", "quiz", $nLineCounter); + unset($question); $ignore_rest_of_question = TRUE; // Question Type not handled by Moodle continue; } @@ -478,6 +481,7 @@ class qformat_webct extends qformat_default { if (eregi("^:TYPE:",$line)) { // Unknow Question $warnings[] = get_string("unknowntype", "quiz", $nLineCounter); + unset($question); $ignore_rest_of_question = TRUE; // Question Type not handled by Moodle continue; } @@ -508,8 +512,8 @@ class qformat_webct extends qformat_default { // if question isn't defined yet there is nothing to do here (avoid notices) if (!isset($question)) { continue; - } - if ('calculated' == $question->qtype && ereg( + } + if (isset($question->qtype ) && CALCULATED == $question->qtype && ereg( "^:([[:lower:]].*|::.*)-(MIN|MAX|DEC|VAL([0-9]+))::?:?($webctnumberregex)", $line, $webct_options)) { $datasetname = ereg_replace('^::', '', $webct_options[1]); $datasetvalue = qformat_webct_convert_formula($webct_options[4]); @@ -592,20 +596,20 @@ class qformat_webct extends qformat_default { continue; } - if (CALCULATED == $question->qtype && eregi('^:ANS-DEC:([1-9][0-9]*)', $line, $webct_options)) { + if (isset($question->qtype ) && CALCULATED == $question->qtype && eregi('^:ANS-DEC:([1-9][0-9]*)', $line, $webct_options)) { // We can but hope that this always appear before the ANSTYPE property $question->answers[$currentchoice]->correctanswerlength = $webct_options[1]; continue; } - if (CALCULATED == $question->qtype && eregi("^:TOL:($webctnumberregex)", $line, $webct_options)) { + if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi("^:TOL:($webctnumberregex)", $line, $webct_options)) { // We can but hope that this always appear before the TOL property $question->answers[$currentchoice]->tolerance = qformat_webct_convert_formula($webct_options[1]); continue; } - if (CALCULATED == $question->qtype && eregi('^:TOLTYPE:percent', $line)) { + if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi('^:TOLTYPE:percent', $line)) { // Percentage case is handled as relative in Moodle: $question->answers[$currentchoice]->tolerance /= 100; $question->answers[$currentchoice]->tolerancetype = 1; // Relative @@ -640,7 +644,7 @@ class qformat_webct extends qformat_default { continue; } - if (CALCULATED == $question->qtype && eregi('^:ANSTYPE:dec', $line)) { + if (isset($question->qtype )&& CALCULATED == $question->qtype && eregi('^:ANSTYPE:dec', $line)) { // Houston - we have a problem // Moodle does not support this - we try something defensively by // setting the correct answer length to 5, it shoud be enough for