From: jamiesensei Date: Mon, 8 Jan 2007 13:58:42 +0000 (+0000) Subject: migrated randomsamatch to formslib. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=08224df157c5f6f105927ee756653dbafe5f5c77;p=moodle.git migrated randomsamatch to formslib. fixed small typo in quiz mod_form --- diff --git a/lang/en_utf8/qtype_randomsamatch.php b/lang/en_utf8/qtype_randomsamatch.php new file mode 100644 index 0000000000..830f580333 --- /dev/null +++ b/lang/en_utf8/qtype_randomsamatch.php @@ -0,0 +1,4 @@ +nosaquestions short answer questions in the category that you chose \'$a->catname\'. Choose a different category, make some more questions in this category or reduce the amount of questions you\'ve selected.'; +$string['nosaincategory'] = 'There are no short answer questions in the category that you chose \'$a->catname\'. Choose a different category, make some questions in this category.'; +?> \ No newline at end of file diff --git a/lib/form/questioncategory.php b/lib/form/questioncategory.php index fc4b444a1d..04a90596dd 100644 --- a/lib/form/questioncategory.php +++ b/lib/form/questioncategory.php @@ -28,7 +28,7 @@ class MoodleQuickForm_questioncategory extends MoodleQuickForm_select { * @access public * @return void */ - function MoodleQuickForm_questioncategory($elementName = null, + function MoodleQuickForm_questioncategory($elementName = null, $elementLabel = null, $attributes = null, $options = null) { HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes, null); @@ -50,7 +50,7 @@ class MoodleQuickForm_questioncategory extends MoodleQuickForm_select { $this->_only_editable = false; } } - + /** * Called by HTML_QuickForm whenever form event is made on this element * diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index 7546d8b293..d0703b3ab1 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -205,7 +205,7 @@ class mod_quiz_mod_form extends moodleform_mod { //------------------------------------------------------------------------------- $this->standard_coursemodule_elements(); //------------------------------------------------------------------------------- - $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'quiz').' {no}'); + $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'quiz')); $mform->setHelpButton('overallfeedbackhdr', array('overallfeedback', get_string('overallfeedback', 'quiz'), 'quiz')); $mform->addElement('static', 'gradeboundarystatic1', get_string('gradeboundary', 'quiz'), '100%'); diff --git a/question/type/randomsamatch/edit_randomsamatch_form.php b/question/type/randomsamatch/edit_randomsamatch_form.php new file mode 100644 index 0000000000..98a0255af8 --- /dev/null +++ b/question/type/randomsamatch/edit_randomsamatch_form.php @@ -0,0 +1,70 @@ +removeElement('image'); + + $questionstoselect = array(); + for ($i=2; $i<=QUESTION_NUMANS; $i++){ + $questionstoselect[$i] = $i; + } + + $mform->addElement('select', 'choose', get_string("randomsamatchnumber", "quiz"), $questionstoselect); + $mform->setType('feedback', PARAM_RAW); + + $mform->addElement('hidden', 'fraction', 0); + } + + function set_defaults($question) { + if (empty($question->name)) { + $question->name = get_string("randomsamatch", "quiz"); + } + + if (empty($question->questiontext)) { + $question->questiontext = get_string("randomsamatchintro", "quiz"); + } + parent::set_defaults($question); + } + + function qtype() { + return 'randomsamatch'; + } + + function validation($data){ + global $QTYPES; + $errors = array(); + $saquestions = $QTYPES['randomsamatch']->get_sa_candidates($data['category']); + $numberavailable = count($saquestions); + if ($saquestions === false){ + $a = new object(); + $a->catname = get_field('question_categories', 'name', 'id', $data['category']); + $errors['choose'] = get_string('nosaincategory', 'qtype_randomsamatch', $a); + + } elseif ($numberavailable < $data['choose']){ + $a = new object(); + $a->catname = get_field('question_categories', 'name', 'id', $data['category']); + $a->nosaquestions = $numberavailable; + $errors['choose'] = get_string('notenoughsaincategory', 'qtype_randomsamatch', $a); + } + return $errors; + + } + +} +?> \ No newline at end of file diff --git a/question/type/randomsamatch/editquestion.html b/question/type/randomsamatch/editquestion.html deleted file mode 100644 index d6fa04dc3a..0000000000 --- a/question/type/randomsamatch/editquestion.html +++ /dev/null @@ -1,28 +0,0 @@ -qtype]->print_question_form_start($question, array(), $course, $usehtmleditor, - array('image')); -?> - - : - - choose", ""); - unset($menu); - ?> - - -qtype]->print_replacement_options($question, $course, $contextquiz); -$QTYPES[$question->qtype]->print_question_form_end($question); -?> diff --git a/question/type/randomsamatch/editquestion.php b/question/type/randomsamatch/editquestion.php deleted file mode 100644 index dca57b41da..0000000000 --- a/question/type/randomsamatch/editquestion.php +++ /dev/null @@ -1,26 +0,0 @@ -id)) { - $options = get_record("question_randomsamatch", "question", $question->id); - } else { - $options->choose = ""; - } - $saquestions = $QTYPES['randomsamatch']->get_sa_candidates($category->id); - $numberavailable = count($saquestions); - unset($saquestions); - - if (empty($question->name)) { - $question->name = get_string("randomsamatch", "quiz"); - } - - if (empty($question->questiontext)) { - $question->questiontext = get_string("randomsamatchintro", "quiz"); - } - - $yesnooptions = array(); - $yesnooptions[0] = get_string("no"); - $yesnooptions[1] = get_string("yes"); - - print_heading_with_help(get_string("editingrandomsamatch", "quiz"), "randomsamatch", "quiz"); - require("$CFG->dirroot/question/type/randomsamatch/editquestion.html"); - -?>