protected function definition_inner($mform) { // Load the configuration. $this->stackconfig = stack_utils::get_config(); // Prepare input types. $this->typechoices = stack_input_factory::get_available_type_choices(); // Prepare answer test types. $answertests = stack_ans_test_controller::get_available_ans_tests(); // Algebraic Equivalence should be the default test, and first on the list. // This does not come first in the alphabet of all languages. $default = 'AlgEquiv'; $defaultstr = stack_string($answertests[$default]); unset($answertests[$default]); $this->answertestchoices = array(); foreach ($answertests as $test => $string) { $this->answertestchoices[$test] = stack_string($string); } stack_utils::sort_array($this->answertestchoices); $this->answertestchoices = array_merge(array($default => $defaultstr), $this->answertestchoices); // Prepare score mode choices. $this->scoremodechoices = array('=' => '=', '+' => '+', '-' => '-'); $inputnames = $this->get_input_names_from_question_text(); $prtnames = $this->get_prt_names_from_question(); // Note that for the editor elements, we are using // $mform->getElement('prtincorrect')->setValue(...); // instead of setDefault, because setDefault does not work for editors. $mform->addHelpButton('questiontext', 'questiontext', 'qtype_stack'); $mform->addRule('questiontext', stack_string('questiontextnonempty'), 'required', '', 'client'); $qvars = $mform->createElement('textarea', 'questionvariables', stack_string('questionvariables'), array('rows' => 5, 'cols' => 80)); $mform->insertElementBefore($qvars, 'questiontext'); $mform->addHelpButton('questionvariables', 'questionvariables', 'qtype_stack'); $seed = $mform->createElement('text', 'variantsselectionseed', stack_string('variantsselectionseed'), array('size' => 50)); $mform->insertElementBefore($seed, 'questiontext'); $mform->setType('variantsselectionseed', PARAM_RAW); $mform->addHelpButton('variantsselectionseed', 'variantsselectionseed', 'qtype_stack'); $sf = $mform->createElement('editor', 'specificfeedback', get_string('specificfeedback', 'question'), array('rows' => 10), $this->editoroptions); $mform->insertElementBefore($sf, 'generalfeedback'); $mform->getElement('specificfeedback')->setValue(array('text' => self::DEFAULT_SPECIFIC_FEEDBACK)); $mform->addHelpButton('specificfeedback', 'specificfeedback', 'qtype_stack'); $mform->addHelpButton('generalfeedback', 'generalfeedback', 'qtype_stack'); $mform->addElement('textarea', 'questionnote', stack_string('questionnote'), array('rows' => 2, 'cols' => 80)); $mform->addHelpButton('questionnote', 'questionnote', 'qtype_stack'); $mform->addElement('submit', 'verify', stack_string('verifyquestionandupdate')); $mform->registerNoSubmitButton('verify'); // Inputs. foreach ($inputnames as $inputname => $counts) { $this->definition_input($inputname, $mform, $counts); } // PRTs. foreach ($prtnames as $prtname => $count) { $this->definition_prt($prtname, $mform, $count); } // Options. $mform->addElement('header', 'optionsheader', stack_string('options')); $mform->addElement('selectyesno', 'questionsimplify', stack_string('questionsimplify')); $mform->setDefault('questionsimplify', $this->stackconfig->questionsimplify); $mform->addHelpButton('questionsimplify', 'autosimplify', 'qtype_stack'); $mform->addElement('selectyesno', 'assumepositive', stack_string('assumepositive')); $mform->setDefault('assumepositive', $this->stackconfig->assumepositive); $mform->addHelpButton('assumepositive', 'assumepositive', 'qtype_stack'); $mform->addElement('editor', 'prtcorrect', stack_string('prtcorrectfeedback'), array('rows' => 1), $this->editoroptions); $mform->getElement('prtcorrect')->setValue(array('text' => $this->stackconfig->prtcorrect)); $mform->addElement('editor', 'prtpartiallycorrect', stack_string('prtpartiallycorrectfeedback'), array('rows' => 1), $this->editoroptions); $mform->getElement('prtpartiallycorrect')->setValue(array('text' => $this->stackconfig->prtpartiallycorrect)); $mform->addElement('editor', 'prtincorrect', stack_string('prtincorrectfeedback'), array('rows' => 1), $this->editoroptions); $mform->getElement('prtincorrect')->setValue(array('text' => $this->stackconfig->prtincorrect)); $mform->addElement('select', 'multiplicationsign', stack_string('multiplicationsign'), stack_options::get_multiplication_sign_options()); $mform->setDefault('multiplicationsign', $this->stackconfig->multiplicationsign); $mform->addHelpButton('multiplicationsign', 'multiplicationsign', 'qtype_stack'); $mform->addElement('selectyesno', 'sqrtsign', stack_string('sqrtsign')); $mform->setDefault('sqrtsign', $this->stackconfig->sqrtsign); $mform->addHelpButton('sqrtsign', 'sqrtsign', 'qtype_stack'); $mform->addElement('select', 'complexno', stack_string('complexno'), stack_options::get_complex_no_options()); $mform->setDefault('complexno', $this->stackconfig->complexno); $mform->addHelpButton('complexno', 'complexno', 'qtype_stack'); $mform->addElement('select', 'inversetrig', stack_string('inversetrig'), stack_options::get_inverse_trig_options()); $mform->setDefault('inversetrig', $this->stackconfig->inversetrig); $mform->addHelpButton('inversetrig', 'inversetrig', 'qtype_stack'); $mform->addElement('select', 'matrixparens', stack_string('matrixparens'), stack_options::get_matrix_parens_options()); $mform->setDefault('matrixparens', $this->stackconfig->matrixparens); $mform->addHelpButton('matrixparens', 'matrixparens', 'qtype_stack'); // Hints. $this->add_interactive_settings(); // Replace standard penalty input at the bottom with the one we want. $mform->removeElement('multitriesheader'); $mform->removeElement('penalty'); $pen = $mform->createElement('text', 'penalty', stack_string('penalty'), array('size' => 5)); $mform->insertElementBefore($pen, 'generalfeedback'); $mform->setType('penalty', PARAM_FLOAT); $mform->addHelpButton('penalty', 'penalty', 'qtype_stack'); $mform->setDefault('penalty', 0.1); $mform->addRule('penalty', null, 'required', null, 'client'); }
/** * @return array input type internal name => display name. */ public static function get_available_type_choices() { $types = self::get_available_types(); $choices = array(); foreach ($types as $type => $notused) { $choices[$type] = stack_string('inputtype' . $type); } stack_utils::sort_array($choices); return $choices; }