From 816fadfcd79b0f16a1dd6549a0705dedb3ca53b9 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 23 Nov 2023 22:16:52 +0800 Subject: [PATCH 1/5] MDL-80043 grade: Use heading parameter for the page title if provided --- grade/lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grade/lib.php b/grade/lib.php index b692b76c861..8abf8035a9f 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -930,14 +930,16 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti } $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'])) { + if ($heading) { + // If heading is supplied, use this for the page title. + $uniquetitle = $heading; + } else 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)); From fe3ff7dd691bba8d2b289a1683c3208601f7f0b6 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 23 Nov 2023 22:44:14 +0800 Subject: [PATCH 2/5] MDL-80043 gradereport_singleview: Improve heading wordings * Make the headings for the single view easier to read and understand * When on editing mode, update the heading for the grade and user screens to convey to the user that the page is currently on editing mode. This is helpful for screen reader users as they can immediately know the current display mode of the single view report page when this gets read via the page title. --- grade/report/singleview/classes/local/screen/grade.php | 4 +++- grade/report/singleview/classes/local/screen/user.php | 4 +++- grade/report/singleview/lang/en/gradereport_singleview.php | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/grade/report/singleview/classes/local/screen/grade.php b/grade/report/singleview/classes/local/screen/grade.php index 567d202e7d6..9984d647aec 100644 --- a/grade/report/singleview/classes/local/screen/grade.php +++ b/grade/report/singleview/classes/local/screen/grade.php @@ -301,7 +301,9 @@ class grade extends tablelike implements selectable_items, filterable_items { * @return string */ public function heading(): string { - return get_string('gradeitem', 'gradereport_singleview', $this->item->get_name()); + global $PAGE; + $headinglangstring = $PAGE->user_is_editing() ? 'gradeitemedit' : 'gradeitem'; + return get_string($headinglangstring, 'gradereport_singleview', $this->item->get_name()); } /** diff --git a/grade/report/singleview/classes/local/screen/user.php b/grade/report/singleview/classes/local/screen/user.php index 1688f18bead..76a7a4c2aa6 100644 --- a/grade/report/singleview/classes/local/screen/user.php +++ b/grade/report/singleview/classes/local/screen/user.php @@ -302,7 +302,9 @@ class user extends tablelike implements selectable_items { * @return string */ public function heading(): string { - return get_string('gradeuser', 'gradereport_singleview', fullname($this->item)); + global $PAGE; + $headinglangstring = $PAGE->user_is_editing() ? 'gradeuseredit' : 'gradeuser'; + return get_string($headinglangstring, 'gradereport_singleview', fullname($this->item)); } /** diff --git a/grade/report/singleview/lang/en/gradereport_singleview.php b/grade/report/singleview/lang/en/gradereport_singleview.php index 8abc112d353..8bed4520065 100644 --- a/grade/report/singleview/lang/en/gradereport_singleview.php +++ b/grade/report/singleview/lang/en/gradereport_singleview.php @@ -44,8 +44,10 @@ $string['excludenonegrades'] = 'Exclude none'; $string['eventgradereportviewed'] = 'Grade single view report viewed.'; $string['feedbackfor'] = 'Feedback for {$a}'; $string['gradefor'] = 'Grade for {$a}'; -$string['gradeitem'] = 'Grade item: {$a}'; -$string['gradeuser'] = 'Grade user: {$a}'; +$string['gradeitem'] = 'Viewing grades for {$a}'; +$string['gradeitemedit'] = 'Editing grades for {$a}'; +$string['gradeuser'] = 'Viewing {$a}\'s grades'; +$string['gradeuseredit'] = 'Editing {$a}\'s grades'; $string['gotonextreport'] = 'Go to next user report'; $string['gotopreviousreport'] = 'Go to previous user report'; $string['noscreens'] = 'Could not find a suitable single view screen.'; From 18e5768332ccd51766276fcf8b5303308150deaf Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 24 Nov 2023 00:18:03 +0800 Subject: [PATCH 3/5] MDL-80043 grade: `editingmode_title` support for grade report plugins * Add support for grade report plugins that define an `editingmode_title` lang string. If the grade report plugin defines this language string, it will be used for the page title's unique identifying information when editing mode is turned on. --- grade/lib.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grade/lib.php b/grade/lib.php index 8abf8035a9f..8e0cf929990 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -934,7 +934,15 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti // If heading is supplied, use this for the page title. $uniquetitle = $heading; } else if (in_array($active_type, ['report', 'settings'])) { + // For grade reports or settings pages of grade plugins, use the plugin name for the unique title. $uniquetitle = $stractive_plugin; + // But if editing mode is turned on, check if the report plugin has an editing mode title string and use it if present. + if ($PAGE->user_is_editing() && $active_type === 'report') { + $strcomponent = "gradereport_{$active_plugin}"; + if (get_string_manager()->string_exists('editingmode_title', $strcomponent)) { + $uniquetitle = get_string('editingmode_title', $strcomponent); + } + } } else { $uniquetitle = $stractive_type . ': ' . $stractive_plugin; } From cc6b3c161f586d505f9afbb3998ff482a8a90c26 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 24 Nov 2023 00:18:42 +0800 Subject: [PATCH 4/5] MDL-80043 gradereport_grader: Define `editingmode_title` lang string --- grade/report/grader/lang/en/gradereport_grader.php | 1 + 1 file changed, 1 insertion(+) diff --git a/grade/report/grader/lang/en/gradereport_grader.php b/grade/report/grader/lang/en/gradereport_grader.php index da0f659288e..aae697d69e8 100644 --- a/grade/report/grader/lang/en/gradereport_grader.php +++ b/grade/report/grader/lang/en/gradereport_grader.php @@ -28,6 +28,7 @@ $string['ajaxerror'] = 'Error'; $string['ajaxfailedupdate'] = 'Unable to update [1] for [2]'; $string['ajaxfieldchanged'] = 'The field you are currently editing has changed, would you like to use the updated value?'; $string['ajaxchoosescale'] = 'Choose'; +$string['editingmode_title'] = 'Editing the grader report'; $string['eventgradereportviewed'] = 'Grader report viewed'; $string['grader:manage'] = 'Manage the grader report'; $string['grader:view'] = 'View grader report'; From a2ddc55f695cdbf32d03c1e18b733168b0d0db26 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 24 Nov 2023 00:19:24 +0800 Subject: [PATCH 5/5] MDL-80043 grade: Add upgrade.txt notes --- grade/upgrade.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grade/upgrade.txt b/grade/upgrade.txt index 49e4603f227..4211979a030 100644 --- a/grade/upgrade.txt +++ b/grade/upgrade.txt @@ -1,6 +1,12 @@ This file describes API changes in /grade/* ; Information provided here is intended especially for developers. +=== 4.1.7 === +* Some changes to how print_grade_page_head() sets the page title: + * If a non-empty `$heading` parameter is passed, it will be used as the page title's unique identifying information. + * Add support for grade report plugins that define an `editingmode_title` lang string. If the grade report plugin defines this + language string, it will be used for the page title's unique identifying information when editing mode is turned on. + === 4.1.6 === * The grade `itemname` property contained in the return structure of the following external methods is now PARAM_CLEANHTML: - `gradereport_user_get_grade_items`