本文整理汇总了PHP中MoodleQuickForm类的典型用法代码示例。如果您正苦于以下问题:PHP MoodleQuickForm类的具体用法?PHP MoodleQuickForm怎么用?PHP MoodleQuickForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MoodleQuickForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* Add question-type specific form fields.
*
* @param MoodleQuickForm $mform the form being built.
*/
function definition_inner(&$mform)
{
//don't need these default elements :
$mform->removeElement('defaultgrade');
$mform->removeElement('penalty');
$mform->addElement('hidden', 'defaultgrade', 0);
}
示例2: add_disabled_constraints_to_form
/**
* Add the disabledIf values.
*
* @param MoodleQuickForm $mform The form to add configuration to.
*/
public static function add_disabled_constraints_to_form(\MoodleQuickForm $mform)
{
$myvalue = \tool_usertours\target::get_target_constant_for_class(get_class());
foreach (array_keys(self::$forcedsettings) as $settingname) {
$mform->disabledIf($settingname, 'targettype', 'eq', $myvalue);
}
}
示例3: mform_autocomplete
/**
* Add autocomplete to a form text field
*
* @param MoodleQuickForm $mform Moodle form
* @param array|moodle_url $options Array of autocomplete options, if $hiddenfieldname is
* passed, array indexes are considered record IDs
* @param string $textfieldname The text field's name
* @param string $hiddenfieldname The hidden field's name. If passed,
* the option index will be set to this hidden
* value when its option value is selected in
* the text field
* @param string $width The pixel width of the text field (Due to YUI, must
* use width instead of size)
* @return void
* @link http://developer.yahoo.com/yui/examples/autocomplete/ac_basic_array.html What you get with no $hiddenfieldname
* @link http://developer.yahoo.com/yui/examples/autocomplete/ac_itemselect.html What you get with $hiddenfieldname
*/
public function mform_autocomplete($mform, $options, $textfieldname, $hiddenfieldname = '', $width = '300')
{
global $PAGE;
$url = NULL;
$data = NULL;
// Generate data source
if ($options instanceof moodle_url) {
$url = $options->out(false);
} else {
$data = array();
foreach ($options as $optionid => $option) {
if (empty($hiddenfieldname)) {
$data[] = $option;
} else {
$data[] = (object) array('text' => $option, 'id' => $optionid);
}
}
}
$fields = array('text');
if (!empty($hiddenfieldname)) {
$fields[] = 'id';
}
$module = array('name' => 'local_mr_framework', 'fullpath' => '/local/mr/framework/assets/javascript.js', 'requires' => array('yui2-yahoo', 'yui2-dom', 'yui2-event', 'yui2-datasource', 'yui2-json', 'yui2-connection', 'yui2-get', 'yui2-animation', 'yui2-autocomplete'));
$arguments = array((object) array('fieldname' => $textfieldname, 'hiddenfieldname' => $hiddenfieldname, 'width' => $width, 'url' => $url, 'data' => $data, 'fields' => $fields));
$PAGE->requires->js_init_call('M.local_mr.init_mr_html_autocomplete', $arguments, true, $module);
// $PAGE->requires->css('/lib/yui/2.8.1/build/autocomplete/assets/autocomplete-core.css');
// $PAGE->requires->css('/lib/yui/2.8.1/build/autocomplete/assets/skins/sam/autocomplete.css');
// Update form - need to force some attributes and add the javascript
$mform->updateElementAttr($textfieldname, array('autocomplete' => 'off', 'style' => "width: {$width}px;"));
// Add ID to hidden field so javascript can find it
if (!empty($hiddenfieldname)) {
$mform->updateElementAttr($hiddenfieldname, array('id' => "id_{$hiddenfieldname}"));
}
}
示例4: 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');
}
示例5: definition_inner
/**
* Add question-type specific form fields.
*
* @param MoodleQuickForm $mform the form being built.
*/
protected function definition_inner($mform)
{
// We don't need this default element.
$mform->removeElement('defaultmark');
$mform->addElement('hidden', 'defaultmark', 0);
$mform->setType('defaultmark', PARAM_RAW);
}
示例6: get_form_elements
/**
* Get form elements for grading form
*
* @param stdClass $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)
{
$fileoptions = $this->get_file_options();
$gradeid = $grade ? $grade->id : 0;
$data = file_prepare_standard_filemanager($data, 'files', $fileoptions, $this->assignment->get_context(), 'assignfeedback_file', ASSIGNFEEDBACK_FILE_FILEAREA, $gradeid);
$mform->addElement('filemanager', 'files_filemanager', '', null, $fileoptions);
return true;
}
示例7: other_preference_fields
protected function other_preference_fields(MoodleQuickForm $mform) {
if (quiz_has_grades($this->_customdata['quiz'])) {
$mform->addElement('selectyesno', 'slotmarks',
get_string('showdetailedmarks', 'quiz_overview'));
} else {
$mform->addElement('hidden', 'slotmarks', 0);
}
}
示例8: add_preflight_check_form_fields
public function add_preflight_check_form_fields(mod_quiz_preflight_check_form $quizform, MoodleQuickForm $mform, $attemptid)
{
$mform->addElement('header', 'passwordheader', get_string('password'));
$mform->addElement('static', 'passwordmessage', '', get_string('requirepasswordmessage', 'quizaccess_password'));
// Don't use the 'proper' field name of 'password' since that get's
// Firefox's password auto-complete over-excited.
$mform->addElement('password', 'quizpassword', get_string('quizpassword', 'quizaccess_password'), array('autofocus' => 'true'));
}
示例9: array
/**
* @param MoodleQuickForm $mform
*/
function add_submit_buttons($mform)
{
$buttons = array();
$buttons[] =& $mform->createElement('submit', 'submitbutton', get_string('filter', 'local_mr'));
$buttons[] =& $mform->createElement('submit', 'resetbutton', get_string('reset', 'local_mr'));
$mform->addGroup($buttons, 'buttons', '', array(' '), false);
$mform->registerNoSubmitButton('reset');
}
示例10: 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);
}
示例11: create_cell_element
/**
* Create the form element used to define the weight of the cell
*
* @param MoodleQuickForm $form
* @param int $row row number
* @param int $col column number
* @return object
*/
public function create_cell_element($form, $row, $col, $multiple)
{
$cell_name = $this->cell_name($row, $col, $multiple);
if ($multiple) {
return $form->createElement('checkbox', $cell_name, 'label');
} else {
return $form->createElement('radio', $cell_name, '', '', $col);
}
}
示例12: add_to_moodleform_testinput
public function add_to_moodleform_testinput(MoodleQuickForm $mform)
{
$values = $this->get_choices();
if (empty($values)) {
$mform->addElement('static', $this->name, stack_string('ddl_empty'));
} else {
$mform->addElement('select', $this->name, $this->name, $values);
}
}
示例13: array
/**
* Add question-type specific form fields.
*
* @param MoodleQuickForm $mform the form being built.
*/
function definition_inner(&$mform)
{
$menu = array(get_string('caseno', 'quiz'), get_string('caseyes', 'quiz'));
$mform->addElement('select', 'usecase', get_string('casesensitive', 'quiz'), $menu);
$mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'quiz'), get_string('filloutoneanswer', 'quiz'));
$mform->closeHeaderBefore('answersinstruct');
$creategrades = get_grade_options();
$this->add_per_answer_fields($mform, get_string('answerno', 'qtype_shortanswer', '{no}'), $creategrades->gradeoptions);
}
示例14: 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);
}
示例15: 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);
}