MDL-38851 Administration: Fixed setType in admin section

This commit is contained in:
Rajesh Taneja 2013-04-08 10:04:02 +08:00
parent 3a8c4380c0
commit 1fe56a2a00
8 changed files with 92 additions and 32 deletions

View File

@ -49,8 +49,10 @@ class site_unregistration_form extends moodleform {
$unregisterlabel = get_string('unregister', 'hub');
$mform->addElement('checkbox', 'unpublishalladvertisedcourses', '',
' ' . get_string('unpublishalladvertisedcourses', 'hub'));
$mform->setType('unpublishalladvertisedcourses', PARAM_INT);
$mform->addElement('checkbox', 'unpublishalluploadedcourses', '',
' ' . get_string('unpublishalluploadedcourses', 'hub'));
$mform->setType('unpublishalluploadedcourses', PARAM_INT);
$mform->addElement('hidden', 'confirm', 1);
$mform->setType('confirm', PARAM_INT);
@ -82,7 +84,6 @@ class site_clean_registration_data_form extends moodleform {
$unregisterlabel = get_string('forceunregister', 'hub');
$mform->addElement('static', '', get_string('warning', 'hub'), get_string('forceunregisterconfirmation', 'hub', $hubname));
$mform->addElement('hidden', 'confirm', 1);
$mform->setType('confirm', PARAM_INT);
$mform->addElement('hidden', 'unregistration', 1);
@ -149,6 +150,7 @@ class hub_selector_form extends moodleform {
if (!empty($hubs)) {
$mform->addElement('select', 'publichub', get_string('publichub', 'hub'),
$options, array("size" => 15));
$mform->setType('publichub', PARAM_URL);
}
$mform->addElement('static', 'or', '', get_string('orenterprivatehub', 'hub'));
@ -156,8 +158,10 @@ class hub_selector_form extends moodleform {
//Private hub
$mform->addElement('text', 'unlistedurl', get_string('privatehuburl', 'hub'),
array('class' => 'registration_textfield'));
$mform->setType('unlistedurl', PARAM_URL);
$mform->addElement('text', 'password', get_string('password'),
array('class' => 'registration_textfield'));
$mform->setType('password', PARAM_RAW);
$this->add_action_buttons(false, get_string('selecthub', 'hub'));
}
@ -171,11 +175,8 @@ class hub_selector_form extends moodleform {
$unlistedurl = $this->_form->_submitValues['unlistedurl'];
if (!empty($unlistedurl)) {
$unlistedurltotest = clean_param($unlistedurl, PARAM_URL);
if (empty($unlistedurltotest)) {
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
}
if (empty($unlistedurl)) {
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
}
return $errors;
@ -272,6 +273,7 @@ class site_registration_form extends moodleform {
$options[HUB_SITELINKPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITELINKPUBLISHED);
$mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options);
$mform->setDefault('privacy', $privacy);
$mform->setType('privacy', PARAM_ALPHA);
$mform->addHelpButton('privacy', 'privacy', 'hub');
unset($options);
@ -305,11 +307,13 @@ class site_registration_form extends moodleform {
$countries = get_string_manager()->get_list_of_countries();
$mform->addElement('select', 'countrycode', get_string('sitecountry', 'hub'), $countries);
$mform->setDefault('countrycode', $country);
$mform->setType('countrycode', PARAM_ALPHANUMEXT);
$mform->addHelpButton('countrycode', 'sitecountry', 'hub');
$mform->addElement('text', 'geolocation', get_string('sitegeolocation', 'hub'),
array('class' => 'registration_textfield'));
$mform->setDefault('geolocation', $geolocation);
$mform->setType('geolocation', PARAM_RAW);
$mform->addHelpButton('geolocation', 'sitegeolocation', 'hub');
$mform->addElement('text', 'contactname', get_string('siteadmin', 'hub'),
@ -327,7 +331,7 @@ class site_registration_form extends moodleform {
$mform->addElement('text', 'contactemail', get_string('siteemail', 'hub'),
array('class' => 'registration_textfield'));
$mform->addRule('contactemail', $strrequired, 'required', null, 'client');
$mform->setType('contactemail', PARAM_TEXT);
$mform->setType('contactemail', PARAM_EMAIL);
$mform->setDefault('contactemail', $contactemail);
$mform->addHelpButton('contactemail', 'siteemail', 'hub');
@ -336,6 +340,7 @@ class site_registration_form extends moodleform {
$options[1] = get_string("registrationcontactyes");
$mform->addElement('select', 'contactable', get_string('siteregistrationcontact', 'hub'), $options);
$mform->setDefault('contactable', $contactable);
$mform->setType('contactable', PARAM_INT);
$mform->addHelpButton('contactable', 'siteregistrationcontact', 'hub');
unset($options);
@ -344,6 +349,7 @@ class site_registration_form extends moodleform {
$options[1] = get_string("registrationyes");
$mform->addElement('select', 'emailalert', get_string('siteregistrationemail', 'hub'), $options);
$mform->setDefault('emailalert', $emailalert);
$mform->setType('emailalert', PARAM_INT);
$mform->addHelpButton('emailalert', 'siteregistrationemail', 'hub');
unset($options);
@ -381,79 +387,89 @@ class site_registration_form extends moodleform {
if (HUB_MOODLEORGHUBURL != $huburl) {
$mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
" " . get_string('coursesnumber', 'hub', $coursecount));
$mform->setDefault('courses', true);
$mform->setDefault('courses', 1);
$mform->setType('courses', PARAM_INT);
$mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');
$mform->addElement('checkbox', 'users', '',
" " . get_string('usersnumber', 'hub', $usercount));
$mform->setDefault('users', true);
$mform->setDefault('users', 1);
$mform->setType('users', PARAM_INT);
$mform->addElement('checkbox', 'roleassignments', '',
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
$mform->setDefault('roleassignments', true);
$mform->setDefault('roleassignments', 1);
$mform->setType('roleassignments', PARAM_INT);
$mform->addElement('checkbox', 'posts', '',
" " . get_string('postsnumber', 'hub', $postcount));
$mform->setDefault('posts', true);
$mform->setDefault('posts', 1);
$mform->setType('posts', PARAM_INT);
$mform->addElement('checkbox', 'questions', '',
" " . get_string('questionsnumber', 'hub', $questioncount));
$mform->setDefault('questions', true);
$mform->setDefault('questions', 1);
$mform->setType('questions', PARAM_INT);
$mform->addElement('checkbox', 'resources', '',
" " . get_string('resourcesnumber', 'hub', $resourcecount));
$mform->setDefault('resources', true);
$mform->setDefault('resources', 1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('checkbox', 'badges', '',
" " . get_string('badgesnumber', 'hub', $badges));
$mform->setDefault('badges', true);
$mform->setDefault('badges', 1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('checkbox', 'issuedbadges', '',
" " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
$mform->setDefault('issuedbadges', true);
$mform->setDefault('issuedbadges', 1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('checkbox', 'participantnumberaverage', '',
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
$mform->setDefault('participantnumberaverage', true);
$mform->setDefault('participantnumberaverage', 1);
$mform->setType('participantnumberaverage', PARAM_FLOAT);
$mform->addElement('checkbox', 'modulenumberaverage', '',
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
$mform->setDefault('modulenumberaverage', true);
$mform->setDefault('modulenumberaverage', 1);
$mform->setType('modulenumberaverage', PARAM_FLOAT);
} else {
$mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
" " . get_string('coursesnumber', 'hub', $coursecount));
$mform->addElement('hidden', 'courses', true);
$mform->setType('courses', PARAM_FLOAT);
$mform->addElement('hidden', 'courses', 1);
$mform->setType('courses', PARAM_INT);
$mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub');
$mform->addElement('static', 'userslabel', '',
" " . get_string('usersnumber', 'hub', $usercount));
$mform->addElement('hidden', 'users', true);
$mform->setType('users', PARAM_FLOAT);
$mform->addElement('hidden', 'users', 1);
$mform->setType('users', PARAM_INT);
$mform->addElement('static', 'roleassignmentslabel', '',
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
$mform->addElement('hidden', 'roleassignments', true);
$mform->setType('roleassignments', PARAM_FLOAT);
$mform->addElement('hidden', 'roleassignments', 1);
$mform->setType('roleassignments', PARAM_INT);
$mform->addElement('static', 'postslabel', '',
" " . get_string('postsnumber', 'hub', $postcount));
$mform->addElement('hidden', 'posts', true);
$mform->setType('posts', PARAM_FLOAT);
$mform->addElement('hidden', 'posts', 1);
$mform->setType('posts', PARAM_INT);
$mform->addElement('static', 'questionslabel', '',
" " . get_string('questionsnumber', 'hub', $questioncount));
$mform->addElement('hidden', 'questions', true);
$mform->setType('questions', PARAM_FLOAT);
$mform->addElement('hidden', 'questions', 1);
$mform->setType('questions', PARAM_INT);
$mform->addElement('static', 'resourceslabel', '',
" " . get_string('resourcesnumber', 'hub', $resourcecount));
$mform->addElement('hidden', 'resources', true);
$mform->setType('resources', PARAM_FLOAT);
$mform->addElement('hidden', 'resources', 1);
$mform->setType('resources', PARAM_INT);
$mform->addElement('static', 'badgeslabel', '',
" " . get_string('badgesnumber', 'hub', $badges));
$mform->addElement('hidden', 'badges', true);
$mform->addElement('hidden', 'badges', 1);
$mform->setType('badges', PARAM_INT);
$mform->addElement('static', 'issuedbadgeslabel', '',
@ -463,12 +479,12 @@ class site_registration_form extends moodleform {
$mform->addElement('static', 'participantnumberaveragelabel', '',
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
$mform->addElement('hidden', 'participantnumberaverage', true);
$mform->addElement('hidden', 'participantnumberaverage', 1);
$mform->setType('participantnumberaverage', PARAM_FLOAT);
$mform->addElement('static', 'modulenumberaveragelabel', '',
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
$mform->addElement('hidden', 'modulenumberaverage', true);
$mform->addElement('hidden', 'modulenumberaverage', 1);
$mform->setType('modulenumberaverage', PARAM_FLOAT);
}

View File

@ -44,6 +44,7 @@ class tool_assignmentupgrade_batchoperations_form extends moodleform {
$mform->addElement('header', 'general', get_string('batchoperations', 'tool_assignmentupgrade'));
// Visible elements.
$mform->addElement('hidden', 'selectedassignments', '', array('class'=>'selectedassignments'));
$mform->setType('selectedassignments', PARAM_SEQUENCE);
$mform->addElement('submit', 'upgradeselected', get_string('upgradeselected', 'tool_assignmentupgrade'));
$mform->addElement('submit', 'upgradeall', get_string('upgradeall', 'tool_assignmentupgrade'));

View File

@ -43,6 +43,7 @@ class database_export_form extends moodleform {
$mform->addElement('header', 'database', get_string('dbexport', 'tool_dbtransfer'));
$mform->addElement('textarea', 'description', get_string('description'), array('rows'=>5, 'cols'=>60));
$mform->setType('description', PARAM_TEXT);
$this->add_action_buttons(false, get_string('exportdata', 'tool_dbtransfer'));
}

View File

@ -52,17 +52,32 @@ class database_transfer_form extends moodleform {
$drivers = array_reverse($drivers, true);
$mform->addElement('select', 'driver', get_string('dbtype', 'install'), $drivers);
$mform->setType('driver', PARAM_RAW);
$mform->addElement('text', 'dbhost', get_string('databasehost', 'install'));
$mform->setType('dbhost', PARAM_HOST);
$mform->addElement('text', 'dbname', get_string('databasename', 'install'));
$mform->setType('dbname', PARAM_ALPHANUMEXT);
$mform->addElement('text', 'dbuser', get_string('databaseuser', 'install'));
$mform->setType('dbuser', PARAM_ALPHANUMEXT);
$mform->addElement('passwordunmask', 'dbpass', get_string('databasepass', 'install'));
$mform->setType('dbpass', PARAM_RAW);
$mform->addElement('text', 'prefix', get_string('dbprefix', 'install'));
$mform->setType('prefix', PARAM_ALPHANUMEXT);
$mform->addElement('text', 'dbport', get_string('dbport', 'install'));
$mform->setType('dbport', PARAM_INT);
if ($CFG->ostype !== 'WINDOWS') {
$mform->addElement('text', 'dbsocket', get_string('databasesocket', 'install'));
} else {
$mform->addElement('hidden', 'dbsocket');
}
$mform->setType('dbsocket', PARAM_RAW);
$mform->addRule('driver', get_string('required'), 'required', null);
$mform->addRule('dbhost', get_string('required'), 'required', null);
@ -76,6 +91,7 @@ class database_transfer_form extends moodleform {
$mform->addElement('header', 'database', get_string('options', 'tool_dbtransfer'));
$mform->addElement('advcheckbox', 'enablemaintenance', get_string('enablemaintenance', 'tool_dbtransfer'));
$mform->setType('enablemaintenance', PARAM_BOOL);
$mform->addHelpButton('enablemaintenance', 'enablemaintenance', 'tool_dbtransfer');
$this->add_action_buttons(false, get_string('transferdata', 'tool_dbtransfer'));

View File

@ -40,17 +40,21 @@ class tool_qeupgradehelper_cron_setup_form extends moodleform {
$mform->addElement('selectyesno', 'cronenabled',
get_string('cronenabled', 'tool_qeupgradehelper'));
$mform->setType('cronenabled', PARAM_BOOL);
$mform->addElement('select', 'starthour',
get_string('cronstarthour', 'tool_qeupgradehelper'), range(0, 23));
$mform->setType('starthour', PARAM_INT);
$mform->addElement('select', 'stophour',
get_string('cronstophour', 'tool_qeupgradehelper'),
array_combine(range(1, 24), range(1, 24)));
$mform->setType('stophour', PARAM_INT);
$mform->setDefault('stophour', 24);
$mform->addElement('duration', 'procesingtime',
get_string('cronprocesingtime', 'tool_qeupgradehelper'));
$mform->setType('procesingtime', PARAM_INT);
$mform->setDefault('procesingtime', 60);
$mform->disabledIf('starthour', 'cronenabled', 'eq', 0);

View File

@ -51,12 +51,23 @@ class tool_qeupgradehelper_extract_options_form extends moodleform {
$mform->addElement('header', 'h1', 'Either extract a specific question_session');
$mform->addElement('text', 'attemptid', 'Quiz attempt id', array('size' => '10'));
$mform->setType('attemptid', PARAM_INT);
$mform->addElement('text', 'questionid', 'Question id', array('size' => '10'));
$mform->setType('questionid', PARAM_INT);
$mform->addElement('header', 'h2', 'Or find and extract an example by type');
$mform->addElement('select', 'behaviour', 'Behaviour', $behaviour);
$mform->setType('behaviour', PARAM_ALPHA);
$mform->addElement('text', 'statehistory', 'State history', array('size' => '10'));
$mform->setType('statehistory', PARAM_RAW);
$mform->addElement('select', 'qtype', 'Question type', $qtypes);
$mform->setType('qtype', PARAM_PLUGIN);
$mform->addElement('text', 'extratests', 'Extra conditions', array('size' => '50'));
$mform->setType('extratests', PARAM_RAW);
$this->add_action_buttons(false, 'Create test case');
}
}

View File

@ -89,8 +89,10 @@ class mod_lti_edit_types_form extends moodleform{
} else {
$mform->addElement('hidden', 'lti_coursevisible', '1');
}
$mform->setType('lti_coursevisible', PARAM_BOOL);
$mform->addElement('hidden', 'typeid');
$mform->setType('typeid', PARAM_INT);
$launchoptions=array();
$launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');
@ -100,6 +102,7 @@ class mod_lti_edit_types_form extends moodleform{
$mform->addElement('select', 'lti_launchcontainer', get_string('default_launch_container', 'lti'), $launchoptions);
$mform->setDefault('lti_launchcontainer', LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS);
$mform->addHelpButton('lti_launchcontainer', 'default_launch_container', 'lti');
$mform->setType('lti_launchcontainer', PARAM_INT);
// Add privacy preferences fieldset where users choose whether to send their data
$mform->addElement('header', 'privacy', get_string('privacy', 'lti'));
@ -110,10 +113,12 @@ class mod_lti_edit_types_form extends moodleform{
$options[2] = get_string('delegate', 'lti');
$mform->addElement('select', 'lti_sendname', get_string('share_name_admin', 'lti'), $options);
$mform->setType('lti_sendname', PARAM_INT);
$mform->setDefault('lti_sendname', '2');
$mform->addHelpButton('lti_sendname', 'share_name_admin', 'lti');
$mform->addElement('select', 'lti_sendemailaddr', get_string('share_email_admin', 'lti'), $options);
$mform->setType('lti_sendemailaddr', PARAM_INT);
$mform->setDefault('lti_sendemailaddr', '2');
$mform->addHelpButton('lti_sendemailaddr', 'share_email_admin', 'lti');
@ -122,6 +127,7 @@ class mod_lti_edit_types_form extends moodleform{
// Add grading preferences fieldset where the tool is allowed to return grades
$mform->addElement('select', 'lti_acceptgrades', get_string('accept_grades_admin', 'lti'), $options);
$mform->setType('lti_acceptgrades', PARAM_INT);
$mform->setDefault('lti_acceptgrades', '2');
$mform->addHelpButton('lti_acceptgrades', 'accept_grades_admin', 'lti');
@ -131,6 +137,7 @@ class mod_lti_edit_types_form extends moodleform{
//$mform->addHelpButton('lti_allowroster', 'share_roster_admin', 'lti');
$mform->addElement('checkbox', 'lti_forcessl', ' ', ' ' . get_string('force_ssl', 'lti'), $options);
$mform->setType('lti_forcessl', PARAM_BOOL);
$mform->setDefault('lti_forcessl', '0');
$mform->addHelpButton('lti_forcessl', 'force_ssl', 'lti');
@ -165,9 +172,11 @@ class mod_lti_edit_types_form extends moodleform{
$tab = optional_param('tab', '', PARAM_ALPHAEXT);
$mform->addElement('hidden', 'tab', $tab);
$mform->setType('tab', PARAM_ALPHAEXT);
$courseid = optional_param('course', 1, PARAM_INT);
$mform->addElement('hidden', 'course', $courseid);
$mform->setType('course', PARAM_INT);
//-------------------------------------------------------------------------------
// Add standard buttons, common to all modules

View File

@ -2908,12 +2908,14 @@ final class repository_type_form extends moodleform {
$component .= ('_' . $this->plugin);
}
$mform->addElement('checkbox', 'enablecourseinstances', get_string('enablecourseinstances', $component));
$mform->setType('enablecourseinstances', PARAM_BOOL);
$component = 'repository';
if ($sm->string_exists('enableuserinstances', 'repository_' . $this->plugin)) {
$component .= ('_' . $this->plugin);
}
$mform->addElement('checkbox', 'enableuserinstances', get_string('enableuserinstances', $component));
$mform->setType('enableuserinstances', PARAM_BOOL);
}
// set the data if we have some.