/** * Get form elements for the grading page * * @param stdClass|null $grade * @param MoodleQuickForm $mform * @param stdClass $data * @return bool true if elements were added to the form */ public function get_form_elements($grade, MoodleQuickForm $mform, stdClass $data) { $choices = get_string_manager()->get_list_of_countries(); $choices = array('' => get_string('selectacountry') . '...') + $choices; $mform->addElement('select', 'country', 'Country for E-signature', $choices); $mform->addElement('static', 'description', '', get_string('savechanges', 'assignfeedback_esign')); $mform->setDefault('country', 'SE'); $mform->addRule('country', get_string('selectacountry'), 'required', '', 'client', false, false); return true; }
/** * Add elements to the edit instance form. * * @param stdClass $instance * @param MoodleQuickForm $mform * @param context $context * @return bool */ public function edit_instance_form($instance, MoodleQuickForm $mform, $context) { global $CFG; // Merge these two settings to one value for the single selection element. if ($instance->notifyall and $instance->expirynotify) { $instance->expirynotify = 2; } unset($instance->notifyall); $nameattribs = array('size' => '20', 'maxlength' => '255'); $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'), $nameattribs); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server'); $options = $this->get_status_options(); $mform->addElement('select', 'status', get_string('status', 'enrol_self'), $options); $mform->addHelpButton('status', 'status', 'enrol_self'); $options = $this->get_newenrols_options(); $mform->addElement('select', 'customint6', get_string('newenrols', 'enrol_self'), $options); $mform->addHelpButton('customint6', 'newenrols', 'enrol_self'); $mform->disabledIf('customint6', 'status', 'eq', ENROL_INSTANCE_DISABLED); $passattribs = array('size' => '20', 'maxlength' => '50'); $mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_self'), $passattribs); $mform->addHelpButton('password', 'password', 'enrol_self'); if (empty($instance->id) and $this->get_config('requirepassword')) { $mform->addRule('password', get_string('required'), 'required', null, 'client'); } $mform->addRule('password', get_string('maximumchars', '', 50), 'maxlength', 50, 'server'); $options = $this->get_groupkey_options(); $mform->addElement('select', 'customint1', get_string('groupkey', 'enrol_self'), $options); $mform->addHelpButton('customint1', 'groupkey', 'enrol_self'); $roles = $this->extend_assignable_roles($context, $instance->roleid); $mform->addElement('select', 'roleid', get_string('role', 'enrol_self'), $roles); $options = array('optional' => true, 'defaultunit' => 86400); $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_self'), $options); $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_self'); $options = $this->get_expirynotify_options(); $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options); $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol'); $options = array('optional' => false, 'defaultunit' => 86400); $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options); $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol'); $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0); $options = array('optional' => true); $mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_self'), $options); $mform->setDefault('enrolstartdate', 0); $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_self'); $options = array('optional' => true); $mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_self'), $options); $mform->setDefault('enrolenddate', 0); $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_self'); $options = $this->get_longtimenosee_options(); $mform->addElement('select', 'customint2', get_string('longtimenosee', 'enrol_self'), $options); $mform->addHelpButton('customint2', 'longtimenosee', 'enrol_self'); $mform->addElement('text', 'customint3', get_string('maxenrolled', 'enrol_self')); $mform->addHelpButton('customint3', 'maxenrolled', 'enrol_self'); $mform->setType('customint3', PARAM_INT); require_once $CFG->dirroot . '/cohort/lib.php'; $cohorts = array(0 => get_string('no')); $allcohorts = cohort_get_available_cohorts($context, 0, 0, 0); if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) { $c = $DB->get_record('cohort', array('id' => $instance->customint5), 'id, name, idnumber, contextid, visible', IGNORE_MISSING); if ($c) { // Current cohort was not found because current user can not see it. Still keep it. $allcohorts[$instance->customint5] = $c; } } foreach ($allcohorts as $c) { $cohorts[$c->id] = format_string($c->name, true, array('context' => context::instance_by_id($c->contextid))); if ($c->idnumber) { $cohorts[$c->id] .= ' [' . s($c->idnumber) . ']'; } } if ($instance->customint5 && !isset($allcohorts[$instance->customint5])) { // Somebody deleted a cohort, better keep the wrong value so that random ppl can not enrol. $cohorts[$instance->customint5] = get_string('unknowncohort', 'cohort', $instance->customint5); } if (count($cohorts) > 1) { $mform->addElement('select', 'customint5', get_string('cohortonly', 'enrol_self'), $cohorts); $mform->addHelpButton('customint5', 'cohortonly', 'enrol_self'); } else { $mform->addElement('hidden', 'customint5'); $mform->setType('customint5', PARAM_INT); $mform->setConstant('customint5', 0); } $mform->addElement('advcheckbox', 'customint4', get_string('sendcoursewelcomemessage', 'enrol_self')); $mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_self'); $options = array('cols' => '60', 'rows' => '8'); $mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'enrol_self'), $options); $mform->addHelpButton('customtext1', 'customwelcomemessage', 'enrol_self'); if (enrol_accessing_via_instance($instance)) { $warntext = get_string('instanceeditselfwarningtext', 'core_enrol'); $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), $warntext); } }
/** * Add elements to submission form. * @param MoodleQuickForm $mform * @param stdClass $data * @return void */ public function add_submission_form_elements(MoodleQuickForm $mform, stdClass $data) { global $USER; // Team submissions. if ($this->get_instance()->teamsubmission) { $submission = $this->get_group_submission($USER->id, 0, false); } else { $submission = $this->get_user_submission($USER->id, false); } // Submission statement. $adminconfig = $this->get_admin_config(); $requiresubmissionstatement = $this->get_instance()->requiresubmissionstatement && !empty($adminconfig->submissionstatement); $draftsenabled = $this->get_instance()->submissiondrafts; if ($requiresubmissionstatement && !$draftsenabled) { $submissionstatement = ''; if (!empty($adminconfig->submissionstatement)) { $submissionstatement = $adminconfig->submissionstatement; } $mform->addElement('checkbox', 'submissionstatement', '', ' ' . $submissionstatement); $mform->addRule('submissionstatement', get_string('required'), 'required', null, 'client'); } $this->add_plugin_submission_elements($submission, $mform, $data, $USER->id); // Hidden params. $mform->addElement('hidden', 'id', $this->get_course_module()->id); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'action', 'savesubmission'); $mform->setType('action', PARAM_TEXT); }
/** * Add elements to submission form. * @param MoodleQuickForm $mform * @param stdClass $data * @return void */ public function add_submission_form_elements(MoodleQuickForm $mform, stdClass $data) { global $USER; $userid = $data->userid; // Team submissions. if ($this->get_instance()->teamsubmission) { $submission = $this->get_group_submission($userid, 0, false); } else { $submission = $this->get_user_submission($userid, false); } // Submission statement. $adminconfig = $this->get_admin_config(); $requiresubmissionstatement = $this->get_instance()->requiresubmissionstatement && !empty($adminconfig->submissionstatement); $draftsenabled = $this->get_instance()->submissiondrafts; // Only show submission statement if we are editing our own submission. if ($requiresubmissionstatement && !$draftsenabled && $userid == $USER->id) { $submissionstatement = ''; if (!empty($adminconfig->submissionstatement)) { // Format the submission statement before its sent. We turn off para because this is going within // a form element. $options = array('context' => $this->get_context(), 'para' => false); $submissionstatement = format_text($adminconfig->submissionstatement, FORMAT_MOODLE, $options); } $mform->addElement('checkbox', 'submissionstatement', '', $submissionstatement); $mform->addRule('submissionstatement', get_string('required'), 'required', null, 'client'); } $this->add_plugin_submission_elements($submission, $mform, $data, $userid); // Hidden params. $mform->addElement('hidden', 'id', $this->get_course_module()->id); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'userid', $userid); $mform->setType('userid', PARAM_INT); $mform->addElement('hidden', 'action', 'savesubmission'); $mform->setType('action', PARAM_TEXT); }
protected function form_choices(\MoodleQuickForm $mform, array $choices, $helpname = '') { $numchoices = count($choices); $allchoices = ''; foreach ($choices as $choice) { if (!empty($allchoices)) { $allchoices .= "\n"; } $allchoices .= $choice->content; } if (empty($helpname)) { $helpname = $this->helpname(); } $mform->addElement('html', '<div class="qoptcontainer">'); $options = array('wrap' => 'virtual', 'class' => 'qopts'); $mform->addElement('textarea', 'allchoices', get_string('possibleanswers', 'questionnaire'), $options); $mform->setType('allchoices', PARAM_RAW); $mform->addRule('allchoices', null, 'required', null, 'client'); $mform->addHelpButton('allchoices', $helpname, 'questionnaire'); $mform->addElement('html', '</div>'); $mform->addElement('hidden', 'num_choices', $numchoices); $mform->setType('num_choices', PARAM_INT); return $allchoices; }
/** * Add elements to the edit instance form. * * @param stdClass $instance * @param MoodleQuickForm $mform * @param context $coursecontext * @return bool */ public function edit_instance_form($instance, MoodleQuickForm $mform, $coursecontext) { global $DB; $courses = $this->get_course_options($instance, $coursecontext); $groups = $this->get_group_options($coursecontext); $mform->addElement('select', 'customint1', get_string('linkedcourse', 'enrol_meta'), $courses); $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); }
/** * Add elements to the edit instance form. * * @param stdClass $instance * @param MoodleQuickForm $mform * @param context $context * @return bool */ public function edit_instance_form($instance, MoodleQuickForm $mform, $context) { global $CFG; $options = $this->get_status_options(); $mform->addElement('select', 'status', get_string('status', 'enrol_guest'), $options); $mform->addHelpButton('status', 'status', 'enrol_guest'); $mform->setDefault('status', $this->get_config('status')); $mform->setAdvanced('status', $this->get_config('status_adv')); $mform->addElement('passwordunmask', 'password', get_string('password', 'enrol_guest')); $mform->addHelpButton('password', 'password', 'enrol_guest'); // If we have a new instance and the password is required - make sure it is set. For existing // instances we do not force the password to be required as it may have been set to empty before // the password was required. We check in the validation function whether this check is required // for existing instances. if (empty($instance->id) && $this->get_config('requirepassword')) { $mform->addRule('password', get_string('required'), 'required', null); } }
/** * Add elements to the edit instance form. * * @param stdClass $instance * @param MoodleQuickForm $mform * @param context $coursecontext * @return bool */ 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), '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); }
/** * Add elements to the edit instance form. * * @param stdClass $instance * @param MoodleQuickForm $mform * @param context $context * @return bool */ public function edit_instance_form($instance, MoodleQuickForm $mform, $context) { global $DB; $nameattribs = array('size' => '20', 'maxlength' => '255'); $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'), $nameattribs); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'server'); $tools = array(); $tools[$context->id] = get_string('course'); $modinfo = get_fast_modinfo($instance->courseid); $mods = $modinfo->get_cms(); foreach ($mods as $mod) { $tools[$mod->context->id] = format_string($mod->name); } $mform->addElement('select', 'contextid', get_string('tooltobeprovided', 'enrol_lti'), $tools); $mform->setDefault('contextid', $context->id); $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_lti'), array('optional' => true, 'defaultunit' => DAYSECS)); $mform->setDefault('enrolperiod', 0); $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_lti'); $mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_lti'), array('optional' => true)); $mform->setDefault('enrolstartdate', 0); $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_lti'); $mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_lti'), array('optional' => true)); $mform->setDefault('enrolenddate', 0); $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_lti'); $mform->addElement('text', 'maxenrolled', get_string('maxenrolled', 'enrol_lti')); $mform->setDefault('maxenrolled', 0); $mform->addHelpButton('maxenrolled', 'maxenrolled', 'enrol_lti'); $mform->setType('maxenrolled', PARAM_INT); $assignableroles = get_assignable_roles($context); $mform->addElement('select', 'roleinstructor', get_string('roleinstructor', 'enrol_lti'), $assignableroles); $mform->setDefault('roleinstructor', '3'); $mform->addHelpButton('roleinstructor', 'roleinstructor', 'enrol_lti'); $mform->addElement('select', 'rolelearner', get_string('rolelearner', 'enrol_lti'), $assignableroles); $mform->setDefault('rolelearner', '5'); $mform->addHelpButton('rolelearner', 'rolelearner', 'enrol_lti'); $mform->addElement('header', 'remotesystem', get_string('remotesystem', 'enrol_lti')); $mform->addElement('text', 'secret', get_string('secret', 'enrol_lti'), 'maxlength="64" size="25"'); $mform->setType('secret', PARAM_ALPHANUM); $mform->setDefault('secret', random_string(32)); $mform->addHelpButton('secret', 'secret', 'enrol_lti'); $mform->addRule('secret', get_string('required'), 'required'); $mform->addElement('selectyesno', 'gradesync', get_string('gradesync', 'enrol_lti')); $mform->setDefault('gradesync', 1); $mform->addHelpButton('gradesync', 'gradesync', 'enrol_lti'); $mform->addElement('selectyesno', 'gradesynccompletion', get_string('requirecompletion', 'enrol_lti')); $mform->setDefault('gradesynccompletion', 0); $mform->disabledIf('gradesynccompletion', 'gradesync', 0); $mform->addElement('selectyesno', 'membersync', get_string('membersync', 'enrol_lti')); $mform->setDefault('membersync', 1); $mform->addHelpButton('membersync', 'membersync', 'enrol_lti'); $options = array(); $options[\enrol_lti\helper::MEMBER_SYNC_ENROL_AND_UNENROL] = get_string('membersyncmodeenrolandunenrol', 'enrol_lti'); $options[\enrol_lti\helper::MEMBER_SYNC_ENROL_NEW] = get_string('membersyncmodeenrolnew', 'enrol_lti'); $options[\enrol_lti\helper::MEMBER_SYNC_UNENROL_MISSING] = get_string('membersyncmodeunenrolmissing', 'enrol_lti'); $mform->addElement('select', 'membersyncmode', get_string('membersyncmode', 'enrol_lti'), $options); $mform->setDefault('membersyncmode', \enrol_lti\helper::MEMBER_SYNC_ENROL_AND_UNENROL); $mform->addHelpButton('membersyncmode', 'membersyncmode', 'enrol_lti'); $mform->disabledIf('membersyncmode', 'membersync', 0); $mform->addElement('header', 'defaultheader', get_string('userdefaultvalues', 'enrol_lti')); $emaildisplay = get_config('enrol_lti', 'emaildisplay'); $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse')); $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices); $mform->setDefault('maildisplay', $emaildisplay); $city = get_config('enrol_lti', 'city'); $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"'); $mform->setType('city', PARAM_TEXT); $mform->setDefault('city', $city); $country = get_config('enrol_lti', 'country'); $countries = array('' => get_string('selectacountry') . '...') + get_string_manager()->get_list_of_countries(); $mform->addElement('select', 'country', get_string('selectacountry'), $countries); $mform->setDefault('country', $country); $mform->setAdvanced('country'); $timezone = get_config('enrol_lti', 'timezone'); $choices = core_date::get_list_of_timezones(null, true); $mform->addElement('select', 'timezone', get_string('timezone'), $choices); $mform->setDefault('timezone', $timezone); $mform->setAdvanced('timezone'); $lang = get_config('enrol_lti', 'lang'); $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations()); $mform->setDefault('lang', $lang); $mform->setAdvanced('lang'); $institution = get_config('enrol_lti', 'institution'); $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"'); $mform->setType('institution', core_user::get_property_type('institution')); $mform->setDefault('institution', $institution); $mform->setAdvanced('institution'); // Check if we are editing an instance. if (!empty($instance->id)) { // Get the details from the enrol_lti_tools table. $ltitool = $DB->get_record('enrol_lti_tools', array('enrolid' => $instance->id), '*', MUST_EXIST); $mform->addElement('hidden', 'toolid'); $mform->setType('toolid', PARAM_INT); $mform->setConstant('toolid', $ltitool->id); $mform->setDefaults((array) $ltitool); } }
/** * Add elements to submission form * * @param mixed $submission stdClass|null * @param MoodleQuickForm $mform * @param stdClass $data * @return bool */ public function get_form_elements($submission, MoodleQuickForm $mform, stdClass $data) { global $DB; if ($this->get_config('maxfilesubmissions') <= 0) { return false; } $fileoptions = $this->get_file_options(); $submissionid = $submission ? $submission->id : 0; $context = $this->assignment->get_context(); $fs = get_file_storage(); $coversheetfiles = $fs->get_area_files($context->id, 'assignsubmission_pdf', ASSIGNSUBMISSION_PDF_FA_COVERSHEET, false, '', false); if ($coversheetfiles) { $file = reset($coversheetfiles); $fileurl = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $file->get_filename()); $filelink = html_writer::link($fileurl, $file->get_filename(), array('target' => '_blank')); $mform->addElement('static', 'pdf_coversheet', '', get_string('coversheetnotice', 'assignsubmission_pdf') . ': ' . $filelink); } file_prepare_standard_filemanager($data, 'pdfs', $fileoptions, $this->assignment->get_context(), 'assignsubmission_pdf', ASSIGNSUBMISSION_PDF_FA_DRAFT, $submissionid); $label = html_writer::tag('span', get_string('pdfsubmissions', 'assignsubmission_pdf'), array('class' => 'accesshide')); $mform->addElement('filemanager', 'pdfs_filemanager', $label, null, $fileoptions); if ($coversheetfiles) { if ($templateid = $this->get_config('templateid')) { $templateitems = $DB->get_records('assignsubmission_pdf_tmplit', array('templateid' => $templateid)); $templatedata = array(); if ($submissionid) { if ($templatedata = $DB->get_field('assignsubmission_pdf', 'templatedata', array('submission' => $submissionid))) { $templatedata = unserialize($templatedata); } } foreach ($templateitems as $item) { $elname = "pdf_template[{$item->id}]"; if ($item->type == 'shorttext') { $mform->addElement('text', $elname, s($item->setting)); } else { if ($item->type == 'text') { $mform->addElement('textarea', $elname, s($item->setting)); } else { continue; } } $mform->setType($elname, PARAM_TEXT); $mform->addRule($elname, null, 'required', null, 'client'); if (isset($templatedata[$item->id])) { $mform->setDefault($elname, $templatedata[$item->id]); } } } } return true; }
/** * 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); }
/** * Add elements to the edit instance form. * * @param stdClass $instance * @param MoodleQuickForm $mform * @param context $context * @return bool */ public function edit_instance_form($instance, MoodleQuickForm $mform, $context) { global $CFG; $hosts = $this->get_valid_hosts_options(); $mform->addElement('select', 'customint1', get_string('remotesubscriber', 'enrol_mnet'), $hosts); $mform->addHelpButton('customint1', 'remotesubscriber', 'enrol_mnet'); $mform->addRule('customint1', get_string('required'), 'required', null, 'client'); $roles = $this->get_valid_roles_options($context); $mform->addElement('select', 'roleid', get_string('roleforremoteusers', 'enrol_mnet'), $roles); $mform->addHelpButton('roleid', 'roleforremoteusers', 'enrol_mnet'); $mform->addRule('roleid', get_string('required'), 'required', null, 'client'); $mform->setDefault('roleid', $this->get_config('roleid')); $mform->addElement('text', 'name', get_string('instancename', 'enrol_mnet')); $mform->addHelpButton('name', 'instancename', 'enrol_mnet'); $mform->setType('name', PARAM_TEXT); }
/** * Add elements to the edit instance form. * * @param stdClass $instance * @param MoodleQuickForm $mform * @param context $coursecontext * @return bool */ public function edit_instance_form($instance, MoodleQuickForm $mform, $coursecontext) { global $DB; $mform->addElement('text', 'name', get_string('custominstancename', 'enrol')); $mform->setType('name', PARAM_TEXT); $options = $this->get_status_options(); $mform->addElement('select', 'status', get_string('status', 'enrol_cohort'), $options); $options = $this->get_cohort_options($instance, $coursecontext); $mform->addElement('select', 'customint1', get_string('cohort', 'cohort'), $options); if ($instance->id) { $mform->setConstant('customint1', $instance->customint1); $mform->hardFreeze('customint1', $instance->customint1); } else { $mform->addRule('customint1', get_string('required'), 'required', null, 'client'); } $roles = $this->get_role_options($instance, $coursecontext); $mform->addElement('select', 'roleid', get_string('assignrole', 'enrol_cohort'), $roles); $mform->setDefault('roleid', $this->get_config('roleid')); $groups = $this->get_group_options($coursecontext); $mform->addElement('select', 'customint2', get_string('addgroup', 'enrol_cohort'), $groups); }