--- /dev/null
+<?php
+$string['notenoughsaincategory'] = 'There is/are only $a->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
* @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);
$this->_only_editable = false;
}
}
-
+
/**
* Called by HTML_QuickForm whenever form event is made on this element
*
//-------------------------------------------------------------------------------
$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%');
--- /dev/null
+<?php
+/**
+ * Defines the editing form for the randomsamatch question type.
+ *
+ * @copyright © 2007 Jamie Pratt
+ * @author Jamie Pratt me@jamiep.org
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package questions
+ */
+
+/**
+ * randomsamatch editing form definition.
+ */
+class question_edit_randomsamatch_form extends question_edit_form {
+ /**
+ * Add question-type specific form fields.
+ *
+ * @param MoodleQuickForm $mform the form being built.
+ */
+ function definition_inner(&$mform) {
+ $mform->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
+++ /dev/null
-<?php
-$QTYPES[$question->qtype]->print_question_form_start($question, array(), $course, $usehtmleditor,
- array('image'));
-?>
-<tr valign="top">
- <td align="right"><b><?php print_string("randomsamatchnumber", "quiz") ?>:</b></td>
- <td align="left">
- <?php
- if ($numberavailable < 2) {
- echo get_string('createfirst', 'quiz');
- $maxrandom=2;
- } else if ($numberavailable < 6) {
- $maxrandom = $numberavailable;
- } else {
- $maxrandom = QUESTION_NUMANS;
- }
- for ($i=2;$i<=$maxrandom;$i++) {
- $menu[$i] = $i;
- }
- choose_from_menu($menu, "choose", "$options->choose", "");
- unset($menu);
- ?>
- </td>
-</tr>
-<?php
-$QTYPES[$question->qtype]->print_replacement_options($question, $course, $contextquiz);
-$QTYPES[$question->qtype]->print_question_form_end($question);
-?>
+++ /dev/null
-<?php // $Id$
- if (!empty($question->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");
-
-?>