本文整理汇总了PHP中MoodleQuickForm::setDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP MoodleQuickForm::setDefault方法的具体用法?PHP MoodleQuickForm::setDefault怎么用?PHP MoodleQuickForm::setDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoodleQuickForm
的用法示例。
在下文中一共展示了MoodleQuickForm::setDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Add question-type specific form fields.
*
* @param MoodleQuickForm $mform the form being built.
*/
function definition_inner(&$mform)
{
$mform->addElement('header', 'globalvarshdr', get_string('globalvarshdr', 'qtype_coordinates'));
$mform->removeElement('defaultgrade');
$mform->addElement('hidden', 'defaultgrade');
$mform->setType('defaultgrade', PARAM_RAW);
$mform->removeElement('penalty');
$mform->addElement('hidden', 'penalty');
$mform->setType('penalty', PARAM_NUMBER);
$mform->setDefault('penalty', 0.1);
$mform->addElement('static', 'help_coordinates', get_string('help'), get_string('helponquestionoptions', 'qtype_coordinates'));
$mform->addElement('textarea', 'varsrandom', get_string('varsrandom', 'qtype_coordinates'), array('rows' => 4, 'cols' => 70, 'course' => $this->coursefilesid));
$mform->addElement('textarea', 'varsglobal', get_string('varsglobal', 'qtype_coordinates'), array('rows' => 6, 'cols' => 70, 'course' => $this->coursefilesid));
$mform->addElement('select', 'showperanswermark', get_string('showperanswermark', 'qtype_coordinates'), array(get_string('choiceno', 'qtype_coordinates'), get_string('choiceyes', 'qtype_coordinates')));
$mform->setDefault('showperanswermark', 1);
$mform->addElement('select', 'peranswersubmit', get_string('peranswersubmit', 'qtype_coordinates'), array(get_string('choiceno', 'qtype_coordinates'), get_string('choiceyes', 'qtype_coordinates')));
$mform->setDefault('peranswersubmit', 1);
$mform->addElement('text', 'retrymarkseq', get_string('retrymarkseq', 'qtype_coordinates'), array('size' => 30));
$show_group = array();
$show_group[] =& $mform->createElement('checkbox', 'vars2', '', get_string('vars2', 'qtype_coordinates'), 'onclick="coordinates_form_display(\'vars2\', this.checked)"');
$show_group[] =& $mform->createElement('checkbox', 'preunit', '', get_string('preunit', 'qtype_coordinates'), 'onclick="coordinates_form_display(\'preunit\', this.checked)"');
$show_group[] =& $mform->createElement('checkbox', 'otherrule', '', get_string('otherrule', 'qtype_coordinates'), 'onclick="coordinates_form_display(\'otherrule\', this.checked)"');
//$show_group[] =& $mform->createElement('checkbox','subqtext','',get_string('subqtext','qtype_coordinates'),
// 'onclick="coordinates_form_display(\'subqtext\', this.checked)"');
//$show_group[] =& $mform->createElement('checkbox','feedback','',get_string('feedback','qtype_coordinates'),
// 'onclick="coordinates_form_display(\'feedback\', this.checked)"');
$show_group[] =& $mform->createElement('checkbox', 'correctnessraw', '', get_string('correctnessraw', 'qtype_coordinates'), 'onclick="coordinates_form_correctness(this.checked)"');
$mform->addGroup($show_group, 'showoptions', get_string('showoptions', 'qtype_coordinates'), array(' '), true);
$creategrades = get_grade_options();
$this->add_per_answer_fields($mform, get_string('answerno', 'qtype_coordinates', '{no}'), $creategrades->gradeoptions, 1, 1);
}
示例2: array
/**
* Add question-type specific form fields.
*
* @param MoodleQuickForm $mform the form being built.
*/
function definition_inner(&$mform)
{
global $COURSE, $CFG;
// don't need these default elements :
$mform->removeElement('defaultgrade');
$mform->removeElement('penalty');
$mform->addElement('html', '<a target="_new" href="' . $CFG->wwwroot . '/files/index.php?id=' . $COURSE->id . '">' . get_string("openinnewwindow", "qtype_imagedit") . '</a>');
// this element will hold the URL of the HTML's IMG SRC value
// of the altered image file that was uploaded by the user
// to the current course's "users" folder
//$mform->addElement('hidden', 'imgurl', '');
// add feedback
$mform->addElement('htmleditor', 'feedback', get_string("feedback", "quiz"));
$mform->setType('feedback', PARAM_RAW);
// add default elements
$mform->addElement('hidden', 'defaultgrade', 0);
$mform->addElement('hidden', 'fraction', 0);
// add max upload limit menu
$choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
$choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')';
$mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices);
$mform->setDefault('maxbytes', $COURSE->maxbytes);
// add essay area checkbox
$mform->addElement('advcheckbox', 'essay', get_string('addessay', 'qtype_imagedit'), null, null, array(0, 1));
}
示例3: get_settings
/**
* Get the default setting for file submission plugin
*
* @param MoodleQuickForm $mform The form to add elements to
* @return void
*/
public function get_settings(MoodleQuickForm $mform)
{
global $CFG, $COURSE;
$defaultmaxfilesubmissions = $this->get_config('maxfilesubmissions');
$defaultmaxsubmissionsizebytes = $this->get_config('maxsubmissionsizebytes');
$settings = array();
$options = array();
for ($i = 1; $i <= ASSIGNSUBMISSION_FILE_MAXFILES; $i++) {
$options[$i] = $i;
}
$mform->addElement('select', 'assignsubmission_file_maxfiles', get_string('maxfilessubmission', 'assignsubmission_file'), $options);
$mform->addHelpButton('assignsubmission_file_maxfiles', 'maxfilessubmission', 'assignsubmission_file');
$mform->setDefault('assignsubmission_file_maxfiles', $defaultmaxfilesubmissions);
$mform->disabledIf('assignsubmission_file_maxfiles', 'assignsubmission_file_enabled', 'eq', 0);
$choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes, get_config('assignsubmission_file', 'maxbytes'));
// Remove the option for 0 bytes.
unset($choices[0]);
if ($COURSE->maxbytes == 0) {
$choices = array(0 => get_string('siteuploadlimit', 'assignsubmission_file')) + $choices;
} else {
$choices = array(0 => get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')') + $choices;
}
$settings[] = array('type' => 'select', 'name' => 'maxsubmissionsizebytes', 'description' => get_string('maximumsubmissionsize', 'assignsubmission_file'), 'options' => $choices, 'default' => $defaultmaxsubmissionsizebytes);
$mform->addElement('select', 'assignsubmission_file_maxsizebytes', get_string('maximumsubmissionsize', 'assignsubmission_file'), $choices);
$mform->addHelpButton('assignsubmission_file_maxsizebytes', 'maximumsubmissionsize', 'assignsubmission_file');
$mform->setDefault('assignsubmission_file_maxsizebytes', $defaultmaxsubmissionsizebytes);
$mform->disabledIf('assignsubmission_file_maxsizebytes', 'assignsubmission_file_enabled', 'eq', 0);
}
示例4: 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);
}
示例5: specific_definition
/**
* @param MoodleQuickForm $mform
*/
protected function specific_definition(MoodleQuickForm $mform)
{
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
$options = ['tree' => get_string('config_type_tree', 'block_activity_tree'), 'prev_next' => get_string('config_type_prev_next', 'block_activity_tree')];
$mform->addElement('select', 'config_type', get_string('config_type', 'block_activity_tree'), $options);
$mform->setDefault('config_type', 'tree');
}
示例6: add_elements
/**
* Add re-usable form elements for forum preferences
* @param MoodleQuickForm $mform
*/
public static function add_elements(&$mform)
{
global $CFG, $OUTPUT;
$mform->addElement('html', $OUTPUT->heading(get_string('forumsubscription', 'forumng'), 3));
$choices = array();
$choices['0'] = get_string('emaildigestoff');
$choices['1'] = get_string('emaildigestcomplete');
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', $CFG->defaultpreference_maildigest);
$mform->addHelpButton('maildigest', 'emaildigest');
$mform->addElement('html', html_writer::empty_tag('hr'));
$choices = array();
$choices['1'] = get_string('htmlformat');
$choices['0'] = get_string('textformat');
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('autosubscribe', $CFG->defaultpreference_mailformat);
}
示例7: specific_definition
/**
* Extends the standard instance config form with custom
* fields for moodletxt specifically
* @param MoodleQuickForm $form Form to extend
* @version 2011072201
* @since 2011072201
*/
protected function specific_definition($form)
{
// Section header title according to language file.
$form->addElement('header', 'configheader', get_string('headerinstanceconfig', 'block_moodletxt'));
// The title of the block
$form->addElement('text', 'config_title', get_string('labelblocktitle', 'block_moodletxt'));
$form->setDefault('config_title', get_string('blocktitle', 'block_moodletxt'));
$form->setType('config_title', PARAM_MULTILANG);
}
示例8: specific_definition
/**
* @param MoodleQuickForm $mform
*/
protected function specific_definition($mform)
{
// Section header title according to language file.
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
// A sample string variable with a default value.
$mform->addElement('text', 'config_text', get_string('blockstring', 'block_simplehtml'));
$mform->setDefault('config_text', 'default value');
$mform->setType('config_text', PARAM_RAW);
}
示例9: specific_definition
/**
* Builds the form to edit instance settings
*
* @param MoodleQuickForm $mform
*/
protected function specific_definition($mform)
{
// Section header title according to language file.
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
// Set the title for the block.
$mform->addElement('text', 'config_title', get_string('configtitle', 'block_filtered_course_list'));
$mform->setDefault('config_title', get_string('blockname', 'block_filtered_course_list'));
$mform->setType('config_title', PARAM_TEXT);
}
示例10: get_form_elements
/**
* 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;
}
示例11: add_filter_to_form
/**
* Add the form elements for the filter to the supplied form.
*
* @param MoodleQuickForm $mform The form to add filter settings to.
*/
public static function add_filter_to_form(\MoodleQuickForm &$mform)
{
$options = [static::ANYVALUE => get_string('all')];
$options += static::get_filter_options();
$filtername = static::get_filter_name();
$key = "filter_{$filtername}";
$mform->addElement('select', $key, get_string($key, 'tool_usertours'), $options, ['multiple' => true]);
$mform->setDefault($key, static::ANYVALUE);
$mform->addHelpButton($key, $key, 'tool_usertours');
}
示例12: standard_attempt_fields
protected function standard_attempt_fields(MoodleQuickForm $mform)
{
$mform->addElement('select', 'attempts', get_string('reportattemptsfrom', 'quiz'), array(quiz_attempts_report::ENROLLED_WITH => get_string('reportuserswith', 'quiz'), quiz_attempts_report::ENROLLED_WITHOUT => get_string('reportuserswithout', 'quiz'), quiz_attempts_report::ENROLLED_ALL => get_string('reportuserswithorwithout', 'quiz'), quiz_attempts_report::ALL_WITH => get_string('reportusersall', 'quiz')));
$stategroup = array($mform->createElement('advcheckbox', 'stateinprogress', '', get_string('stateinprogress', 'quiz')), $mform->createElement('advcheckbox', 'stateoverdue', '', get_string('stateoverdue', 'quiz')), $mform->createElement('advcheckbox', 'statefinished', '', get_string('statefinished', 'quiz')), $mform->createElement('advcheckbox', 'stateabandoned', '', get_string('stateabandoned', 'quiz')));
$mform->addGroup($stategroup, 'stateoptions', get_string('reportattemptsthatare', 'quiz'), array(' '), false);
$mform->setDefault('stateinprogress', 1);
$mform->setDefault('stateoverdue', 1);
$mform->setDefault('statefinished', 1);
$mform->setDefault('stateabandoned', 1);
$mform->disabledIf('stateinprogress', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
$mform->disabledIf('stateoverdue', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
$mform->disabledIf('statefinished', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
$mform->disabledIf('stateabandoned', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
if (quiz_report_can_filter_only_graded($this->_customdata['quiz'])) {
$gm = html_writer::tag('span', quiz_get_grading_option_name($this->_customdata['quiz']->grademethod), array('class' => 'highlight'));
$mform->addElement('advcheckbox', 'onlygraded', get_string('reportshowonly', 'quiz'), get_string('optonlygradedattempts', 'quiz_overview', $gm));
$mform->disabledIf('onlygraded', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
$mform->disabledIf('onlygraded', 'statefinished', 'notchecked');
}
}
示例13: specific_definition
/**
* @param MoodleQuickForm $mform
*/
protected function specific_definition($mform)
{
global $CFG;
$mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
$mods = array('enabledock' => 'yes');
$yesnooptions = array('yes' => get_string('yes'), 'no' => get_string('no'));
foreach ($mods as $modname => $default) {
$mform->addElement('select', 'config_' . $modname, get_string($modname . 'desc', $this->block->blockname), $yesnooptions);
$mform->setDefault('config_' . $modname, $default);
}
$options = array(block_navigation::TRIM_RIGHT => get_string('trimmoderight', $this->block->blockname), block_navigation::TRIM_LEFT => get_string('trimmodeleft', $this->block->blockname), block_navigation::TRIM_CENTER => get_string('trimmodecenter', $this->block->blockname));
$mform->addElement('select', 'config_trimmode', get_string('trimmode', $this->block->blockname), $options);
$mform->setType('config_trimmode', PARAM_INT);
$mform->addElement('text', 'config_trimlength', get_string('trimlength', $this->block->blockname));
$mform->setDefault('config_trimlength', 50);
$mform->setType('config_trimlength', PARAM_INT);
$options = array(0 => get_string('everything', $this->block->blockname), global_navigation::TYPE_COURSE => get_string('courses', $this->block->blockname), global_navigation::TYPE_SECTION => get_string('coursestructures', $this->block->blockname), global_navigation::TYPE_ACTIVITY => get_string('courseactivities', $this->block->blockname));
$mform->addElement('select', 'config_expansionlimit', get_string('expansionlimit', $this->block->blockname), $options);
$mform->setType('config_expansionlimit', PARAM_INT);
}
示例14: specific_definition
/**
* The definition of the fields to use.
*
* @param MoodleQuickForm $mform
*/
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);
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');
}
}
示例15: specific_definition
/**
* Creates form fields specific to this type of block.
*
* @param MoodleQuickForm $mform The pear quick form form being built.
*/
protected function specific_definition($mform)
{
// Create a fieldset with a legend
$mform->addElement('header', 'config_header', get_string('blocksettings', 'block'));
// Add an input text element to form
$mform->addElement('text', 'config_title', get_string('inconfblocktitlelabel', 'block_openveo_videos'));
// Add help button
$mform->addHelpButton('config_title', 'inconfblocktitlelabel', 'block_openveo_videos');
// Set input text default value
$mform->setDefault('config_title', get_string('inconfblocktitlelabel', 'block_openveo_videos'));
// Clean title to plain text while submitting
$mform->setType('config_title', PARAM_TEXT);
}