Example #1
0
    /**
     * Add question-type specific form fields.
     *
     * @param object $mform the form being built.
     */
    protected 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('advcheckbox', 'shuffleanswers',
                get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0, 1));
        $mform->addHelpButton('shuffleanswers', 'shuffleanswers', 'qtype_multichoice');
        $mform->setDefault('shuffleanswers', 1);

        $mform->addElement('select', 'answernumbering',
                get_string('answernumbering', 'qtype_multichoice'),
                qtype_multichoice::get_numbering_styles());
        $mform->setDefault('answernumbering', 'abc');

        $this->add_per_answer_fields($mform, get_string('choiceno', 'qtype_multichoice', '{no}'),
                question_bank::fraction_options_full(), max(5, QUESTION_NUMANS_START));

        $this->add_combined_feedback_fields(true);
        $mform->disabledIf('shownumcorrect', 'single', 'eq', 1);

        $this->add_interactive_settings(true, true);
    }
 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 protected function definition_inner($mform)
 {
     $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0, 1));
     $mform->addHelpButton('shuffleanswers', 'shuffleanswers', 'qtype_multichoice');
     $mform->setDefault('shuffleanswers', 1);
     $mform->addElement('select', 'answernumbering', get_string('answernumbering', 'qtype_multichoice'), qtype_multichoice::get_numbering_styles());
     $mform->setDefault('answernumbering', 'abc');
     $this->add_per_answer_fields($mform, get_string('choiceno', 'qtype_multichoice', '{no}'), null, max(5, QUESTION_NUMANS_START));
     $mform->addElement('header', 'overallfeedbackhdr', get_string('combinedfeedback', 'question'));
     foreach (array('correctfeedback', 'incorrectfeedback') as $feedbackname) {
         $element = $mform->addElement('editor', $feedbackname, get_string($feedbackname, 'question'), array('rows' => 5), $this->editoroptions);
         $mform->setType($feedbackname, PARAM_RAW);
         $element->setValue(array('text' => get_string($feedbackname . 'default', 'question')));
         if ($feedbackname == 'incorrectfeedback') {
             $mform->addElement('advcheckbox', 'shownumcorrect', get_string('options', 'question'), get_string('shownumpartscorrect', 'question'));
         }
     }
     $this->add_interactive_settings(true, true);
 }
 /**
  * Defines the section to set the properties of the answer options
  *
  * @throws coding_exception
  */
 protected function define_answer_options_properties_section()
 {
     global $PAGE, $OUTPUT;
     $mform = $this->_form;
     // header
     $mform->addElement('header', 'answeroptionspropertiesheader', get_string("answer_options_properties", 'qtype_omerocommon'));
     // selector to allow single or multi answers
     $menu = array(get_string('answersingleno', 'qtype_omerocommon'), get_string('answersingleyes', 'qtype_omerocommon'));
     $mform->addElement('select', 'single', get_string('answerhowmany', 'qtype_omerocommon'), $menu);
     $mform->setDefault('single', 1);
     // how to number answer options
     $mform->addElement('select', 'answernumbering', get_string('answernumbering', 'qtype_multichoice'), qtype_multichoice::get_numbering_styles());
     $mform->setDefault('answernumbering', 'abc');
     // default mark
     $mform->addElement('text', 'defaultmark', get_string('defaultmark', 'question'), array('size' => 7));
     $mform->setType('defaultmark', PARAM_FLOAT);
     $mform->setDefault('defaultmark', 1);
     $mform->addRule('defaultmark', null, 'required', null, 'client');
     // flag to set the shuffling of answer options
     $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0, 1));
     $mform->addHelpButton('shuffleanswers', 'shuffleanswers', 'qtype_multichoice');
     $mform->setDefault('shuffleanswers', 1);
     // set as expanded by default
     $mform->setExpanded('answeroptionspropertiesheader');
 }
 public function save_question_answers($question)
 {
     parent::save_question_answers($question);
     // TODO: Change the autogenerated stub
 }