The definition of the fields to use.

@param MoodleQuickForm $mform
489905
protected function specific_definition($mform) {
        global $DB;

        // Load defaults.
        $blockconfig = get_config('block_activity_results');

        // Fields for editing activity_results block title and contents.
        $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));

        // Get supported modules (Only modules using grades or scales will be listed).
        $sql = 'SELECT id, itemname FROM {grade_items} WHERE courseid = ? and itemtype = ? and (gradetype = ? or gradetype = ?)';
        $params = array($this->page->course->id, 'mod', GRADE_TYPE_VALUE, GRADE_TYPE_SCALE);
        $activities = $DB->get_records_sql_menu($sql, $params);
        core_collator::asort($activities);

        if (empty($activities)) {
            $mform->addElement('static', 'noactivitieswarning', get_string('config_select_activity', 'block_activity_results'),
                    get_string('config_no_activities_in_course', 'block_activity_results'));
        } else {
            foreach ($activities as $id => $name) {
                $activities[$id] = strip_tags(format_string($name));
            }
            $mform->addElement('select', 'config_activitygradeitemid',
                    get_string('config_select_activity', 'block_activity_results'), $activities);
            $mform->setDefault('config_activitygradeitemid', $this->block->get_owning_activity()->id);
        }

        $mform->addElement('text', 'config_showbest',
                get_string('config_show_best', 'block_activity_results'), array('size' => 3));
        $mform->setDefault('config_showbest', $blockconfig->config_showbest);
        $mform->setType('config_showbest', PARAM_INT);
        if ($blockconfig->config_showbest_locked) {
            $mform->freeze('config_showbest');
        }

        $mform->addElement('text', 'config_showworst',
                get_string('config_show_worst', 'block_activity_results'), array('size' => 3));
        $mform->setDefault('config_showworst', $blockconfig->config_showworst);
        $mform->setType('config_showworst', PARAM_INT);
        if ($blockconfig->config_showworst_locked) {
            $mform->freeze('config_showworst');
        }

        $mform->addElement('selectyesno', 'config_usegroups', get_string('config_use_groups', 'block_activity_results'));
        $mform->setDefault('config_usegroups', $blockconfig->config_usegroups);
        if ($blockconfig->config_usegroups_locked) {
            $mform->freeze('config_usegroups');
        }

        $nameoptions = array(
            B_ACTIVITYRESULTS_NAME_FORMAT_FULL => get_string('config_names_full', 'block_activity_results'),
            B_ACTIVITYRESULTS_NAME_FORMAT_ID => get_string('config_names_id', 'block_activity_results'),
            B_ACTIVITYRESULTS_NAME_FORMAT_ANON => get_string('config_names_anon', 'block_activity_results')
        );
        $mform->addElement('select', 'config_nameformat',
                get_string('config_name_format', 'block_activity_results'), $nameoptions);
        $mform->setDefault('config_nameformat', $blockconfig->config_nameformat);
        if ($blockconfig->config_nameformat_locked) {
            $mform->freeze('config_nameformat');
        }

        $gradeeoptions = array(
            B_ACTIVITYRESULTS_GRADE_FORMAT_PCT => get_string('config_format_percentage', 'block_activity_results'),
            B_ACTIVITYRESULTS_GRADE_FORMAT_FRA => get_string('config_format_fraction', 'block_activity_results'),
            B_ACTIVITYRESULTS_GRADE_FORMAT_ABS => get_string('config_format_absolute', 'block_activity_results')
        );
        $mform->addElement('select', 'config_gradeformat',
                get_string('config_grade_format', 'block_activity_results'), $gradeeoptions);
        $mform->setDefault('config_gradeformat', $blockconfig->config_gradeformat);
        if ($blockconfig->config_gradeformat_locked) {
            $mform->freeze('config_gradeformat');
        }

        $options = array();
        for ($i = 0; $i <= 5; $i++) {
            $options[$i] = $i;
        }
        $mform->addElement('select', 'config_decimalpoints', get_string('config_decimalplaces', 'block_activity_results'),
                $options);
        $mform->setDefault('config_decimalpoints', $blockconfig->config_decimalpoints);
        $mform->setType('config_decimalpoints', PARAM_INT);
        if ($blockconfig->config_decimalpoints_locked) {
            $mform->freeze('config_decimalpoints');
        }
    }
391427
public function edit_instance_form($instance, MoodleQuickForm $mform, $coursecontext) {
        global $DB;

        $groups = $this->get_group_options($coursecontext);
        $existing = $DB->get_records('enrol', array('enrol' => 'meta', 'courseid' => $coursecontext->instanceid), '', 'customint1, id');

        $excludelist = array($coursecontext->instanceid);
        foreach ($existing as $existinginstance) {
            $excludelist[] = $existinginstance->customint1;
        }

        $options = array(
            'requiredcapabilities' => array('enrol/meta:selectaslinked'),
            'multiple' => empty($instance->id),  // We only accept multiple values on creation.
            'exclude' => $excludelist
        );
        $mform->addElement('course', 'customint1', get_string('linkedcourse', 'enrol_meta'), $options);
        $mform->addRule('customint1', get_string('required'), 'required', null, 'client');
        if (!empty($instance->id)) {
            $mform->freeze('customint1');
        }

        $mform->addElement('select', 'customint2', get_string('addgroup', 'enrol_meta'), $groups);
    }
308137
public function get_settings(MoodleQuickForm $mform) {
        $default = $this->get_config('commentinline');
        if ($default === false) {
            // Apply the admin default if we don't have a value yet.
            $default = get_config('assignfeedback_comments', 'inline');
        }
        $mform->addElement('selectyesno',
                           'assignfeedback_comments_commentinline',
                           get_string('commentinline', 'assignfeedback_comments'));
        $mform->addHelpButton('assignfeedback_comments_commentinline', 'commentinline', 'assignfeedback_comments');
        $mform->setDefault('assignfeedback_comments_commentinline', $default);
        // Disable comment online if comment feedback plugin is disabled.
        $mform->hideIf('assignfeedback_comments_commentinline', 'assignfeedback_comments_enabled', 'notchecked');
   }
674192
public function definition() {
        global $CFG, $COURSE, $DB, $PAGE;
        $mform = $this->_form;

        $mform->addElement('header', 'general', get_string('general', 'form'));

        $mform->addElement('text', 'name', get_string('assignmentname', 'assign'), array('size'=>'64'));
        if (!empty($CFG->formatstringstriptags)) {
            $mform->setType('name', PARAM_TEXT);
        } else {
            $mform->setType('name', PARAM_CLEANHTML);
        }
        $mform->addRule('name', null, 'required', null, 'client');
        $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');

        $this->standard_intro_elements(get_string('description', 'assign'));

        $mform->addElement('filemanager', 'introattachments',
                            get_string('introattachments', 'assign'),
                            null, array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes) );
        $mform->addHelpButton('introattachments', 'introattachments', 'assign');

        $ctx = null;
        if ($this->current && $this->current->coursemodule) {
            $cm = get_coursemodule_from_instance('assign', $this->current->id, 0, false, MUST_EXIST);
            $ctx = context_module::instance($cm->id);
        }
        $assignment = new assign($ctx, null, null);
        if ($this->current && $this->current->course) {
            if (!$ctx) {
                $ctx = context_course::instance($this->current->course);
            }
            $course = $DB->get_record('course', array('id'=>$this->current->course), '*', MUST_EXIST);
            $assignment->set_course($course);
        }

        $config = get_config('assign');

        $mform->addElement('header', 'availability', get_string('availability', 'assign'));
        $mform->setExpanded('availability', true);

        $name = get_string('allowsubmissionsfromdate', 'assign');
        $options = array('optional'=>true);
        $mform->addElement('date_time_selector', 'allowsubmissionsfromdate', $name, $options);
        $mform->addHelpButton('allowsubmissionsfromdate', 'allowsubmissionsfromdate', 'assign');

        $name = get_string('duedate', 'assign');
        $mform->addElement('date_time_selector', 'duedate', $name, array('optional'=>true));
        $mform->addHelpButton('duedate', 'duedate', 'assign');

        $name = get_string('cutoffdate', 'assign');
        $mform->addElement('date_time_selector', 'cutoffdate', $name, array('optional'=>true));
        $mform->addHelpButton('cutoffdate', 'cutoffdate', 'assign');

        $name = get_string('gradingduedate', 'assign');
        $mform->addElement('date_time_selector', 'gradingduedate', $name, array('optional' => true));
        $mform->addHelpButton('gradingduedate', 'gradingduedate', 'assign');

        $name = get_string('alwaysshowdescription', 'assign');
        $mform->addElement('checkbox', 'alwaysshowdescription', $name);
        $mform->addHelpButton('alwaysshowdescription', 'alwaysshowdescription', 'assign');
        $mform->disabledIf('alwaysshowdescription', 'allowsubmissionsfromdate[enabled]', 'notchecked');

        $assignment->add_all_plugin_settings($mform);

        $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'assign'));

        $name = get_string('submissiondrafts', 'assign');
        $mform->addElement('selectyesno', 'submissiondrafts', $name);
        $mform->addHelpButton('submissiondrafts', 'submissiondrafts', 'assign');

        $name = get_string('requiresubmissionstatement', 'assign');
        $mform->addElement('selectyesno', 'requiresubmissionstatement', $name);
        $mform->addHelpButton('requiresubmissionstatement',
                              'requiresubmissionstatement',
                              'assign');
        $mform->setType('requiresubmissionstatement', PARAM_BOOL);

        $options = array(
            ASSIGN_ATTEMPT_REOPEN_METHOD_NONE => get_string('attemptreopenmethod_none', 'mod_assign'),
            ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL => get_string('attemptreopenmethod_manual', 'mod_assign'),
            ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS => get_string('attemptreopenmethod_untilpass', 'mod_assign')
        );
        $mform->addElement('select', 'attemptreopenmethod', get_string('attemptreopenmethod', 'mod_assign'), $options);
        $mform->addHelpButton('attemptreopenmethod', 'attemptreopenmethod', 'mod_assign');

        $options = array(ASSIGN_UNLIMITED_ATTEMPTS => get_string('unlimitedattempts', 'mod_assign'));
        $options += array_combine(range(1, 30), range(1, 30));
        $mform->addElement('select', 'maxattempts', get_string('maxattempts', 'mod_assign'), $options);
        $mform->addHelpButton('maxattempts', 'maxattempts', 'assign');
        $mform->hideIf('maxattempts', 'attemptreopenmethod', 'eq', ASSIGN_ATTEMPT_REOPEN_METHOD_NONE);

        $mform->addElement('header', 'groupsubmissionsettings', get_string('groupsubmissionsettings', 'assign'));

        $name = get_string('teamsubmission', 'assign');
        $mform->addElement('selectyesno', 'teamsubmission', $name);
        $mform->addHelpButton('teamsubmission', 'teamsubmission', 'assign');
        if ($assignment->has_submissions_or_grades()) {
            $mform->freeze('teamsubmission');
        }

        $name = get_string('preventsubmissionnotingroup', 'assign');
        $mform->addElement('selectyesno', 'preventsubmissionnotingroup', $name);
        $mform->addHelpButton('preventsubmissionnotingroup',
            'preventsubmissionnotingroup',
            'assign');
        $mform->setType('preventsubmissionnotingroup', PARAM_BOOL);
        $mform->hideIf('preventsubmissionnotingroup', 'teamsubmission', 'eq', 0);

        $name = get_string('requireallteammemberssubmit', 'assign');
        $mform->addElement('selectyesno', 'requireallteammemberssubmit', $name);
        $mform->addHelpButton('requireallteammemberssubmit', 'requireallteammemberssubmit', 'assign');
        $mform->hideIf('requireallteammemberssubmit', 'teamsubmission', 'eq', 0);
        $mform->disabledIf('requireallteammemberssubmit', 'submissiondrafts', 'eq', 0);

        $groupings = groups_get_all_groupings($assignment->get_course()->id);
        $options = array();
        $options[0] = get_string('none');
        foreach ($groupings as $grouping) {
            $options[$grouping->id] = $grouping->name;
        }

        $name = get_string('teamsubmissiongroupingid', 'assign');
        $mform->addElement('select', 'teamsubmissiongroupingid', $name, $options);
        $mform->addHelpButton('teamsubmissiongroupingid', 'teamsubmissiongroupingid', 'assign');
        $mform->hideIf('teamsubmissiongroupingid', 'teamsubmission', 'eq', 0);
        if ($assignment->has_submissions_or_grades()) {
            $mform->freeze('teamsubmissiongroupingid');
        }

        $mform->addElement('header', 'notifications', get_string('notifications', 'assign'));

        $name = get_string('sendnotifications', 'assign');
        $mform->addElement('selectyesno', 'sendnotifications', $name);
        $mform->addHelpButton('sendnotifications', 'sendnotifications', 'assign');

        $name = get_string('sendlatenotifications', 'assign');
        $mform->addElement('selectyesno', 'sendlatenotifications', $name);
        $mform->addHelpButton('sendlatenotifications', 'sendlatenotifications', 'assign');
        $mform->disabledIf('sendlatenotifications', 'sendnotifications', 'eq', 1);

        $name = get_string('sendstudentnotificationsdefault', 'assign');
        $mform->addElement('selectyesno', 'sendstudentnotifications', $name);
        $mform->addHelpButton('sendstudentnotifications', 'sendstudentnotificationsdefault', 'assign');

        // Plagiarism enabling form.
        if (!empty($CFG->enableplagiarism)) {
            require_once($CFG->libdir . '/plagiarismlib.php');
            plagiarism_get_form_elements_module($mform, $ctx->get_course_context(), 'mod_assign');
        }

        $this->standard_grading_coursemodule_elements();
        $name = get_string('blindmarking', 'assign');
        $mform->addElement('selectyesno', 'blindmarking', $name);
        $mform->addHelpButton('blindmarking', 'blindmarking', 'assign');
        if ($assignment->has_submissions_or_grades() ) {
            $mform->freeze('blindmarking');
        }

        $name = get_string('hidegrader', 'assign');
        $mform->addElement('selectyesno', 'hidegrader', $name);
        $mform->addHelpButton('hidegrader', 'hidegrader', 'assign');

        $name = get_string('markingworkflow', 'assign');
        $mform->addElement('selectyesno', 'markingworkflow', $name);
        $mform->addHelpButton('markingworkflow', 'markingworkflow', 'assign');

        $name = get_string('markingallocation', 'assign');
        $mform->addElement('selectyesno', 'markingallocation', $name);
        $mform->addHelpButton('markingallocation', 'markingallocation', 'assign');
        $mform->hideIf('markingallocation', 'markingworkflow', 'eq', 0);

        $this->standard_coursemodule_elements();
        $this->apply_admin_defaults();

        $this->add_action_buttons();
    }
379564
public static function type_config_form($mform, $classname = 'repository') {
        $instnaceoptions = call_user_func(array($classname, 'get_instance_option_names'), $mform, $classname);
        if (empty($instnaceoptions)) {
            // this plugin has only one instance
            // so we need to give it a name
            // it can be empty, then moodle will look for instance name from language string
            $mform->addElement('text', 'pluginname', get_string('pluginname', 'repository'), array('size' => '40'));
            $mform->addElement('static', 'pluginnamehelp', '', get_string('pluginnamehelp', 'repository'));
            $mform->setType('pluginname', PARAM_TEXT);
        }
    }
1032895
public function add_config_field_to_form(\MoodleQuickForm $mform, $key) {
        $tour = $this->get_tour();

        $default = (bool) $tour->get_config($key);

        $options = [
            true    => get_string('yes'),
            false   => get_string('no'),
        ];

        if (!isset($options[$default])) {
            $default = configuration::get_default_value($key);
        }

        $options = array_reverse($options, true);
        $options[configuration::TOURDEFAULT] = get_string('defaultvalue', 'tool_usertours', $options[$default]);
        $options = array_reverse($options, true);

        $mform->addElement('select', $key, get_string($key, 'tool_usertours'), $options);
        $mform->setDefault($key, configuration::TOURDEFAULT);
        $mform->addHelpButton($key, $key, 'tool_usertours');

        return $this;
    }
39602
public function instance_form_definition(\MoodleQuickForm $mform) {
        $field = $this->get_field();
        $config = $field->get('configdata');
        $options = field_controller::get_options_array($field);
        $formattedoptions = array();
        $context = $this->get_field()->get_handler()->get_configuration_context();
        foreach ($options as $key => $option) {
            // Multilang formatting with filters.
            $formattedoptions[$key] = format_string($option, true, ['context' => $context]);
        }

        $elementname = $this->get_form_element_name();
        $mform->addElement('select', $elementname, $this->get_field()->get_formatted_name(), $formattedoptions);

        if (($defaultkey = array_search($config['defaultvalue'], $options)) !== false) {
            $mform->setDefault($elementname, $defaultkey);
        }
        if ($field->get_configdata_property('required')) {
            $mform->addRule($elementname, null, 'required', null, 'client');
        }
    }
660756
public function edit_field_set_default($mform) {
        $key = $this->field->defaultdata;
        if (isset($this->options[$key]) || ($key = array_search($key, $this->options)) !== false){
            $defaultkey = $key;
        } else {
            $defaultkey = '';
        }
        $mform->setDefault($this->inputname, $defaultkey);
    }
43350
public function setupForm(&$mform) {
        $choices = array('' => get_string('anyvalue', 'filters')) + $this->_options;
        $mform->addElement('select', $this->_name, $this->_label, $choices);
        if ($this->_advanced) {
            $mform->setAdvanced($this->_name);
        }
    }
702742
public static function type_config_form($mform, $classname = 'repository') {
        global $CFG;
        parent::type_config_form($mform);

        $clientid = get_config('boxnet', 'clientid');
        $clientsecret = get_config('boxnet', 'clientsecret');
        $strrequired = get_string('required');

        $mform->addElement('text', 'clientid', get_string('clientid', 'repository_boxnet'),
            array('value' => $clientid, 'size' => '40'));
        $mform->addRule('clientid', $strrequired, 'required', null, 'client');
        $mform->setType('clientid', PARAM_RAW_TRIMMED);

        $mform->addElement('text', 'clientsecret', get_string('clientsecret', 'repository_boxnet'),
            array('value' => $clientsecret, 'size' => '40'));
        $mform->addRule('clientsecret', $strrequired, 'required', null, 'client');
        $mform->setType('clientsecret', PARAM_RAW_TRIMMED);

        $mform->addElement('static', null, '',  get_string('information', 'repository_boxnet'));

        if (!is_https()) {
            $mform->addElement('static', null, '',  get_string('warninghttps', 'repository_boxnet'));
        }
    }
831404
public function edit_field_add($mform) {
        // Create the form field.
        $mform->addElement('editor', $this->inputname, format_string($this->field->name), null, null);
        $mform->setType($this->inputname, PARAM_RAW); // We MUST clean this before display!
    }
248712
protected function definition_inner($mform) {
        $strquestionlabel = $this->qtypeobj->comment_header($this->nonemptyanswer);
        $label = get_string("sharedwildcards", "qtype_calculated");
        $mform->addElement('hidden', 'synchronize', 0);
        $mform->addElement('hidden', 'initialcategory', 1);
        $mform->setType('synchronize', PARAM_BOOL);
        $mform->setType('initialcategory', PARAM_INT);
        $mform->addElement('hidden', 'reload', 1);
        $mform->setType('reload', PARAM_INT);
        $addfieldsname = 'updatequestion value';
        $addstring = get_string("updatecategory", "qtype_calculated");
        $mform->registerNoSubmitButton($addfieldsname);

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

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

        $label = "<div class='mdl-align'></div><div class='mdl-align'>" .
                get_string('wildcardrole', 'qtype_calculatedsimple') . "</div>";
        $mform->addElement('html', "<div class='mdl-align'>&nbsp;</div>");
        // Explaining the role of datasets so other strings can be shortened.
        $mform->addElement('html', $label);

        $mform->addElement('submit', 'analyzequestion',
                get_string('findwildcards', 'qtype_calculatedsimple'));
        $mform->registerNoSubmitButton('analyzequestion');
        $mform->closeHeaderBefore('analyzequestion');
        $this->wizarddisplay = optional_param('analyzequestion', false, PARAM_BOOL);
        if ($this->maxnumber != -1) {
            $this->noofitems = $this->maxnumber;
        } else {
            $this->noofitems = 0;
        }
        if (!empty($this->datasetdefs)) {// So there are some datadefs.
            // We put them on the page.
            $key = 0;
            $mform->addElement('header', 'additemhdr',
                    get_string('wildcardparam', 'qtype_calculatedsimple'));
            $idx = 1;
            if (!empty($this->datasetdefs)) {// Unnecessary test.
                $j = (($this->noofitems) * count($this->datasetdefs))+1;//
                foreach ($this->datasetdefs as $defkey => $datasetdef) {
                    $mform->addElement('static', "na[{$j}]",
                            get_string('param', 'qtype_calculated', $datasetdef->name));
                    $this->qtypeobj->custom_generator_tools_part($mform, $idx, $j);
                    $mform->addElement('hidden', "datasetdef[{$idx}]");
                    $mform->setType("datasetdef[{$idx}]", PARAM_RAW);
                    $mform->addElement('hidden', "defoptions[{$idx}]");
                    $mform->setType("defoptions[{$idx}]", PARAM_RAW);
                    $idx++;
                    $mform->addElement('static', "divider[{$j}]", '', '<hr />');
                    $j++;
                }
            }
            // This should be done before the elements are created and stored as $this->formdata.
            // Fill out all data sets and also the fields for the next item to add.
            /*Here we do already the values error analysis so that
             * we could force all wild cards values display if there is an error in values.
             * as using a , in a number */
            $this->numbererrors = array();
            if (!empty($this->datasetdefs)) {
                $j = $this->noofitems * count($this->datasetdefs);
                for ($itemnumber = $this->noofitems; $itemnumber >= 1; $itemnumber--) {
                    $data = array();
                    $numbererrors = '';
                    $comment = new stdClass();
                    $comment->stranswers = array();
                    $comment->outsidelimit = false;
                    $comment->answers = array();

                    foreach ($this->datasetdefs as $defid => $datasetdef) {
                        if (isset($datasetdef->items[$itemnumber])) {
                            $this->formdata["definition[{$j}]"] = $defid;
                            $this->formdata["itemid[{$j}]"] =
                                    $datasetdef->items[$itemnumber]->id;
                            $data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value;
                            $this->formdata["number[{$j}]"] = $number =
                                    $datasetdef->items[$itemnumber]->value;
                            if (! is_numeric($number)) {
                                $a = new stdClass();
                                $a->name = '{'.$datasetdef->name.'}';
                                $a->value = $datasetdef->items[$itemnumber]->value;
                                if (stristr($number, ',')) {
                                    $this->numbererrors["number[{$j}]"] =
                                            get_string('nocommaallowed', 'qtype_calculated');
                                    $numbererrors .= $this->numbererrors['number['.$j.']']."<br />";

                                } else {
                                    $this->numbererrors["number[{$j}]"] =
                                            get_string('notvalidnumber', 'qtype_calculated', $a);
                                    $numbererrors .= $this->numbererrors['number['.$j.']']."<br />";
                                }
                            } else if (stristr($number, 'x')) { // Hexa will pass the test.
                                $a = new stdClass();
                                $a->name = '{'.$datasetdef->name.'}';
                                $a->value = $datasetdef->items[$itemnumber]->value;
                                $this->numbererrors['number['.$j.']'] =
                                        get_string('hexanotallowed', 'qtype_calculated', $a);
                                $numbererrors .= $this->numbererrors['number['.$j.']']."<br />";
                            } else if (is_nan($number)) {
                                $a = new stdClass();
                                $a->name = '{'.$datasetdef->name.'}';
                                $a->value = $datasetdef->items[$itemnumber]->value;
                                $this->numbererrors["number[{$j}]"] =
                                        get_string('notvalidnumber', 'qtype_calculated', $a);
                                $numbererrors .= $this->numbererrors['number['.$j.']']."<br />";
                            }
                        }
                        $j--;
                    }
                    if ($this->noofitems != 0) {
                        if (empty($numbererrors)) {
                            if (!isset($this->question->id)) {
                                $this->question->id = 0;
                            }
                            $this->question->questiontext = !empty($this->question->questiontext) ?
                                    $this->question->questiontext : '';
                            $comment = $this->qtypeobj->comment_on_datasetitems(
                                    $this->qtypeobj, $this->question->id,
                                    $this->question->questiontext, $this->nonemptyanswer,
                                    $data, $itemnumber);
                            if ($comment->outsidelimit) {
                                $this->outsidelimit = $comment->outsidelimit;
                            }
                            $totalcomment = '';

                            foreach ($this->nonemptyanswer as $key => $answer) {
                                $totalcomment .= $comment->stranswers[$key].'<br/>';
                            }

                            $this->formdata['answercomment['.$itemnumber.']'] = $totalcomment;
                        }
                    }
                }
                $this->formdata['selectdelete'] = '1';
                $this->formdata['selectadd'] = '1';
                $j = $this->noofitems * count($this->datasetdefs)+1;
                $data = array(); // Data for comment_on_datasetitems later.
                $idx = 1;
                foreach ($this->datasetdefs as $defid => $datasetdef) {
                    $this->formdata["datasetdef[{$idx}]"] = $defid;
                    $idx++;
                }
                $this->formdata = $this->qtypeobj->custom_generator_set_data(
                        $this->datasetdefs, $this->formdata);
            }

            $addoptions = Array();
            $addoptions['1'] = '1';
            for ($i = 10; $i <= 100; $i += 10) {
                $addoptions["{$i}"] = "{$i}";
            }
            $showoptions = Array();
            $showoptions['1'] = '1';
            $showoptions['2'] = '2';
            $showoptions['5'] = '5';
            for ($i = 10; $i <= 100; $i += 10) {
                $showoptions["{$i}"] = "{$i}";
            }
            $mform->closeHeaderBefore('additemhdr');
            $addgrp = array();
            $addgrp[] = $mform->createElement('submit', 'addbutton',
                    get_string('generatenewitemsset', 'qtype_calculatedsimple'));
            $addgrp[] = $mform->createElement('select', "selectadd", '', $addoptions);
            $addgrp[] = $mform->createElement('static', "stat", '',
                    get_string('newsetwildcardvalues', 'qtype_calculatedsimple'));
            $mform->addGroup($addgrp, 'addgrp', '', '   ', false);
            $mform->registerNoSubmitButton('addbutton');
            $mform->closeHeaderBefore('addgrp');
            $addgrp1 = array();
            $addgrp1[] = $mform->createElement('submit', 'showbutton',
                    get_string('showitems', 'qtype_calculatedsimple'));
            $addgrp1[] = $mform->createElement('select', "selectshow", '', $showoptions);
            $addgrp1[] = $mform->createElement('static', "stat", '',
                    get_string('setwildcardvalues', 'qtype_calculatedsimple'));
            $mform->addGroup($addgrp1, 'addgrp1', '', '   ', false);
            $mform->registerNoSubmitButton('showbutton');
            $mform->closeHeaderBefore('addgrp1');
            $mform->addElement('static', "divideradd", '', '');
            if ($this->noofitems == 0) {
                $mform->addElement('static', 'warningnoitems', '', '<span class="error">' .
                        get_string('youmustaddatleastonevalue', 'qtype_calculatedsimple') .
                        '</span>');
                $mform->closeHeaderBefore('warningnoitems');
            } else {
                $mform->addElement('header', 'additemhdr1',
                        get_string('wildcardvalues', 'qtype_calculatedsimple'));
                $mform->closeHeaderBefore('additemhdr1');
                if (!empty($this->numbererrors) || $this->outsidelimit) {
                    $mform->addElement('static', "alert", '', '<span class="error">' .
                            get_string('useadvance', 'qtype_calculatedsimple').'</span>');
                }

                $mform->addElement('submit', 'updatedatasets',
                        get_string('updatewildcardvalues', 'qtype_calculatedsimple'));
                $mform->registerNoSubmitButton('updatedatasets');
                $mform->setAdvanced("updatedatasets", true);

                // ...--------------------------------------------------------------.
                $j = $this->noofitems * count($this->datasetdefs);
                $k = optional_param('selectshow', 1, PARAM_INT);

                for ($i = $this->noofitems; $i >= 1; $i--) {
                    foreach ($this->datasetdefs as $defkey => $datasetdef) {
                        if ($k > 0 ||  $this->outsidelimit || !empty($this->numbererrors)) {
                            $mform->addElement('float', "number[{$j}]", get_string(
                                    'wildcard', 'qtype_calculatedsimple', $datasetdef->name));
                            $mform->setAdvanced("number[{$j}]", true);
                            if (!empty($this->numbererrors['number['.$j.']'])) {
                                $mform->addElement('static', "numbercomment[{$j}]", '',
                                        '<span class="error">' .
                                        $this->numbererrors['number['.$j.']'] . '</span>');
                                $mform->setAdvanced("numbercomment[{$j}]", true);
                            }
                        } else {
                            $mform->addElement('hidden', "number[{$j}]", '');
                            $mform->setType("number[{$j}]", PARAM_LOCALISEDFLOAT); // Localisation handling has to be done manually.
                            if (isset($this->formdata["number[{$j}]"])) {
                                $number = $this->formdata["number[{$j}]"];
                                $this->formdata["number[{$j}]"] = format_float($number, strlen($number), true, true);
                            }
                        }

                        $mform->addElement('hidden', "itemid[{$j}]");
                        $mform->setType("itemid[{$j}]", PARAM_INT);

                        $mform->addElement('hidden', "definition[{$j}]");
                        $mform->setType("definition[{$j}]", PARAM_NOTAGS);

                        $j--;
                    }
                    if (!empty($strquestionlabel) && ($k > 0 ||  $this->outsidelimit ||
                            !empty($this->numbererrors))) {
                        $mform->addElement('static', "answercomment[{$i}]", "<b>" .
                                get_string('setno', 'qtype_calculatedsimple', $i) .
                                "</b>&nbsp;&nbsp;" . $strquestionlabel);

                    }
                    if ($k > 0 ||  $this->outsidelimit || !empty($this->numbererrors)) {
                        $mform->addElement('static', "divider1[{$j}]", '', '<hr />');

                    }
                    $k--;
                }
            }
        } else {
            $mform->addElement('static', 'warningnowildcards', '', '<span class="error">' .
                    get_string('atleastonewildcard', 'qtype_calculatedsimple') . '</span>');
            $mform->closeHeaderBefore('warningnowildcards');
        }

        // ...----------------------------------------------------------------------.
        // Non standard name for button element needed so not using add_action_buttons.
        // Hidden elements.

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        $mform->addElement('hidden', 'courseid');
        $mform->setType('courseid', PARAM_INT);
        $mform->setDefault('courseid', 0);

        $mform->addElement('hidden', 'cmid');
        $mform->setType('cmid', PARAM_INT);
        $mform->setDefault('cmid', 0);
        if (!empty($this->question->id)) {
            if ($this->question->formoptions->cansaveasnew) {
                $mform->addElement('header', 'additemhdr',
                        get_string('converttocalculated', 'qtype_calculatedsimple'));
                $mform->closeHeaderBefore('additemhdr');

                $mform->addElement('checkbox', 'convert', '',
                        get_string('willconverttocalculated', 'qtype_calculatedsimple'));
                $mform->setDefault('convert', 0);

            }
        }
    }
514950
public function add_all_plugin_settings(MoodleQuickForm $mform) {
        $mform->addElement('header', 'submissiontypes', get_string('submissiontypes', 'assign'));

        $submissionpluginsenabled = array();
        $group = $mform->addGroup(array(), 'submissionplugins', get_string('submissiontypes', 'assign'), array(' '), false);
        foreach ($this->submissionplugins as $plugin) {
            $this->add_plugin_settings($plugin, $mform, $submissionpluginsenabled);
        }
        $group->setElements($submissionpluginsenabled);

        $mform->addElement('header', 'feedbacktypes', get_string('feedbacktypes', 'assign'));
        $feedbackpluginsenabled = array();
        $group = $mform->addGroup(array(), 'feedbackplugins', get_string('feedbacktypes', 'assign'), array(' '), false);
        foreach ($this->feedbackplugins as $plugin) {
            $this->add_plugin_settings($plugin, $mform, $feedbackpluginsenabled);
        }
        $group->setElements($feedbackpluginsenabled);
        $mform->setExpanded('submissiontypes');
    }
549800
protected function definition_inner(&$mform) {
        $workshop   = $this->_customdata['workshop'];
        $fields     = $this->_customdata['fields'];
        $current    = $this->_customdata['current'];
        $nodims     = $this->_customdata['nodims'];     // number of assessment dimensions

        // get the number of required grid columns
        $levelcounts = array();
        for ($i = 0; $i < $nodims; $i++) {
            if ($fields->{'numoflevels__idx_'.$i} > 0) {
                $levelcounts[] = $fields->{'numoflevels__idx_'.$i};
            }
        }
        $numofcolumns = array_reduce($levelcounts, 'workshop::lcm', 1);

        $mform->addElement('header', 'rubric-grid-wrapper', get_string('layoutgrid', 'workshopform_rubric'));

        $mform->addElement('html', '<table class="rubric-grid">' . "\n");
        $mform->addElement('html', '<th class="header">' . get_string('criteria', 'workshopform_rubric') . '</th>');
        $mform->addElement('html', '<th class="header" colspan="'.$numofcolumns.'">'.get_string('levels', 'workshopform_rubric').'</th>');

        for ($i = 0; $i < $nodims; $i++) {

            $mform->addElement('html', '<tr class="r'. $i % 2  .'"><td class="criterion">' . "\n");

            // dimension id
            $mform->addElement('hidden', 'dimensionid__idx_'.$i, $fields->{'dimensionid__idx_'.$i});
            $mform->setType('dimensionid__idx_'.$i, PARAM_INT);

            // given grade id
            $mform->addElement('hidden', 'gradeid__idx_'.$i);   // value set by set_data() later
            $mform->setType('gradeid__idx_'.$i, PARAM_INT);

            // dimension description
            $desc = format_text($fields->{'description__idx_'.$i}, $fields->{'description__idx_'.$i.'format'});
            $desc .= "</td>\n";
            $mform->addElement('html', $desc);

            $numoflevels = $fields->{'numoflevels__idx_'.$i};
            for ($j = 0; $j < $numoflevels; $j++) {
                $colspan = $numofcolumns / $numoflevels;
                $mform->addElement('html', '<td class="level c' . $j % 2  . '" colspan="' . $colspan . '">' . "\n");
                $levelid = $fields->{'levelid__idx_'.$i.'__idy_'.$j};
                $definition = $fields->{'definition__idx_'.$i.'__idy_'.$j};
                $definitionformat = $fields->{'definition__idx_'.$i.'__idy_'.$j.'format'};
                $mform->addElement('radio', 'chosenlevelid__idx_'.$i, '',
                        format_text($definition, $definitionformat, null, $workshop->course->id), $levelid);
                $mform->addElement('html', '</td>' . "\n");
            }
            $mform->addElement('html', '</tr>' . "\n");
        }
        $mform->addElement('html', '</table>' . "\n");

        $this->set_data($current);
    }
1129482
public function setupForm(&$mform) {
        $objs = array();
        $objs['select'] = $mform->createElement('select', $this->_name.'_op', null, $this->getOperators());
        $objs['text'] = $mform->createElement('text', $this->_name, null);
        $objs['select']->setLabel(get_string('limiterfor', 'filters', $this->_label));
        $objs['text']->setLabel(get_string('valuefor', 'filters', $this->_label));
        $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false);
        $mform->setType($this->_name, PARAM_RAW);
        $mform->disabledIf($this->_name, $this->_name.'_op', 'eq', 5);
        if ($this->_advanced) {
            $mform->setAdvanced($this->_name.'_grp');
        }
        $mform->setDefault($this->_name.'_op', 2);
    }
965030
public function config_form_definition(\MoodleQuickForm $mform) {

        $mform->addElement('header', 'header_specificsettings', get_string('specificsettings', 'customfield_text'));
        $mform->setExpanded('header_specificsettings', true);

        $mform->addElement('text', 'configdata[defaultvalue]', get_string('defaultvalue', 'core_customfield'),
            ['size' => 50]);
        $mform->setType('configdata[defaultvalue]', PARAM_TEXT);

        $mform->addElement('text', 'configdata[displaysize]', get_string('displaysize', 'customfield_text'), ['size' => 6]);
        $mform->setType('configdata[displaysize]', PARAM_INT);
        $mform->setDefault('configdata[displaysize]', 50);
        $mform->addRule('configdata[displaysize]', null, 'numeric', null, 'client');

        $mform->addElement('text', 'configdata[maxlength]', get_string('maxlength', 'customfield_text'), ['size' => 6]);
        $mform->setType('configdata[maxlength]', PARAM_INT);
        $mform->setDefault('configdata[maxlength]', 1333);
        $mform->addRule('configdata[maxlength]', null, 'numeric', null, 'client');

        $mform->addElement('selectyesno', 'configdata[ispassword]', get_string('ispassword', 'customfield_text'));
        $mform->setType('configdata[ispassword]', PARAM_INT);

        $mform->addElement('text', 'configdata[link]', get_string('islink', 'customfield_text'), ['size' => 50]);
        $mform->setType('configdata[link]', PARAM_RAW_TRIMMED);
        $mform->addHelpButton('configdata[link]', 'islink', 'customfield_text');

        $mform->disabledIf('configdata[link]', 'configdata[ispassword]', 'eq', 1);

        $linkstargetoptions = array(
            ''       => get_string('none', 'customfield_text'),
            '_blank' => get_string('newwindow', 'customfield_text'),
            '_self'  => get_string('sameframe', 'customfield_text'),
            '_top'   => get_string('samewindow', 'customfield_text')
        );
        $mform->addElement('select', 'configdata[linktarget]', get_string('linktarget', 'customfield_text'),
            $linkstargetoptions);

        $mform->disabledIf('configdata[linktarget]', 'configdata[link]', 'eq', '');
    }
471268
public static function instance_config_form($mform) {
        if (!has_capability('moodle/site:config', context_system::instance())) {
            $mform->addElement('static', null, '',  get_string('nopermissions', 'error', get_string('configplugin',
                'repository_nextcloud')));
            return false;
        }

        // Load configured issuers.
        $issuers = core\oauth2\api::get_all_issuers();
        $types = array();

        // Validates which issuers implement the right endpoints. WebDav is necessary for Nextcloud.
        $validissuers = [];
        foreach ($issuers as $issuer) {
            $types[$issuer->get('id')] = $issuer->get('name');
            if (\repository_nextcloud\issuer_management::is_valid_issuer($issuer)) {
                $validissuers[] = $issuer->get('name');
            }
        }

        // Render the form.
        $url = new \moodle_url('/admin/tool/oauth2/issuers.php');
        $mform->addElement('static', null, '', get_string('oauth2serviceslink', 'repository_nextcloud', $url->out()));

        $mform->addElement('select', 'issuerid', get_string('chooseissuer', 'repository_nextcloud'), $types);
        $mform->addRule('issuerid', get_string('required'), 'required', null, 'issuer');
        $mform->addHelpButton('issuerid', 'chooseissuer', 'repository_nextcloud');
        $mform->setType('issuerid', PARAM_INT);

        // All issuers that are valid are displayed seperately (if any).
        if (count($validissuers) === 0) {
            $mform->addElement('static', null, '', get_string('no_right_issuers', 'repository_nextcloud'));
        } else {
            $mform->addElement('static', null, '', get_string('right_issuers', 'repository_nextcloud',
                implode(', ', $validissuers)));
        }

        $mform->addElement('text', 'controlledlinkfoldername', get_string('foldername', 'repository_nextcloud'));
        $mform->addHelpButton('controlledlinkfoldername', 'foldername', 'repository_nextcloud');
        $mform->setType('controlledlinkfoldername', PARAM_TEXT);
        $mform->setDefault('controlledlinkfoldername', 'Moodlefiles');

        $mform->addElement('static', null, '', get_string('fileoptions', 'repository_nextcloud'));
        $choices = [
            'both' => get_string('both', 'repository_nextcloud'),
            'internal' => get_string('internal', 'repository_nextcloud'),
            'external' => get_string('external', 'repository_nextcloud'),
        ];
        $mform->addElement('select', 'supportedreturntypes', get_string('supportedreturntypes', 'repository_nextcloud'), $choices);

        $choices = [
            FILE_INTERNAL => get_string('internal', 'repository_nextcloud'),
            FILE_CONTROLLED_LINK => get_string('external', 'repository_nextcloud'),
        ];
        $mform->addElement('select', 'defaultreturntype', get_string('defaultreturntype', 'repository_nextcloud'), $choices);
    }