本文整理汇总了PHP中quiz_access_manager::add_settings_form_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP quiz_access_manager::add_settings_form_fields方法的具体用法?PHP quiz_access_manager::add_settings_form_fields怎么用?PHP quiz_access_manager::add_settings_form_fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quiz_access_manager
的用法示例。
在下文中一共展示了quiz_access_manager::add_settings_form_fields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
//.........这里部分代码省略.........
}
$mform->addElement('select', 'decimalpoints', get_string('decimalplaces', 'quiz'), $options);
$mform->addHelpButton('decimalpoints', 'decimalplaces', 'quiz');
$mform->setAdvanced('decimalpoints', $quizconfig->decimalpoints_adv);
$mform->setDefault('decimalpoints', $quizconfig->decimalpoints);
// Question decimal points.
$options = array(-1 => get_string('sameasoverall', 'quiz'));
for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) {
$options[$i] = $i;
}
$mform->addElement('select', 'questiondecimalpoints', get_string('decimalplacesquestion', 'quiz'), $options);
$mform->addHelpButton('questiondecimalpoints', 'decimalplacesquestion', 'quiz');
$mform->setAdvanced('questiondecimalpoints', $quizconfig->questiondecimalpoints_adv);
$mform->setDefault('questiondecimalpoints', $quizconfig->questiondecimalpoints);
// Show blocks during quiz attempt.
$mform->addElement('selectyesno', 'showblocks', get_string('showblocks', 'quiz'));
$mform->addHelpButton('showblocks', 'showblocks', 'quiz');
$mform->setAdvanced('showblocks', $quizconfig->showblocks_adv);
$mform->setDefault('showblocks', $quizconfig->showblocks);
// -------------------------------------------------------------------------------
$mform->addElement('header', 'security', get_string('extraattemptrestrictions', 'quiz'));
// Require password to begin quiz attempt.
$mform->addElement('passwordunmask', 'quizpassword', get_string('requirepassword', 'quiz'));
$mform->setType('quizpassword', PARAM_TEXT);
$mform->addHelpButton('quizpassword', 'requirepassword', 'quiz');
$mform->setAdvanced('quizpassword', $quizconfig->password_adv);
$mform->setDefault('quizpassword', $quizconfig->password);
// IP address.
$mform->addElement('text', 'subnet', get_string('requiresubnet', 'quiz'));
$mform->setType('subnet', PARAM_TEXT);
$mform->addHelpButton('subnet', 'requiresubnet', 'quiz');
$mform->setAdvanced('subnet', $quizconfig->subnet_adv);
$mform->setDefault('subnet', $quizconfig->subnet);
// Enforced time delay between quiz attempts.
$mform->addElement('duration', 'delay1', get_string('delay1st2nd', 'quiz'), array('optional' => true));
$mform->addHelpButton('delay1', 'delay1st2nd', 'quiz');
$mform->setAdvanced('delay1', $quizconfig->delay1_adv);
$mform->setDefault('delay1', $quizconfig->delay1);
if ($this->get_max_attempts_for_any_override() < 2) {
$mform->disabledIf('delay1', 'attempts', 'eq', 1);
}
$mform->addElement('duration', 'delay2', get_string('delaylater', 'quiz'), array('optional' => true));
$mform->addHelpButton('delay2', 'delaylater', 'quiz');
$mform->setAdvanced('delay2', $quizconfig->delay2_adv);
$mform->setDefault('delay2', $quizconfig->delay2);
if ($this->get_max_attempts_for_any_override() < 3) {
$mform->disabledIf('delay2', 'attempts', 'eq', 1);
$mform->disabledIf('delay2', 'attempts', 'eq', 2);
}
// Browser security choices.
$mform->addElement('select', 'browsersecurity', get_string('browsersecurity', 'quiz'), quiz_access_manager::get_browser_security_choices());
$mform->addHelpButton('browsersecurity', 'browsersecurity', 'quiz');
$mform->setAdvanced('browsersecurity', $quizconfig->browsersecurity_adv);
$mform->setDefault('browsersecurity', $quizconfig->browsersecurity);
// Any other rule plugins.
quiz_access_manager::add_settings_form_fields($this, $mform);
// -------------------------------------------------------------------------------
$mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'quiz'));
$mform->addHelpButton('overallfeedbackhdr', 'overallfeedback', 'quiz');
if (isset($this->current->grade)) {
$needwarning = $this->current->grade === 0;
} else {
$needwarning = $quizconfig->maximumgrade == 0;
}
if ($needwarning) {
$mform->addElement('static', 'nogradewarning', '', get_string('nogradewarning', 'quiz'));
}
$mform->addElement('static', 'gradeboundarystatic1', get_string('gradeboundary', 'quiz'), '100%');
$repeatarray = array();
$repeatedoptions = array();
$repeatarray[] = $mform->createElement('editor', 'feedbacktext', get_string('feedback', 'quiz'), array('rows' => 3), array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $this->context));
$repeatarray[] = $mform->createElement('text', 'feedbackboundaries', get_string('gradeboundary', 'quiz'), array('size' => 10));
$repeatedoptions['feedbacktext']['type'] = PARAM_RAW;
$repeatedoptions['feedbackboundaries']['type'] = PARAM_RAW;
if (!empty($this->_instance)) {
$this->_feedbacks = $DB->get_records('quiz_feedback', array('quizid' => $this->_instance), 'mingrade DESC');
} else {
$this->_feedbacks = array();
}
$numfeedbacks = max(count($this->_feedbacks) * 1.5, 5);
$nextel = $this->repeat_elements($repeatarray, $numfeedbacks - 1, $repeatedoptions, 'boundary_repeats', 'boundary_add_fields', 3, get_string('addmoreoverallfeedbacks', 'quiz'), true);
// Put some extra elements in before the button.
$mform->insertElementBefore($mform->createElement('editor', "feedbacktext[{$nextel}]", get_string('feedback', 'quiz'), array('rows' => 3), array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $this->context)), 'boundary_add_fields');
$mform->insertElementBefore($mform->createElement('static', 'gradeboundarystatic2', get_string('gradeboundary', 'quiz'), '0%'), 'boundary_add_fields');
// Add the disabledif rules. We cannot do this using the $repeatoptions parameter to
// repeat_elements because we don't want to dissable the first feedbacktext.
for ($i = 0; $i < $nextel; $i++) {
$mform->disabledIf('feedbackboundaries[' . $i . ']', 'grade', 'eq', 0);
$mform->disabledIf('feedbacktext[' . ($i + 1) . ']', 'grade', 'eq', 0);
}
// -------------------------------------------------------------------------------
$this->standard_coursemodule_elements();
// Check and act on whether setting outcomes is considered an advanced setting.
$mform->setAdvanced('modoutcomes', !empty($quizconfig->outcomes_adv));
// The standard_coursemodule_elements method sets this to 100, but the
// quiz has its own setting, so use that.
$mform->setDefault('grade', $quizconfig->maximumgrade);
// -------------------------------------------------------------------------------
$this->add_action_buttons();
}