MDL-79047 grade: Use the gradebook plugin name for the page title

* Use the appropriate gradebook plugin string for the page title.
* Improve gradebook page titles set by grade_get_plugin_info() by
listing the unique identifying information for the page first
(e.g. the gradebook plugin name), followed by broader information
(Grades + Course name), separating these bits of information using the
pipe `|` character.

For more information, check out
https://www.w3.org/WAI/WCAG21/Techniques/general/G88
This commit is contained in:
Jun Pataleta 2023-08-30 00:20:01 +08:00
parent 88f4aafad9
commit 1ece6f4295
No known key found for this signature in database
GPG key ID: F83510526D99E2C7

View file

@ -770,8 +770,8 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
break; break;
} }
foreach ($plugins as $plugin) { foreach ($plugins as $plugin) {
if (is_a($plugin, 'grade_plugin_info')) { if (is_a($plugin, grade_plugin_info::class)) {
if ($active_plugin == $plugin->id) { if ($plugin_type === $active_type && $active_plugin == $plugin->id) {
$plugin_info['strings']['active_plugin_str'] = $plugin->string; $plugin_info['strings']['active_plugin_str'] = $plugin->string;
} }
} }
@ -880,7 +880,7 @@ class grade_plugin_info {
* @param string|null $headerhelpidentifier The help string identifier if required. * @param string|null $headerhelpidentifier The help string identifier if required.
* @param string|null $headerhelpcomponent The component for the help string. * @param string|null $headerhelpcomponent The component for the help string.
* @param stdClass|null $user The user object for use with the user context header. * @param stdClass|null $user The user object for use with the user context header.
* @param actionbar|null $actionbar The actions bar which will be displayed on the page if $shownavigation is set * @param action_bar|null $actionbar The actions bar which will be displayed on the page if $shownavigation is set
* to true. If $actionbar is not explicitly defined, the general action bar * to true. If $actionbar is not explicitly defined, the general action bar
* (\core_grades\output\general_action_bar) will be used by default. * (\core_grades\output\general_action_bar) will be used by default.
* @param boolean $showtitle If set to false just show course full name as a title. * @param boolean $showtitle If set to false just show course full name as a title.
@ -922,7 +922,19 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti
} else { } else {
$PAGE->set_pagelayout('admin'); $PAGE->set_pagelayout('admin');
} }
$PAGE->set_title(get_string('grades') . ': ' . $stractive_type); $coursecontext = context_course::instance($courseid);
// Title will be constituted by information starting from the unique identifying information for the page.
if (in_array($active_type, ['report', 'settings'])) {
$uniquetitle = $stractive_plugin;
} else {
$uniquetitle = $stractive_type . ': ' . $stractive_plugin;
}
$titlecomponents = [
$uniquetitle,
get_string('grades'),
$coursecontext->get_context_name(false),
];
$PAGE->set_title(implode(moodle_page::TITLE_SEPARATOR, $titlecomponents));
$PAGE->set_heading($title); $PAGE->set_heading($title);
$PAGE->set_secondary_active_tab('grades'); $PAGE->set_secondary_active_tab('grades');
@ -988,8 +1000,7 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti
echo $output; echo $output;
} }
$returnval .= print_natural_aggregation_upgrade_notice($courseid, context_course::instance($courseid), $PAGE->url, $returnval .= print_natural_aggregation_upgrade_notice($courseid, $coursecontext, $PAGE->url, $return);
$return);
if ($return) { if ($return) {
return $returnval; return $returnval;