}
function readquestions ($lines) {
- global $QTYPES;
$qtypecalculated = new qformat_webct_modified_calculated_qtype();
$webctnumberregex =
$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)) {
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;
}
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();
$question->fraction = array('1.0');
$currentchoice = -1;
- $ignore_rest_of_question = FALSE;
+ $ignore_rest_of_question = FALSE;*/
continue;
}
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;
}
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;
}
// 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]);
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
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