本文整理汇总了PHP中MoodleQuickForm::setAdvanced方法的典型用法代码示例。如果您正苦于以下问题:PHP MoodleQuickForm::setAdvanced方法的具体用法?PHP MoodleQuickForm::setAdvanced怎么用?PHP MoodleQuickForm::setAdvanced使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoodleQuickForm
的用法示例。
在下文中一共展示了MoodleQuickForm::setAdvanced方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_settings_form_fields
public static function add_settings_form_fields(mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
{
$config = get_config('quizaccess_offlinemode');
$mform->addElement('selectyesno', 'offlinemode_enabled', get_string('offlinemodeenabled', 'quizaccess_offlinemode'));
$mform->addHelpButton('offlinemode_enabled', 'offlinemodeenabled', 'quizaccess_offlinemode');
$mform->setDefault('offlinemode_enabled', !empty($config->defaultenabled));
$mform->setAdvanced('offlinemode_enabled', !empty($config->defaultenabled_adv));
foreach (question_engine::get_behaviour_options(null) as $behaviour => $notused) {
if (!self::is_compatible_behaviour($behaviour)) {
$mform->disabledIf('offlinemode_enabled', 'preferredbehaviour', 'eq', $behaviour);
}
}
}
示例2: setupForm
/**
* Adds controls specific to this filter in the form.
*
* @param moodleform $mform a MoodleQuickForm object in which element will be added
*/
public function setupForm(MoodleQuickForm &$mform)
{
$objs = array();
$objs[] = $mform->createElement('checkbox', $this->_name, null, '');
$grp = $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
if ($this->_advanced) {
$mform->setAdvanced($this->_name . '_grp');
}
//Check if disable if options are set. if yes then set rules
if (!empty($this->disableelements) && is_array($this->disableelements)) {
foreach ($this->disableelements as $disableelement) {
$mform->disabledIf($disableelement, $this->_name, 'checked');
}
}
}
示例3: add_element
/**
* Add filter form element
*
* @param MoodleQuickForm $mform Filter form
* @return mr_html_filter_abstract
*/
public function add_element($mform)
{
//add div and empty unordered list to the form
$ieshim = '<div class="selectmultiplus-ieshim">.</div>';
$mform->addElement('static', $this->name . '_addedlist', $ieshim, '<div id="id_' . $this->name . '_addedlist" class="selectmultiplus"></div>');
// Add the select element setting multiple
$mform->addElement('select', $this->name, $this->label, $this->options, 'class="selectmultiplus"')->setMultiple(true);
// set the defaults
if ($defaults = $this->preferences_get($this->name)) {
$mform->setDefault($this->name, explode(',', $defaults));
}
if ($this->advanced) {
$mform->setAdvanced($this->name);
}
// add the input field for autocomplete
$mform->addElement('text', $this->name . '_autocomplete', $this->label, 'class="selectmultiplus"');
$mform->setType($this->name . '_autocomplete', PARAM_TEXT);
// initialize the javascript
$helper = new mr_helper();
$helper->html->filter_selectmultiplus_init($this->name);
return $this;
}
示例4: 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;
}
}
}
示例5: edit_instance_form
/**
* 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);
}
}
示例6: definition_inner
/**
* Add question-type specific form fields.
*
* @param MoodleQuickForm $mform the form being built.
*/
protected function definition_inner($mform)
{
global $CFG, $OUTPUT, $SESSION;
require_once $CFG->dirroot . '/question/type/regexp/locallib.php';
$this->showalternate = false;
if ("" != optional_param('showalternate', '', PARAM_RAW)) {
$this->showalternate = true;
$this->questionid = optional_param('id', '', PARAM_NOTAGS);
$this->usecase = optional_param('usecase', '', PARAM_NOTAGS);
$this->studentshowalternate = optional_param('studentshowalternate', '', PARAM_NOTAGS);
$this->fraction = optional_param_array('fraction', '', PARAM_RAW);
$this->currentanswers = optional_param_array('answer', '', PARAM_NOTAGS);
//$this->feedback = optional_param('feedback', '', PARAM_NOTAGS);
// no longer works in moodle 2.2 and later see http://moodle.org/mod/forum/discuss.php?d=197118
// so use data_submitted() instead
$feedback = data_submitted()->feedback;
// we only need to get the feedback text, for validation purposes when showalternate is requested
foreach ($feedback as $key => $fb) {
$this->feedback[$key]['text'] = clean_param($fb['text'], PARAM_NOTAGS);
}
}
// JR added advanced settings to hide mostly unwanted hints and tags settings
if ("" != optional_param('addhint', '', PARAM_RAW)) {
$this->hints = optional_param('hint', '', PARAM_NOTAGS);
} elseif (isset($this->question->hints)) {
$this->hints = $this->question->hints;
}
$counthints = 0;
if (isset($this->hints)) {
$counthints = count($this->hints);
}
$mform->setAdvanced('tags');
for ($i = 0; $i < $counthints; $i++) {
$mform->setAdvanced("hint[{$i}]");
}
// hint mode :: None / Letter / Word
$menu = array(get_string('none'), get_string('letter', 'qtype_regexp'), get_string('word', 'qtype_regexp'));
$mform->addElement('select', 'usehint', get_string('usehint', 'qtype_regexp'), $menu);
$mform->addHelpButton('usehint', 'usehint', 'qtype_regexp');
// use case :: yes / no
$menu = array(get_string('caseno', 'qtype_regexp'), get_string('caseyes', 'qtype_regexp'));
$mform->addElement('select', 'usecase', get_string('casesensitive', 'qtype_regexp'), $menu);
// display all correct alternate answers to student on review page :: yes / no
$menu = array(get_string('no'), get_string('yes'));
$mform->addElement('select', 'studentshowalternate', get_string('studentshowalternate', 'qtype_regexp'), $menu);
$mform->addHelpButton('studentshowalternate', 'studentshowalternate', 'qtype_regexp');
//$mform->closeHeaderBefore('answersinstruct');
$mform->addElement('static', 'answersinstruct', 'Note.-', get_string('filloutoneanswer', 'qtype_regexp'));
$this->add_per_answer_fields($mform, get_string('answerno', 'qtype_shortanswer', '{no}'), question_bank::fraction_options(), $minoptions = 3, $addoptions = 1);
$mform->addElement('header', 'showhidealternate', get_string('showhidealternate', 'qtype_regexp'));
$mform->addHelpButton('showhidealternate', 'showhidealternate', 'qtype_regexp');
$buttonarray = array();
$buttonarray[] = $mform->createElement('submit', 'showalternate', get_string('showalternate', 'qtype_regexp'));
$mform->registerNoSubmitButton('showalternate');
if ($this->showalternate) {
$qu = new stdClass();
$qu->id = $this->questionid;
$qu->answers = array();
$i = 0;
$this->fraction[0] = 1;
$data = array();
foreach ($this->currentanswers as $key => $answer) {
$qu->answers[$i] = new stdClass();
$qu->answers[$i]->answer = $answer;
$qu->answers[$i]->fraction = $this->fraction[$i];
// for sending $data to validation
$data['answer'][$i] = $answer;
$data['fraction'][$i] = $this->fraction[$i];
$data['feedback'][$i] = $this->feedback[$i];
$i++;
}
$moodle_val = $this->validation($data, '');
if (is_array($moodle_val) && count($moodle_val) !== 0) {
// non-empty array means errors
foreach ($moodle_val as $element => $msg) {
$mform->setElementError($element, $msg);
}
// set to false in order to set hidealternate button to disabled
$this->showalternate = false;
} else {
// we need to unset SESSION in case Answers have been edited since last call to get_alternateanswers()
if (isset($SESSION->qtype_regexp_question->alternateanswers[$this->questionid])) {
unset($SESSION->qtype_regexp_question->alternateanswers[$this->questionid]);
}
$alternateanswers = get_alternateanswers($qu);
$mform->addElement('html', '<div class="alternateanswers">');
$alternatelist = '';
foreach ($alternateanswers as $key => $alternateanswer) {
$mform->addElement('static', 'alternateanswer', get_string('answer') . ' ' . $key . ' (' . $alternateanswer['fraction'] . ')', '<span class="regexp">' . $alternateanswer['regexp'] . '</span>');
$list = '';
foreach ($alternateanswer['answers'] as $alternate) {
$list .= '<li>' . $alternate . '</li>';
}
$mform->addElement('static', 'alternateanswer', '', '<ul class="square">' . $list . '</ul>');
}
//.........这里部分代码省略.........
示例7: add_settings_form_fields
public static function add_settings_form_fields(mod_quiz_mod_form $quizform, MoodleQuickForm $mform)
{
global $CFG;
// Allow to enable the access rule only if the Mobile services are enabled.
if ($CFG->enablemobilewebservice) {
$mform->addElement('selectyesno', 'allowofflineattempts', get_string('allowofflineattempts', 'quizaccess_offlineattempts'));
$mform->addHelpButton('allowofflineattempts', 'allowofflineattempts', 'quizaccess_offlineattempts');
$mform->setDefault('allowofflineattempts', 0);
$mform->setAdvanced('allowofflineattempts');
$mform->disabledIf('allowofflineattempts', 'timelimit[number]', 'neq', 0);
$mform->disabledIf('allowofflineattempts', 'subnet', 'neq', '');
}
}