本文整理汇总了PHP中MoodleQuickForm::hardFreeze方法的典型用法代码示例。如果您正苦于以下问题:PHP MoodleQuickForm::hardFreeze方法的具体用法?PHP MoodleQuickForm::hardFreeze怎么用?PHP MoodleQuickForm::hardFreeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoodleQuickForm
的用法示例。
在下文中一共展示了MoodleQuickForm::hardFreeze方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moodleform
/**
* The constructor function calls the abstract function definition() and it will then
* process and clean and attempt to validate incoming data.
*
* It will call your custom validate method to validate data and will also check any rules
* you have specified in definition using addRule
*
* The name of the form (id attribute of the form) is automatically generated depending on
* the name you gave the class extending moodleform. You should call your class something
* like
*
* @param mixed $action the action attribute for the form. If empty defaults to auto detect the
* current url. If a moodle_url object then outputs params as hidden variables.
* @param array $customdata if your form defintion method needs access to data such as $course
* $cm, etc. to construct the form definition then pass it in this array. You can
* use globals for somethings.
* @param string $method if you set this to anything other than 'post' then _GET and _POST will
* be merged and used as incoming data to the form.
* @param string $target target frame for form submission. You will rarely use this. Don't use
* it if you don't need to as the target attribute is deprecated in xhtml
* strict.
* @param mixed $attributes you can pass a string of html attributes here or an array.
* @return moodleform
*/
function moodleform($action = null, $customdata = null, $method = 'post', $target = '', $attributes = null, $editable = true)
{
if (empty($action)) {
$action = strip_querystring(qualified_me());
}
$this->_formname = get_class($this);
// '_form' suffix kept in order to prevent collisions of form id and other element
$this->_customdata = $customdata;
$this->_form =& new MoodleQuickForm($this->_formname, $method, $action, $target, $attributes);
if (!$editable) {
$this->_form->hardFreeze();
}
$this->set_upload_manager(new upload_manager());
$this->definition();
$this->_form->addElement('hidden', 'sesskey', null);
// automatic sesskey protection
$this->_form->setType('sesskey', PARAM_RAW);
$this->_form->setDefault('sesskey', sesskey());
$this->_form->addElement('hidden', '_qf__' . $this->_formname, null);
// form submission marker
$this->_form->setType('_qf__' . $this->_formname, PARAM_RAW);
$this->_form->setDefault('_qf__' . $this->_formname, 1);
$this->_form->_setDefaultRuleMessages();
// we have to know all input types before processing submission ;-)
$this->_process_submission($method);
}
示例2: add_grade_form_elements
/**
* Add elements to grade form.
*
* @param MoodleQuickForm $mform
* @param stdClass $data
* @param array $params
* @return void
*/
public function add_grade_form_elements(MoodleQuickForm $mform, stdClass $data, $params)
{
global $USER, $CFG;
$settings = $this->get_instance();
$rownum = $params['rownum'];
$last = $params['last'];
$useridlistid = $params['useridlistid'];
$userid = $params['userid'];
$attemptnumber = $params['attemptnumber'];
if (!$userid) {
$cache = cache::make_from_params(cache_store::MODE_SESSION, 'mod_assign', 'useridlist');
if (!($useridlist = $cache->get($this->get_course_module()->id . '_' . $useridlistid))) {
$useridlist = $this->get_grading_userid_list();
$cache->set($this->get_course_module()->id . '_' . $useridlistid, $useridlist);
}
} else {
$useridlist = array($userid);
$rownum = 0;
$useridlistid = '';
}
$userid = $useridlist[$rownum];
$grade = $this->get_user_grade($userid, false, $attemptnumber);
$submission = null;
if ($this->get_instance()->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, false, $attemptnumber);
} else {
$submission = $this->get_user_submission($userid, false, $attemptnumber);
}
// Add advanced grading.
$gradingdisabled = $this->grading_disabled($userid);
$gradinginstance = $this->get_grading_instance($userid, $grade, $gradingdisabled);
$mform->addElement('header', 'gradeheader', get_string('grade'));
if ($gradinginstance) {
$gradingelement = $mform->addElement('grading', 'advancedgrading', get_string('grade') . ':', array('gradinginstance' => $gradinginstance));
if ($gradingdisabled) {
$gradingelement->freeze();
} else {
$mform->addElement('hidden', 'advancedgradinginstanceid', $gradinginstance->get_id());
$mform->setType('advancedgradinginstanceid', PARAM_INT);
}
} else {
// Use simple direct grading.
if ($this->get_instance()->grade > 0) {
$name = get_string('gradeoutof', 'assign', $this->get_instance()->grade);
if (!$gradingdisabled) {
$gradingelement = $mform->addElement('text', 'grade', $name);
$mform->addHelpButton('grade', 'gradeoutofhelp', 'assign');
$mform->setType('grade', PARAM_RAW);
} else {
$mform->addElement('hidden', 'grade', $name);
$mform->hardFreeze('grade');
$mform->setType('grade', PARAM_RAW);
$strgradelocked = get_string('gradelocked', 'assign');
$mform->addElement('static', 'gradedisabled', $name, $strgradelocked);
$mform->addHelpButton('gradedisabled', 'gradeoutofhelp', 'assign');
}
} else {
$grademenu = array(-1 => get_string("nograde")) + make_grades_menu($this->get_instance()->grade);
if (count($grademenu) > 1) {
$gradingelement = $mform->addElement('select', 'grade', get_string('grade') . ':', $grademenu);
// The grade is already formatted with format_float so it needs to be converted back to an integer.
if (!empty($data->grade)) {
$data->grade = (int) unformat_float($data->grade);
}
$mform->setType('grade', PARAM_INT);
if ($gradingdisabled) {
$gradingelement->freeze();
}
}
}
}
$gradinginfo = grade_get_grades($this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, $userid);
if (!empty($CFG->enableoutcomes)) {
foreach ($gradinginfo->outcomes as $index => $outcome) {
$options = make_grades_menu(-$outcome->scaleid);
if ($outcome->grades[$userid]->locked) {
$options[0] = get_string('nooutcome', 'grades');
$mform->addElement('static', 'outcome_' . $index . '[' . $userid . ']', $outcome->name . ':', $options[$outcome->grades[$userid]->grade]);
} else {
$options[''] = get_string('nooutcome', 'grades');
$attributes = array('id' => 'menuoutcome_' . $index);
$mform->addElement('select', 'outcome_' . $index . '[' . $userid . ']', $outcome->name . ':', $options, $attributes);
$mform->setType('outcome_' . $index . '[' . $userid . ']', PARAM_INT);
$mform->setDefault('outcome_' . $index . '[' . $userid . ']', $outcome->grades[$userid]->grade);
}
}
}
$capabilitylist = array('gradereport/grader:view', 'moodle/grade:viewall');
if (has_all_capabilities($capabilitylist, $this->get_course_context())) {
$urlparams = array('id' => $this->get_course()->id);
$url = new moodle_url('/grade/report/grader/index.php', $urlparams);
$usergrade = '-';
//.........这里部分代码省略.........
示例3: course_edit_form
/**
* Adds enrol instance UI to course edit form
*
* @param object $instance enrol instance or null if does not exist yet
* @param MoodleQuickForm $mform
* @param object $data
* @param object $context context of existing course or parent category if course does not exist
* @return void
*/
public function course_edit_form($instance, MoodleQuickForm $mform, $data, $context)
{
$i = isset($instance->id) ? $instance->id : 0;
if (!$i and !$this->get_config('defaultenrol')) {
return;
}
$header = $this->get_instance_name($instance);
$config = has_capability('enrol/guest:config', $context);
$mform->addElement('header', 'enrol_guest_header_' . $i, $header);
$options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
$mform->addElement('select', 'enrol_guest_status_' . $i, get_string('status', 'enrol_guest'), $options);
$mform->addHelpButton('enrol_guest_status_' . $i, 'status', 'enrol_guest');
$mform->setDefault('enrol_guest_status_' . $i, $this->get_config('status'));
$mform->setAdvanced('enrol_guest_status_' . $i, $this->get_config('status_adv'));
if (!$config) {
$mform->hardFreeze('enrol_guest_status_' . $i);
}
$mform->addElement('passwordunmask', 'enrol_guest_password_' . $i, get_string('password', 'enrol_guest'));
$mform->addHelpButton('enrol_guest_password_' . $i, 'password', 'enrol_guest');
if (!$config) {
$mform->hardFreeze('enrol_guest_password_' . $i);
} else {
$mform->disabledIf('enrol_guest_password_' . $i, 'enrol_guest_status_' . $i, 'noteq', ENROL_INSTANCE_ENABLED);
}
// now add all values from enrol table
if ($instance) {
foreach ($instance as $key => $val) {
$data->{'enrol_guest_' . $key . '_' . $i} = $val;
}
}
}
示例4: edit_instance_form
/**
* 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);
}