本文整理汇总了PHP中MoodleQuickForm::setType方法的典型用法代码示例。如果您正苦于以下问题:PHP MoodleQuickForm::setType方法的具体用法?PHP MoodleQuickForm::setType怎么用?PHP MoodleQuickForm::setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoodleQuickForm
的用法示例。
在下文中一共展示了MoodleQuickForm::setType方法的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: 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');
}
}
示例3: array
/**
* Add question-type specific form fields.
*
* @param MoodleQuickForm $mform the form being built.
*/
function definition_inner(&$mform)
{
global $QTYPES;
$this->qtypeobj =& $QTYPES[$this->qtype()];
$label = get_string("sharedwildcards", "qtype_datasetdependent");
$mform->addElement('hidden', 'initialcategory', 1);
$html2 = $this->qtypeobj->print_dataset_definitions_category($this->question);
$mform->insertElementBefore($mform->createElement('static', 'listcategory', $label, $html2), 'name');
$addfieldsname = 'updatecategory';
$addstring = get_string("updatecategory", "qtype_calculated");
$mform->registerNoSubmitButton($addfieldsname);
$mform->insertElementBefore($mform->createElement('submit', $addfieldsname, $addstring), 'listcategory');
$repeated = array();
$repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerhdr', 'qtype_calculated', '{no}'));
$repeated[] =& $mform->createElement('text', 'answers', get_string('correctanswerformula', 'quiz') . '=', array('size' => 50));
$repeatedoptions['answers']['type'] = PARAM_NOTAGS;
$creategrades = get_grade_options();
$gradeoptions = $creategrades->gradeoptions;
$repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions);
$repeatedoptions['fraction']['default'] = 0;
$repeated[] =& $mform->createElement('text', 'tolerance', get_string('tolerance', 'qtype_calculated'));
$repeatedoptions['tolerance']['type'] = PARAM_NUMBER;
$repeatedoptions['tolerance']['default'] = 0.01;
$repeated[] =& $mform->createElement('select', 'tolerancetype', get_string('tolerancetype', 'quiz'), $this->qtypeobj->tolerance_types());
$repeated[] =& $mform->createElement('select', 'correctanswerlength', get_string('correctanswershows', 'qtype_calculated'), range(0, 9));
$repeatedoptions['correctanswerlength']['default'] = 2;
$answerlengthformats = array('1' => get_string('decimalformat', 'quiz'), '2' => get_string('significantfiguresformat', 'quiz'));
$repeated[] =& $mform->createElement('select', 'correctanswerformat', get_string('correctanswershowsformat', 'qtype_calculated'), $answerlengthformats);
$repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'));
$repeatedoptions['feedback']['type'] = PARAM_RAW;
if (isset($this->question->options)) {
$count = count($this->question->options->answers);
} else {
$count = 0;
}
$repeatsatstart = $count + 1;
$this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', 1, get_string('addmoreanswerblanks', 'qtype_calculated'));
$repeated = array();
$repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}'));
$repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz'));
$mform->setType('unit', PARAM_NOTAGS);
$repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz'));
$mform->setType('multiplier', PARAM_NUMBER);
if (isset($this->question->options)) {
$countunits = count($this->question->options->units);
} else {
$countunits = 0;
}
$repeatsatstart = $countunits + 1;
$this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}'));
$firstunit =& $mform->getElement('multiplier[0]');
$firstunit->freeze();
$firstunit->setValue('1.0');
$firstunit->setPersistantFreeze(true);
//hidden elements
$mform->addElement('hidden', 'wizard', 'datasetdefinitions');
$mform->setType('wizard', PARAM_ALPHA);
}
示例4:
/**
* Add question-type specific form fields.
*
* @param MoodleQuickForm $mform the form being built.
*/
function definition_inner(&$mform)
{
$mform->addElement('editor', 'feedback', get_string('feedback', 'quiz'), null, $this->editoroptions);
$mform->setType('feedback', PARAM_RAW);
$mform->addElement('hidden', 'fraction', 0);
$mform->setType('fraction', PARAM_RAW);
//don't need this default element.
$mform->removeElement('penalty');
$mform->addElement('hidden', 'penalty', 0);
$mform->setType('penalty', PARAM_RAW);
}
示例5: array
/**
* Add question-type specific form fields.
*
* @param MoodleQuickForm $mform the form being built.
*/
function definition_inner(&$mform)
{
$mform->addElement('htmleditor', 'feedback', get_string("feedback", "quiz"), array('course' => $this->coursefilesid));
$mform->setType('feedback', PARAM_RAW);
$mform->addElement('hidden', 'fraction', 0);
$mform->setType('fraction', PARAM_RAW);
//don't need this default element.
$mform->removeElement('penalty');
$mform->addElement('hidden', 'penalty', 0);
$mform->setType('penalty', PARAM_RAW);
}
示例6: array
/**
* Add question-type specific form fields.
*
* @param MoodleQuickForm $mform the form being built.
*/
function definition_inner(&$mform)
{
$questionstoselect = array();
for ($i = 2; $i <= QUESTION_NUMANS; $i++) {
$questionstoselect[$i] = $i;
}
$mform->addElement('select', 'choose', get_string("randomsamatchnumber", "quiz"), $questionstoselect);
$mform->setType('feedback', PARAM_RAW);
$mform->addElement('hidden', 'fraction', 0);
$mform->setType('fraction', PARAM_RAW);
}
示例7: 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);
}
示例8: 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();
$gradeoptions = $creategrades->gradeoptions;
$repeated = array();
$repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerno', 'qtype_shortanswer', '{no}'));
$repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'), array('size' => 54));
$repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions);
$repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'), array('course' => $this->coursefilesid));
if (isset($this->question->options)) {
$countanswers = count($this->question->options->answers);
} else {
$countanswers = 0;
}
if ($this->question->formoptions->repeatelements) {
$repeatsatstart = QUESTION_NUMANS_START > $countanswers + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countanswers + QUESTION_NUMANS_ADD;
} else {
$repeatsatstart = $countanswers;
}
$repeatedoptions = array();
$mform->setType('answer', PARAM_RAW);
$repeatedoptions['fraction']['default'] = 0;
$this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreanswerblanks', 'qtype_shortanswer'));
}
示例9: 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));
}
示例10: 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);
}
示例11:
/**
* 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);
$mform->setType('defaultgrade', PARAM_RAW);
}
示例12: 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);
}
示例13: 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);
}
示例14: 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);
}
示例15: 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);
$mform->setType('slotmarks', PARAM_INT);
}
}