// No question-type specific form fields.
+ function set_defaults($question) {
+ if ($question->questiontext and $question->id and $question->qtype) {
+
+ foreach ($question->options->questions as $key => $wrapped) {
+ // The old way of restoring the definitions is kept to gradually
+ // update all multianswer questions
+ if (empty($wrapped->questiontext)) {
+ $parsableanswerdef = '{' . $wrapped->defaultgrade . ':';
+ switch ($wrapped->qtype) {
+ case 'multichoice':
+ $parsableanswerdef .= 'MULTICHOICE:';
+ break;
+ case 'shortanswer':
+ $parsableanswerdef .= 'SHORTANSWER:';
+ break;
+ case 'numerical':
+ $parsableanswerdef .= 'NUMERICAL:';
+ break;
+ default:
+ error("questiontype $wrapped->qtype not recognized");
+ }
+ $separator= '';
+ foreach ($wrapped->options->answers as $subanswer) {
+ $parsableanswerdef .= $separator
+ . '%' . round(100*$subanswer->fraction) . '%';
+ $parsableanswerdef .= $subanswer->answer;
+ if (!empty($wrapped->options->tolerance)) {
+ // Special for numerical answers:
+ $parsableanswerdef .= ":{$wrapped->options->tolerance}";
+ // We only want tolerance for the first alternative, it will
+ // be applied to all of the alternatives.
+ unset($wrapped->options->tolerance);
+ }
+ if ($subanswer->feedback) {
+ $parsableanswerdef .= "#$subanswer->feedback";
+ }
+ $separator = '~';
+ }
+ $parsableanswerdef .= '}';
+ // Fix the questiontext fields of old questions
+ set_field('question', 'questiontext', addslashes($parsableanswerdef), 'id', $wrapped->id);
+ } else {
+ $parsableanswerdef = str_replace('&#', '&\#', $wrapped->questiontext);
+ }
+ $question->questiontext = str_replace("{#$key}", $parsableanswerdef, $question->questiontext);
+ }
+ }
+ }
function qtype() {
return 'multianswer';
+++ /dev/null
-<?php
-$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor,
- array('defaultgrade'));
-$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
-$QTYPES[$question->qtype]->print_question_form_end($question, '',
- '<input type="hidden" name="defaultgrade" value="' . s($question->defaultgrade) . '" />');
-?>
+++ /dev/null
-<?php // $Id$
- if ($question->questiontext and $question->id and $question->qtype) {
- global $QTYPES;
- $QTYPES[$question->qtype]->get_question_options($question);
-
- foreach ($question->options->questions as $key => $wrapped) {
- // The old way of restoring the definitions is kept to gradually
- // update all multianswer questions
- if (empty($wrapped->questiontext)) {
- $parsableanswerdef = '{' . $wrapped->defaultgrade . ':';
- switch ($wrapped->qtype) {
- case 'multichoice':
- $parsableanswerdef .= 'MULTICHOICE:';
- break;
- case 'shortanswer':
- $parsableanswerdef .= 'SHORTANSWER:';
- break;
- case 'numerical':
- $parsableanswerdef .= 'NUMERICAL:';
- break;
- default:
- error("questiontype $wrapped->qtype not recognized");
- }
- $separator= '';
- foreach ($wrapped->options->answers as $subanswer) {
- $parsableanswerdef .= $separator
- . '%' . round(100*$subanswer->fraction) . '%';
- $parsableanswerdef .= $subanswer->answer;
- if (!empty($wrapped->options->tolerance)) {
- // Special for numerical answers:
- $parsableanswerdef .= ":{$wrapped->options->tolerance}";
- // We only want tolerance for the first alternative, it will
- // be applied to all of the alternatives.
- unset($wrapped->options->tolerance);
- }
- if ($subanswer->feedback) {
- $parsableanswerdef .= "#$subanswer->feedback";
- }
- $separator = '~';
- }
- $parsableanswerdef .= '}';
- // Fix the questiontext fields of old questions
- set_field('question', 'questiontext', addslashes($parsableanswerdef), 'id', $wrapped->id);
- } else {
- $parsableanswerdef = str_replace('&#', '&\#', $wrapped->questiontext);
- }
- $question->questiontext = str_replace("{#$key}", $parsableanswerdef, $question->questiontext);
- }
- }
- print_heading_with_help(get_string('editingmultianswer', 'quiz'),
- 'multianswer', 'quiz');
- require("$CFG->dirroot/question/type/multianswer/editquestion.html");
-
-?>
function definition_inner(&$mform) {
$menu = array(get_string('answersingleno', 'qtype_multichoice'), get_string('answersingleyes', 'qtype_multichoice'));
$mform->addElement('select', 'single', get_string('answerhowmany', 'qtype_multichoice'), $menu);
+ $mform->setDefault('single', 1);
- $mform->addElement('selectyesno', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'));
+ $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0,1));
$mform->setHelpButton('shuffleanswers', array('multichoiceshuffle', get_string('shuffleanswers','qtype_multichoice'), 'quiz'));
+ $mform->setDefault('shuffleanswers', 1);
/* $mform->addElement('static', 'answersinstruct', get_string('choices', 'qtype_multichoice'), get_string('fillouttwochoices', 'qtype_multichoice'));
$mform->closeHeaderBefore('answersinstruct');