\n";
// Add header.
$expout .= "
{$question->name}
\n";
// Format and add the question text.
$text = question_rewrite_question_preview_urls($question->questiontext, $question->id,
$question->contextid, 'question', 'questiontext', $question->id,
$question->contextid, 'qformat_xhtml');
$expout .= '
' . format_text($text,
$question->questiontextformat, array('noclean' => true)) . "
\n";
// Selection depends on question type.
switch($question->qtype) {
case 'truefalse':
$sttrue = get_string('true', 'qtype_truefalse');
$stfalse = get_string('false', 'qtype_truefalse');
$expout .= "
\n";
break;
case 'multichoice':
$expout .= "
\n";
break;
case 'shortanswer':
$expout .= html_writer::start_tag('ul', array('class' => 'shortanswer'));
$expout .= html_writer::start_tag('li');
$expout .= html_writer::label(get_string('answer'), 'quest_'.$id, false, array('class' => 'accesshide'));
$expout .= html_writer::empty_tag('input', array('id' => "quest_{$id}", 'name' => "quest_{$id}", 'type' => 'text'));
$expout .= html_writer::end_tag('li');
$expout .= html_writer::end_tag('ul');
break;
case 'numerical':
$expout .= html_writer::start_tag('ul', array('class' => 'numerical'));
$expout .= html_writer::start_tag('li');
$expout .= html_writer::label(get_string('answer'), 'quest_'.$id, false, array('class' => 'accesshide'));
$expout .= html_writer::empty_tag('input', array('id' => "quest_{$id}", 'name' => "quest_{$id}", 'type' => 'text'));
$expout .= html_writer::end_tag('li');
$expout .= html_writer::end_tag('ul');
break;
case 'match':
$expout .= html_writer::start_tag('ul', array('class' => 'match'));
// Build answer list.
$answerlist = array();
foreach ($question->options->subquestions as $subquestion) {
$answerlist[] = $this->repchar( $subquestion->answertext );
}
shuffle( $answerlist ); // Random display order.
// Build select options.
$selectoptions = array();
foreach ($answerlist as $ans) {
$selectoptions[s($ans)] = s($ans);
}
// Display.
$option = 0;
foreach ($question->options->subquestions as $subquestion) {
// Build drop down for answers.
$questiontext = $this->repchar( $subquestion->questiontext );
if ($questiontext != '') {
$dropdown = html_writer::label(get_string('answer', 'qtype_match', $option+1), 'quest_'.$id.'_'.$option,
false, array('class' => 'accesshide'));
$dropdown .= html_writer::select($selectoptions, "quest_{$id}_{$option}", '', false,
array('id' => "quest_{$id}_{$option}"));
$expout .= html_writer::tag('li', $questiontext);
$expout .= $dropdown;
$option++;
}
}
$expout .= html_writer::end_tag('ul');
break;
case 'description':
break;
case 'multianswer':
default:
$expout .= "\n";
}
// Close off div.
$expout .= "
\n\n\n";
return $expout;
}
protected function presave_process($content) {
// Override method to allow us to add xhtml headers and footers.
global $CFG;
// Get css bit.
$csslines = file( "{$CFG->dirroot}/question/format/xhtml/xhtml.css" );
$css = implode( ' ', $csslines );
$xp = "\n";
$xp .= "\n";
$xp .= "\n";
$xp .= "