From 7501a5437223d553ee145d88f2618fb94bd2798a Mon Sep 17 00:00:00 2001 From: David Woloszyn Date: Tue, 30 Jul 2024 11:06:46 +1000 Subject: [PATCH] MDL-82346 hub: Add organisation type to registration form --- lang/en/hub.php | 21 ++++++++++++++ lib/classes/hub/registration.php | 33 +++++++++++++++++++++- lib/classes/hub/site_registration_form.php | 12 ++++++-- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/lang/en/hub.php b/lang/en/hub.php index a82ad1af2fc..f86005ec788 100644 --- a/lang/en/hub.php +++ b/lang/en/hub.php @@ -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'; diff --git a/lib/classes/hub/registration.php b/lib/classes/hub/registration.php index 0b1cc88037d..56030e159b9 100644 --- a/lib/classes/hub/registration.php +++ b/lib/classes/hub/registration.php @@ -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 * diff --git a/lib/classes/hub/site_registration_form.php b/lib/classes/hub/site_registration_form.php index 74ccb47b882..85b69c70bf4 100644 --- a/lib/classes/hub/site_registration_form.php +++ b/lib/classes/hub/site_registration_form.php @@ -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');