当前位置: 首页>>代码示例>>PHP>>正文


PHP MoodleQuickForm::insertElementBefore方法代码示例

本文整理汇总了PHP中MoodleQuickForm::insertElementBefore方法的典型用法代码示例。如果您正苦于以下问题:PHP MoodleQuickForm::insertElementBefore方法的具体用法?PHP MoodleQuickForm::insertElementBefore怎么用?PHP MoodleQuickForm::insertElementBefore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MoodleQuickForm的用法示例。


在下文中一共展示了MoodleQuickForm::insertElementBefore方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     global $QTYPES;
     $this->qtypeobj =& $QTYPES[$this->qtype()];
     $label = get_string("sharedwildcards", "qtype_datasetdependent");
     $mform->addElement('hidden', 'initialcategory', 1);
     $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question);
     $mform->insertElementBefore($mform->createElement('static', 'listcategory', $label, $html2), 'name');
     $addfieldsname = 'updatecategory';
     $addstring = get_string("updatecategory", "qtype_calculated");
     $mform->registerNoSubmitButton($addfieldsname);
     $mform->insertElementBefore($mform->createElement('submit', $addfieldsname, $addstring), 'listcategory');
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerhdr', 'qtype_calculated', '{no}'));
     $repeated[] =& $mform->createElement('text', 'answers', get_string('correctanswerformula', 'quiz') . '=', array('size' => 50));
     $repeatedoptions['answers']['type'] = PARAM_NOTAGS;
     $creategrades = get_grade_options();
     $gradeoptions = $creategrades->gradeoptions;
     $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions);
     $repeatedoptions['fraction']['default'] = 0;
     $repeated[] =& $mform->createElement('text', 'tolerance', get_string('tolerance', 'qtype_calculated'));
     $repeatedoptions['tolerance']['type'] = PARAM_NUMBER;
     $repeatedoptions['tolerance']['default'] = 0.01;
     $repeated[] =& $mform->createElement('select', 'tolerancetype', get_string('tolerancetype', 'quiz'), $this->qtypeobj->tolerance_types());
     $repeated[] =& $mform->createElement('select', 'correctanswerlength', get_string('correctanswershows', 'qtype_calculated'), range(0, 9));
     $repeatedoptions['correctanswerlength']['default'] = 2;
     $answerlengthformats = array('1' => get_string('decimalformat', 'quiz'), '2' => get_string('significantfiguresformat', 'quiz'));
     $repeated[] =& $mform->createElement('select', 'correctanswerformat', get_string('correctanswershowsformat', 'qtype_calculated'), $answerlengthformats);
     $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'));
     $repeatedoptions['feedback']['type'] = PARAM_RAW;
     if (isset($this->question->options)) {
         $count = count($this->question->options->answers);
     } else {
         $count = 0;
     }
     $repeatsatstart = $count + 1;
     $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', 1, get_string('addmoreanswerblanks', 'qtype_calculated'));
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}'));
     $repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz'));
     $mform->setType('unit', PARAM_NOTAGS);
     $repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz'));
     $mform->setType('multiplier', PARAM_NUMBER);
     if (isset($this->question->options)) {
         $countunits = count($this->question->options->units);
     } else {
         $countunits = 0;
     }
     $repeatsatstart = $countunits + 1;
     $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}'));
     $firstunit =& $mform->getElement('multiplier[0]');
     $firstunit->freeze();
     $firstunit->setValue('1.0');
     $firstunit->setPersistantFreeze(true);
     //hidden elements
     $mform->addElement('hidden', 'wizard', 'datasetdefinitions');
     $mform->setType('wizard', PARAM_ALPHA);
 }
开发者ID:veritech,项目名称:pare-project,代码行数:63,代码来源:edit_calculated_form.php

示例2: array

 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     global $QTYPES;
     $this->qtypeobj =& $QTYPES[$this->qtype()];
     $label = get_string("sharedwildcards", "qtype_datasetdependent");
     $mform->addElement('hidden', 'initialcategory', 1);
     $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question);
     $mform->insertElementBefore($mform->createElement('static', 'listcategory', $label, $html2), 'name');
     $addfieldsname = 'updatecategory';
     $addstring = get_string("updatecategory", "qtype_calculated");
     $mform->registerNoSubmitButton($addfieldsname);
     $mform->insertElementBefore($mform->createElement('submit', $addfieldsname, $addstring), 'listcategory');
     $creategrades = get_grade_options();
     $this->add_per_answer_fields($mform, get_string('answerhdr', 'qtype_calculated', '{no}'), $creategrades->gradeoptions, 1, 1);
     $repeated = array();
     $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}'));
     $repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz'));
     $mform->setType('unit', PARAM_NOTAGS);
     $repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz'));
     $mform->setType('multiplier', PARAM_NUMBER);
     if (isset($this->question->options)) {
         $countunits = count($this->question->options->units);
     } else {
         $countunits = 0;
     }
     if ($this->question->formoptions->repeatelements) {
         $repeatsatstart = $countunits + 1;
     } else {
         $repeatsatstart = $countunits;
     }
     $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}'));
     if ($mform->elementExists('multiplier[0]')) {
         $firstunit =& $mform->getElement('multiplier[0]');
         $firstunit->freeze();
         $firstunit->setValue('1.0');
         $firstunit->setPersistantFreeze(true);
     }
     //hidden elements
     $mform->addElement('hidden', 'synchronize', '');
     if (isset($this->question->options) && isset($this->question->options->synchronize)) {
         $mform->setDefault("synchronize", $this->question->options->synchronize);
     } else {
         $mform->setDefault("synchronize", 0);
     }
     $mform->addElement('hidden', 'wizard', 'datasetdefinitions');
     $mform->setType('wizard', PARAM_ALPHA);
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:52,代码来源:edit_calculated_form.php

示例3: array

 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     global $QTYPES;
     $this->qtypeobj =& $QTYPES[$this->qtype()];
     // echo code left for testing period
     // echo "<p>question ".optional_param('multichoice', '', PARAM_RAW)." optional<pre>";print_r($this->question);echo "</pre></p>";
     $label = get_string("sharedwildcards", "qtype_calculated");
     $mform->addElement('hidden', 'initialcategory', 1);
     $mform->addElement('hidden', 'reload', 1);
     $mform->setType('initialcategory', PARAM_INT);
     //     $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question);
     $html2 = "";
     $mform->insertElementBefore($mform->createElement('static', 'listcategory', $label, $html2), 'name');
     if (isset($this->question->id)) {
         $mform->insertElementBefore($mform->createElement('static', 'initialname', get_string('questionstoredname', 'qtype_calculated'), $this->initialname), 'name');
     }
     $addfieldsname = 'updatecategory';
     $addstring = get_string("updatecategory", "qtype_calculated");
     $mform->registerNoSubmitButton($addfieldsname);
     $this->editasmultichoice = 1;
     $mform->insertElementBefore($mform->createElement('submit', $addfieldsname, $addstring), 'listcategory');
     $mform->registerNoSubmitButton('createoptionbutton');
     $mform->addElement('hidden', 'multichoice', $this->editasmultichoice);
     $mform->setType('multichoice', PARAM_INT);
     //            $mform->addElement('header', 'choicehdr',get_string('multichoicecalculatedquestion', 'qtype_calculated'));
     $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);
     $numberingoptions = $QTYPES['multichoice']->get_numbering_styles();
     $menu = array();
     foreach ($numberingoptions as $numberingoption) {
         $menu[$numberingoption] = get_string('answernumbering' . $numberingoption, 'qtype_multichoice');
     }
     $mform->addElement('select', 'answernumbering', get_string('answernumbering', 'qtype_multichoice'), $menu);
     $mform->setDefault('answernumbering', 'abc');
     $creategrades = get_grade_options();
     $this->add_per_answer_fields($mform, get_string('choiceno', 'qtype_multichoice', '{no}'), $creategrades->gradeoptionsfull, max(5, QUESTION_NUMANS_START));
     $repeated = array();
     //   if ($this->editasmultichoice == 1){
     $nounits = optional_param('nounits', 1, PARAM_INT);
     $mform->addElement('hidden', 'nounits', $nounits);
     $mform->setType('nounits', PARAM_INT);
     $mform->setConstants(array('nounits' => $nounits));
     for ($i = 0; $i < $nounits; $i++) {
         $mform->addElement('hidden', 'unit' . "[{$i}]", optional_param('unit' . "[{$i}]", '', PARAM_NOTAGS));
         $mform->setType('unit' . "[{$i}]", PARAM_NOTAGS);
         $mform->addElement('hidden', 'multiplier' . "[{$i}]", optional_param('multiplier' . "[{$i}]", '', PARAM_NUMBER));
         $mform->setType('multiplier' . "[{$i}]", PARAM_NUMBER);
     }
     $mform->setType('addunits', 'hidden');
     $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'qtype_multichoice'));
     foreach (array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback') as $feedbackname) {
         $mform->addElement('editor', $feedbackname, get_string($feedbackname, 'qtype_multichoice'), null, $this->editoroptions);
         $mform->setType($feedbackname, PARAM_RAW);
     }
     //hidden elements
     $mform->addElement('hidden', 'synchronize', '');
     $mform->setType('synchronize', PARAM_INT);
     if (isset($this->question->options) && isset($this->question->options->synchronize)) {
         $mform->setDefault("synchronize", $this->question->options->synchronize);
     } else {
         $mform->setDefault("synchronize", 0);
     }
     $mform->addElement('hidden', 'wizard', 'datasetdefinitions');
     $mform->setType('wizard', PARAM_ALPHA);
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:74,代码来源:edit_calculatedmulti_form.php

示例4: definition_inner

    /**
     * Add question-type specific form fields.
     *
     * @param MoodleQuickForm $mform the form being built.
     */
    protected function definition_inner($mform) {
        $this->qtypeobj = question_bank::get_qtype($this->qtype());
        $label = get_string('sharedwildcards', 'qtype_calculated');
        $mform->addElement('hidden', 'initialcategory', 1);
        $mform->addElement('hidden', 'reload', 1);
        $mform->setType('initialcategory', PARAM_INT);
        $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question);
        $mform->insertElementBefore(
                $mform->createElement('static', 'listcategory', $label, $html2), 'name');
        if (isset($this->question->id)) {
            $mform->insertElementBefore($mform->createElement('static', 'initialname',
                    get_string('questionstoredname', 'qtype_calculated'),
                    $this->initialname), 'name');
        };
        $addfieldsname = 'updatecategory';
        $addstring = get_string('updatecategory', 'qtype_calculated');
        $mform->registerNoSubmitButton($addfieldsname);

        $mform->insertElementBefore(
                $mform->createElement('submit', $addfieldsname, $addstring), 'listcategory');
        $mform->registerNoSubmitButton('createoptionbutton');

        //editing as regular
        $mform->setType('single', PARAM_INT);

        $mform->addElement('hidden', 'shuffleanswers', '1');
        $mform->setType('shuffleanswers', PARAM_INT);
        $mform->addElement('hidden', 'answernumbering', 'abc');
        $mform->setType('answernumbering', PARAM_SAFEDIR);

        $this->add_per_answer_fields($mform, get_string('answerhdr', 'qtype_calculated', '{no}'),
                question_bank::fraction_options(), 1, 1);

        $repeated = array();

        $this->add_unit_options($mform, $this);
        $this->add_unit_fields($mform, $this);
        $this->add_interactive_settings();

        // Hidden elements
        $mform->addElement('hidden', 'synchronize', '');
        $mform->setType('synchronize', PARAM_INT);
        $mform->addElement('hidden', 'wizard', 'datasetdefinitions');
        $mform->setType('wizard', PARAM_ALPHA);
    }
开发者ID:ncsu-delta,项目名称:moodle,代码行数:50,代码来源:edit_calculated_form.php

示例5: array

 /**
  * Add question-type specific form fields.
  *
  * @param MoodleQuickForm $mform the form being built.
  */
 function definition_inner(&$mform)
 {
     global $QTYPES;
     $this->qtypeobj =& $QTYPES[$this->qtype()];
     $label = get_string('sharedwildcards', 'qtype_calculated');
     $mform->addElement('hidden', 'initialcategory', 1);
     $mform->addElement('hidden', 'reload', 1);
     $mform->setType('initialcategory', PARAM_INT);
     $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question);
     $mform->insertElementBefore($mform->createElement('static', 'listcategory', $label, $html2), 'name');
     if (isset($this->question->id)) {
         $mform->insertElementBefore($mform->createElement('static', 'initialname', get_string('questionstoredname', 'qtype_calculated'), $this->initialname), 'name');
     }
     $addfieldsname = 'updatecategory';
     $addstring = get_string("updatecategory", "qtype_calculated");
     $mform->registerNoSubmitButton($addfieldsname);
     $mform->insertElementBefore($mform->createElement('submit', $addfieldsname, $addstring), 'listcategory');
     $mform->registerNoSubmitButton('createoptionbutton');
     //editing as regular
     $mform->setType('single', PARAM_INT);
     $mform->addElement('hidden', 'shuffleanswers', '1');
     $mform->setType('shuffleanswers', PARAM_INT);
     $mform->addElement('hidden', 'answernumbering', 'abc');
     $mform->setType('answernumbering', PARAM_SAFEDIR);
     $creategrades = get_grade_options();
     $this->add_per_answer_fields($mform, get_string('answerhdr', 'qtype_calculated', '{no}'), $creategrades->gradeoptions, 1, 1);
     $repeated = array();
     $QTYPES['numerical']->add_units_options($mform, $this);
     $QTYPES['numerical']->add_units_elements($mform, $this);
     //hidden elements
     $mform->addElement('hidden', 'synchronize', '');
     $mform->setType('synchronize', PARAM_INT);
     $mform->addElement('hidden', 'wizard', 'datasetdefinitions');
     $mform->setType('wizard', PARAM_ALPHA);
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:40,代码来源:edit_calculated_form.php

示例6: add_choice_group

 /**
  * method to add choice options to the form
  *
  * @param MoodleQuickForm $mform form
  * @param unknown $choice choice (new (negative id) or existing)
  */
 private function add_choice_group(MoodleQuickForm $mform, $choice)
 {
     $elemprefix = 'choices_' . $choice->id . '_';
     $mform->addElement('hidden', $elemprefix . 'id', $choice->id);
     // Save the record's id.
     $mform->setType($elemprefix . 'id', PARAM_INT);
     $elementname = 'fieldset_edit_choice' . $choice->id;
     $mform->addElement('header', $elementname, get_string('edit_choice', self::MOD_NAME, $choice->title));
     $mform->insertElementBefore($mform->removeElement($elementname, false), self::CHOICE_PLACEHOLDER_IDENTIFIER);
     $elementname = $elemprefix . 'title';
     $mform->addElement('text', $elementname, get_string('choice_title', self::MOD_NAME));
     $mform->setDefault($elementname, $choice->title);
     $mform->setType($elementname, PARAM_TEXT);
     $mform->addHelpButton($elementname, 'choice_title', self::MOD_NAME);
     $mform->insertElementBefore($mform->removeElement($elementname, false), self::CHOICE_PLACEHOLDER_IDENTIFIER);
     $mform->addRule($elementname, $this->msgerrorrequired, 'required', null, 'server');
     $elementname = $elemprefix . 'explanation';
     $mform->addElement('text', $elementname, get_string('choice_explanation', self::MOD_NAME));
     $mform->insertElementBefore($mform->removeElement($elementname, false), self::CHOICE_PLACEHOLDER_IDENTIFIER);
     $mform->setDefault($elementname, $choice->explanation);
     $mform->setType($elementname, PARAM_TEXT);
     $elementname = $elemprefix . 'maxsize';
     $mform->addElement('text', $elementname, get_string('choice_maxsize', self::MOD_NAME));
     $mform->insertElementBefore($mform->removeElement($elementname, false), self::CHOICE_PLACEHOLDER_IDENTIFIER);
     $mform->setDefault($elementname, $choice->maxsize);
     $mform->setType($elementname, PARAM_INT);
     $mform->addRule($elementname, $this->msgerrorrequired, 'required', null, 'server');
     $elementname = $elemprefix . 'active';
     $checkbox = $mform->addElement('advcheckbox', $elementname, get_string('choice_active', self::MOD_NAME), null, null, array(0, 1));
     $mform->insertElementBefore($mform->removeElement($elementname, false), self::CHOICE_PLACEHOLDER_IDENTIFIER);
     $mform->setDefault($elementname, $choice->active);
     $mform->addHelpButton($elementname, 'choice_active', self::MOD_NAME);
     $elementname = self::DELETE_CHOICE_ACTION . $choice->id;
     $mform->registerNoSubmitButton($elementname);
     $mform->addElement('submit', $elementname, get_string('deletechoice', self::MOD_NAME));
     $mform->insertElementBefore($mform->removeElement($elementname, false), self::CHOICE_PLACEHOLDER_IDENTIFIER);
 }
开发者ID:andrewhancox,项目名称:moodle-mod_ratingallocate,代码行数:43,代码来源:mod_form.php

示例7: add_settings_form_fields

 public static function add_settings_form_fields(mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
 {
     $mform->insertElementBefore($mform->createElement('selectyesno', 'gradebycategory', get_string('gradebycategory', 'quizaccess_gradebycategory')), 'security');
     $mform->setDefault('gradebycategory', get_config('quizaccess_gradebycategory', 'gradebycategory'));
     $mform->addHelpButton('gradebycategory', 'gradebycategory', 'quizaccess_gradebycategory');
 }
开发者ID:advancingdesign,项目名称:moodle-mod_quiz_accessrule_gradebycategory,代码行数:6,代码来源:rule.php


注:本文中的MoodleQuickForm::insertElementBefore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。