]> git.mjollnir.org Git - moodle.git/commitdiff
more last fixes to question forms and removal of redundant files
authorjamiesensei <jamiesensei>
Sun, 7 Jan 2007 17:06:50 +0000 (17:06 +0000)
committerjamiesensei <jamiesensei>
Sun, 7 Jan 2007 17:06:50 +0000 (17:06 +0000)
question/type/multianswer/edit_multianswer_form.php
question/type/multianswer/editquestion.html [deleted file]
question/type/multianswer/editquestion.php [deleted file]
question/type/multichoice/edit_multichoice_form.php

index 0a32f161e33f63524d236ccdde75ad81f3cef828..2afa18ba9224b780bbbcb45e4a30ee387b99a047 100644 (file)
@@ -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 (file)
index 40979cd..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?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) . '" />');
-?>
diff --git a/question/type/multianswer/editquestion.php b/question/type/multianswer/editquestion.php
deleted file mode 100644 (file)
index 0ef97c4..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?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");
-
-?>
index e6d08e9462321bbf38229ec752e28a84d7e75b3f..b3701cb9fe6c5a04a35fbdafc32970d26214657c 100644 (file)
@@ -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');