Brought into line with changed object layouts after Gustav's update.

Doesn't work for cloze questions at the moment due to vanished function
in quiz_embedded_cloze_qtype
This commit is contained in:
thepurpleblob 2005-05-09 15:28:34 +00:00
parent adc7ade8c6
commit 7ea81728c3

View file

@ -270,7 +270,7 @@ function handle_questions_media(&$questions, $path, $courseid) {
if ($result !== true) { if ($result !== true) {
notify(implode("<br />", $result)); notify(implode("<br />", $result));
} }
$manifestquestions = $this->objects_to_array($questions); $manifestquestions = $this->objects_to_array($questions);
$manifestid = str_replace(array(':', '/'), array('-','_'), "question_category_{$this->category->id}---{$CFG->wwwroot}"); $manifestid = str_replace(array(':', '/'), array('-','_'), "question_category_{$this->category->id}---{$CFG->wwwroot}");
$smarty->assign('externalfiles', 1); $smarty->assign('externalfiles', 1);
@ -279,6 +279,7 @@ function handle_questions_media(&$questions, $path, $courseid) {
$smarty->assign('quizinfo', "All questions in category {$this->category->id}"); $smarty->assign('quizinfo', "All questions in category {$this->category->id}");
$smarty->assign('questions', $manifestquestions); $smarty->assign('questions', $manifestquestions);
$smarty->assign('lang', $this->lang); $smarty->assign('lang', $this->lang);
$smarty->error_reporting = 99;
$expout = $smarty->fetch('imsmanifest.tpl'); $expout = $smarty->fetch('imsmanifest.tpl');
$filepath = $path.'/imsmanifest.xml'; $filepath = $path.'/imsmanifest.xml';
if (!$fh=fopen($filepath,"w")) { if (!$fh=fopen($filepath,"w")) {
@ -541,9 +542,10 @@ function xml_entitize(&$collection) {
// output depends on question type // output depends on question type
switch($question->qtype) { switch($question->qtype) {
case TRUEFALSE: case TRUEFALSE:
$answers[0] = (array)$question->trueanswer; $qanswers = $question->options->answers;
$answers[0] = (array)$qanswers['true'];
$answers[0]['answer'] = get_string("true", "quiz"); $answers[0]['answer'] = get_string("true", "quiz");
$answers[1] = (array)$question->falseanswer; $answers[1] = (array)$qanswers['false'];
$answers[1]['answer'] = get_string("false", "quiz"); $answers[1]['answer'] = get_string("false", "quiz");
if (!empty($shuffleanswers)) { if (!empty($shuffleanswers)) {
@ -567,7 +569,7 @@ function xml_entitize(&$collection) {
$expout = $smarty->fetch('choice.tpl'); $expout = $smarty->fetch('choice.tpl');
break; break;
case MULTICHOICE: case MULTICHOICE:
$answers = $this->objects_to_array($question->answers); $answers = $this->objects_to_array($question->options->answers);
if (!empty($shuffleanswers)) { if (!empty($shuffleanswers)) {
$answers = $this->shuffle_things($answers); $answers = $this->shuffle_things($answers);
} }
@ -578,11 +580,11 @@ function xml_entitize(&$collection) {
$smarty->assign('responsedeclarationcardinality', $correctcount > 1 ? 'multiple' : 'single'); $smarty->assign('responsedeclarationcardinality', $correctcount > 1 ? 'multiple' : 'single');
$smarty->assign('correctresponses', $correctresponses); $smarty->assign('correctresponses', $correctresponses);
$smarty->assign('answers', $answers); $smarty->assign('answers', $answers);
$smarty->assign('maxChoices', $question->single ? '1' : count($answers)); $smarty->assign('maxChoices', $question->options->single ? '1' : count($answers));
$expout = $smarty->fetch('choiceMultiple.tpl'); $expout = $smarty->fetch('choiceMultiple.tpl');
break; break;
case SHORTANSWER: case SHORTANSWER:
$answers = $this->objects_to_array($question->answers); $answers = $this->objects_to_array($question->options->answers);
if (!empty($shuffleanswers)) { if (!empty($shuffleanswers)) {
$answers = $this->shuffle_things($answers); $answers = $this->shuffle_things($answers);
} }
@ -596,14 +598,15 @@ function xml_entitize(&$collection) {
$expout = $smarty->fetch('textEntry.tpl'); $expout = $smarty->fetch('textEntry.tpl');
break; break;
case NUMERICAL: case NUMERICAL:
$smarty->assign('lowerbound', $question->min); $qanswer = array_pop( $question->options->answers );
$smarty->assign('upperbound', $question->max); $smarty->assign('lowerbound', $qanswer->answer - $question->options->tolerance);
$smarty->assign('answer', $question->answer); $smarty->assign('upperbound', $qanswer->answer + $question->options->tolerance);
$smarty->assign('answer', $qanswer->answer);
$expout = $smarty->fetch('numerical.tpl'); $expout = $smarty->fetch('numerical.tpl');
break; break;
case MATCH: case MATCH:
$this->xml_entitize($question->subquestions); $this->xml_entitize($question->options->subquestions);
$subquestions = $this->objects_to_array($question->subquestions); $subquestions = $this->objects_to_array($question->options->subquestions);
if (!empty($shuffleanswers)) { if (!empty($shuffleanswers)) {
$subquestions = $this->shuffle_things($subquestions); $subquestions = $this->shuffle_things($subquestions);
} }
@ -617,6 +620,7 @@ function xml_entitize(&$collection) {
$expout = $smarty->fetch('extendedText.tpl'); $expout = $smarty->fetch('extendedText.tpl');
break; break;
case MULTIANSWER: case MULTIANSWER:
// echo "<pre>"; print_r( $question ); echo "</pre>"; die();
$answers = $this->get_cloze_answers_array($question); $answers = $this->get_cloze_answers_array($question);
$questions = $this->get_cloze_questions($question, $answers, $allowedtags); $questions = $this->get_cloze_questions($question, $answers, $allowedtags);
@ -679,7 +683,7 @@ function xml_entitize(&$collection) {
} }
} }
$smarty = new Smarty; $smarty = new Smarty;
$smarty->template_dir = "{$CFG->dirroot}/mod/quiz/format/qti/templates"; $smarty->template_dir = "{$CFG->dirroot}/mod/quiz/format/qti2/templates";
$smarty->compile_dir = "$path"; $smarty->compile_dir = "$path";
return $smarty; return $smarty;
} }
@ -805,8 +809,6 @@ function xml_entitize(&$collection) {
switch ($question->qtype) { switch ($question->qtype) {
case DESCRIPTION: case DESCRIPTION:
return 'false'; return 'false';
//case SIMPLEESSAY:
// return 'false';
default: default:
return 'true'; return 'true';
} }
@ -826,8 +828,6 @@ function xml_entitize(&$collection) {
return 'true'; return 'true';
case MULTICHOICE: case MULTICHOICE:
return 'true'; return 'true';
case XMULTICHOICE:
return 'true';
case SHORTANSWER: case SHORTANSWER:
return 'true'; return 'true';
case NUMERICAL: case NUMERICAL:
@ -836,12 +836,8 @@ function xml_entitize(&$collection) {
return 'true'; return 'true';
case DESCRIPTION: case DESCRIPTION:
return 'false'; return 'false';
case SIMPLEESSAY:
return 'false';
case MULTIANSWER: case MULTIANSWER:
return 'true'; return 'true';
case DRAGDROP:
return 'true';
default: default:
return 'true'; return 'true';
} }
@ -862,9 +858,6 @@ function xml_entitize(&$collection) {
case MULTICHOICE: case MULTICHOICE:
$name = 'choiceInteraction'; $name = 'choiceInteraction';
break; break;
case XMULTICHOICE:
$name = 'choiceInteraction';
break;
case SHORTANSWER: case SHORTANSWER:
$name = 'textInteraction'; $name = 'textInteraction';
break; break;
@ -877,15 +870,9 @@ function xml_entitize(&$collection) {
case DESCRIPTION: case DESCRIPTION:
$name = 'extendedTextInteraction'; $name = 'extendedTextInteraction';
break; break;
case SIMPLEESSAY:
$name = 'extendedTextInteraction';
break;
case MULTIANSWER: case MULTIANSWER:
$name = 'textInteraction'; $name = 'textInteraction';
break; break;
case DRAGDROP:
$name = 'graphicGapMatchInteraction';
break;
default: default:
$name = 'textInteraction'; $name = 'textInteraction';
} }