MDL-82346 hub: Add organisation type to registration form

This commit is contained in:
David Woloszyn
2024-07-30 11:06:46 +10:00
parent 1a33da6637
commit 7501a54372
3 changed files with 63 additions and 3 deletions
+21
View File
@@ -143,6 +143,27 @@ $string['sitelang'] = 'Language';
$string['sitelang_help'] = 'What is the main language used on your Moodle site?';
$string['sitename'] = 'Name';
$string['sitename_help'] = 'The name of the site will be shown on the site listing if the hub allows that.';
$string['siteorganisationtype'] = 'Organisation type';
$string['siteorganisationtype:charityornotforprofit'] = 'Charity or Not For Profit';
$string['siteorganisationtype:charterschool'] = 'Charter school';
$string['siteorganisationtype:college'] = 'College';
$string['siteorganisationtype:collegedepartment'] = 'College department';
$string['siteorganisationtype:commercialcourseprovider'] = 'Commercial course provider';
$string['siteorganisationtype:companydepartment'] = 'Company department';
$string['siteorganisationtype:companyinternal'] = 'Company internal';
$string['siteorganisationtype:donotshare'] = 'Do not share';
$string['siteorganisationtype:government'] = 'Government';
$string['siteorganisationtype:highschool'] = 'High school';
$string['siteorganisationtype:highschooldepartment'] = 'High school department';
$string['siteorganisationtype:highschooldistrict'] = 'High school district';
$string['siteorganisationtype:hospital'] = 'Hospital';
$string['siteorganisationtype:independentteacher'] = 'Independent teacher';
$string['siteorganisationtype:other'] = 'Other';
$string['siteorganisationtype:primaryschool'] = 'Primary school';
$string['siteorganisationtype:schooldistrict'] = 'School district';
$string['siteorganisationtype:universitydepartment'] = 'University department';
$string['siteorganisationtype:wholeuniversity'] = 'Whole university';
$string['siteorganisationtype_help'] = 'Providing your organisation type will help us better understand the types of organisations using Moodle and their needs.';
$string['sitephone'] = 'Phone';
$string['sitephone_help'] = 'Your phone number will only be seen by the hub administrator.';
$string['siteprivacy'] = 'Site listing';
+32 -1
View File
@@ -44,7 +44,8 @@ class registration {
* IMPORTANT: any new fields with non-empty defaults have to be added to CONFIRM_NEW_FIELDS */
const FORM_FIELDS = ['policyagreed', 'language', 'countrycode', 'privacy',
'contactemail', 'emailalert', 'emailalertemail', 'commnews', 'commnewsemail',
'contactname', 'name', 'description', 'imageurl', 'contactphone', 'regioncode', 'geolocation', 'street'];
'contactname', 'name', 'description', 'imageurl', 'contactphone', 'regioncode',
'geolocation', 'street', 'organisationtype'];
/** @var array List of new FORM_FIELDS or siteinfo fields added indexed by the version when they were added.
* If site was already registered, admin will be promted to confirm new registration data manually. Until registration is manually confirmed,
@@ -397,6 +398,36 @@ class registration {
];
}
/**
* Get the options for organisation type form element to use in registration form.
*
* Indexes reference Moodle internal ids and should not be changed.
*
* @return array
*/
public static function get_site_organisation_type_options(): array {
return [
1 => get_string('siteorganisationtype:wholeuniversity', 'hub'),
2 => get_string('siteorganisationtype:universitydepartment', 'hub'),
3 => get_string('siteorganisationtype:college', 'hub'),
4 => get_string('siteorganisationtype:collegedepartment', 'hub'),
5 => get_string('siteorganisationtype:highschool', 'hub'),
6 => get_string('siteorganisationtype:highschooldepartment', 'hub'),
7 => get_string('siteorganisationtype:primaryschool', 'hub'),
8 => get_string('siteorganisationtype:independentteacher', 'hub'),
9 => get_string('siteorganisationtype:companyinternal', 'hub'),
10 => get_string('siteorganisationtype:companydepartment', 'hub'),
11 => get_string('siteorganisationtype:commercialcourseprovider', 'hub'),
12 => get_string('siteorganisationtype:other', 'hub'),
13 => get_string('siteorganisationtype:highschooldistrict', 'hub'),
14 => get_string('siteorganisationtype:government', 'hub'),
16 => get_string('siteorganisationtype:charityornotforprofit', 'hub'),
17 => get_string('siteorganisationtype:charterschool', 'hub'),
18 => get_string('siteorganisationtype:schooldistrict', 'hub'),
19 => get_string('siteorganisationtype:hospital', 'hub'),
];
}
/**
* Registers a site
*
+10 -2
View File
@@ -65,8 +65,8 @@ class site_registration_form extends \moodleform {
'geolocation' => '',
'emailalert' => 0,
'commnews' => 0,
'policyagreed' => 0
'policyagreed' => 0,
'organisationtype' => '',
]);
// Fields that need to be highlighted.
@@ -79,6 +79,14 @@ class site_registration_form extends \moodleform {
$mform->setType('name', PARAM_TEXT);
$mform->addHelpButton('name', 'sitename', 'hub');
$organisationtypes = registration::get_site_organisation_type_options();
\core_collator::asort($organisationtypes);
// Prepend the empty/default value here. We are not using array_merge to preserve keys.
$organisationtypes = ['' => get_string('siteorganisationtype:donotshare', 'hub')] + $organisationtypes;
$mform->addElement('select', 'organisationtype', get_string('siteorganisationtype', 'hub'), $organisationtypes);
$mform->setType('organisationtype', PARAM_ALPHANUM);
$mform->addHelpButton('organisationtype', 'siteorganisationtype', 'hub');
$mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), registration::site_privacy_options());
$mform->setType('privacy', PARAM_ALPHA);
$mform->addHelpButton('privacy', 'siteprivacy', 'hub');