diff --git a/blocks/myoverview/classes/output/main.php b/blocks/myoverview/classes/output/main.php index 5f44bb31e0dae..d9687ded27672 100644 --- a/blocks/myoverview/classes/output/main.php +++ b/blocks/myoverview/classes/output/main.php @@ -366,7 +366,9 @@ public function get_customfield_values_for_export() { return []; } $field = \core_customfield\field_controller::create($fieldid); - if (!$field->supports_course_grouping()) { + $isvisible = $field->get_configdata_property('visibility') == \core_course\customfield\course_handler::VISIBLETOALL; + // Only visible fields to everybody supporting course grouping will be displayed. + if (!$field->supports_course_grouping() || !$isvisible) { return []; // The field shouldn't have been selectable in the global settings, but just skip it now. } $values = $field->course_grouping_format_values($values); diff --git a/blocks/myoverview/lang/en/block_myoverview.php b/blocks/myoverview/lang/en/block_myoverview.php index 09b5aed8c5813..76f83fb21460c 100644 --- a/blocks/myoverview/lang/en/block_myoverview.php +++ b/blocks/myoverview/lang/en/block_myoverview.php @@ -54,7 +54,7 @@ $string['completepercent'] = '{$a}% complete'; $string['customfield'] = 'Custom field'; $string['customfiltergrouping'] = 'Field to use'; -$string['customfiltergrouping_nofields'] = 'This option requires a course custom field to be set up.'; +$string['customfiltergrouping_nofields'] = 'This option requires a course custom field to be set up and visible to everyone.'; $string['displaycategories'] = 'Display categories'; $string['displaycategories_help'] = 'Display the course category on dashboard course items including cards, list items and summary items.'; $string['favourites'] = 'Starred'; diff --git a/customfield/classes/api.php b/customfield/classes/api.php index 087a0d348c4ad..6ebce70d30483 100644 --- a/customfield/classes/api.php +++ b/customfield/classes/api.php @@ -431,7 +431,9 @@ public static function get_fields_supporting_course_grouping() { $fields = $DB->get_records_sql($sql); foreach ($fields as $field) { $inst = field_controller::create(0, $field); - if ($inst->supports_course_grouping()) { + $isvisible = $inst->get_configdata_property('visibility') == \core_course\customfield\course_handler::VISIBLETOALL; + // Only visible fields to everybody supporting course grouping will be displayed. + if ($inst->supports_course_grouping() && $isvisible) { $ret[$inst->get('shortname')] = $inst->get('name'); } } diff --git a/lang/en/course.php b/lang/en/course.php index 7895d12e28f96..38c51188ee845 100644 --- a/lang/en/course.php +++ b/lang/en/course.php @@ -35,7 +35,7 @@ $string['customfield_islocked_help'] = 'If the field is locked, only users with the capability to change locked custom fields (by default users with the default role of manager only) will be able to change it in the course settings.'; $string['customfield_notvisible'] = 'Nobody'; $string['customfield_visibility'] = 'Visible to'; -$string['customfield_visibility_help'] = 'This setting determines who can view the custom field name and value in the list of courses.'; +$string['customfield_visibility_help'] = 'This setting determines who can view the custom field name and value in the list of courses or in the available custom field filter of the Dashboard.'; $string['customfield_visibletoall'] = 'Everyone'; $string['customfield_visibletoteachers'] = 'Teachers'; $string['customfieldsettings'] = 'Common course custom fields settings';