From: jamiesensei Date: Sun, 7 Jan 2007 17:06:50 +0000 (+0000) Subject: more last fixes to question forms and removal of redundant files X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c6fc998899bbcafeaa42c8fe07f6eb4f9c78fbbc;p=moodle.git more last fixes to question forms and removal of redundant files --- diff --git a/question/type/multianswer/edit_multianswer_form.php b/question/type/multianswer/edit_multianswer_form.php index 0a32f161e3..2afa18ba92 100644 --- a/question/type/multianswer/edit_multianswer_form.php +++ b/question/type/multianswer/edit_multianswer_form.php @@ -15,6 +15,54 @@ class question_edit_multianswer_form extends question_edit_form { // 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'; diff --git a/question/type/multianswer/editquestion.html b/question/type/multianswer/editquestion.html deleted file mode 100644 index 40979cd2b6..0000000000 --- a/question/type/multianswer/editquestion.html +++ /dev/null @@ -1,7 +0,0 @@ -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, '', - ''); -?> diff --git a/question/type/multianswer/editquestion.php b/question/type/multianswer/editquestion.php deleted file mode 100644 index 0ef97c4d08..0000000000 --- a/question/type/multianswer/editquestion.php +++ /dev/null @@ -1,54 +0,0 @@ -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"); - -?> diff --git a/question/type/multichoice/edit_multichoice_form.php b/question/type/multichoice/edit_multichoice_form.php index e6d08e9462..b3701cb9fe 100644 --- a/question/type/multichoice/edit_multichoice_form.php +++ b/question/type/multichoice/edit_multichoice_form.php @@ -20,9 +20,11 @@ class question_edit_multichoice_form extends question_edit_form { 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');