From 7c88f2abdc3b421fab69469c2a6fdfca58ea1784 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Sat, 19 Aug 2023 06:54:02 +0800 Subject: [PATCH] MDL-79048 course: Add editing versions of course view page titles * Create 'editing' versions of the coursetitle and coursesectiontitle lang strings used for the page title of the course homepage and use these when editing mode is turned on to provide immediate information to users, especially screen reader users, the current state of the course homepage. --- course/view.php | 10 ++++++++-- lang/en/moodle.php | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/course/view.php b/course/view.php index 82f22518f6b..fb8ab4f9b72 100644 --- a/course/view.php +++ b/course/view.php @@ -259,19 +259,25 @@ if ($PAGE->user_allowed_editing()) { $PAGE->set_button($buttons); } +$editingtitle = ''; +if ($PAGE->user_is_editing()) { + // Append this to the page title's lang string to get its equivalent when editing mode is turned on. + $editingtitle = 'editing'; +} + // If viewing a section, make the title more specific. if ($section && $section > 0 && course_format_uses_sections($course->format)) { $sectionname = get_string('sectionname', "format_$course->format"); $sectiontitle = get_section_name($course, $section); $PAGE->set_title( get_string( - 'coursesectiontitle', + 'coursesectiontitle' . $editingtitle, 'moodle', ['course' => $course->fullname, 'sectiontitle' => $sectiontitle, 'sectionname' => $sectionname] ) ); } else { - $PAGE->set_title(get_string('coursetitle', 'moodle', ['course' => $course->fullname])); + $PAGE->set_title(get_string('coursetitle' . $editingtitle, 'moodle', ['course' => $course->fullname])); } // Add bulk editing control. diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 163fab0c05b..0b936f5af69 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -418,7 +418,8 @@ $string['courserestore'] = 'Course restore'; $string['coursereuse'] = 'Course reuse'; $string['courses'] = 'Courses'; $string['coursesectionsummaries'] = 'Course section summaries'; -$string['coursesectiontitle'] = 'Course: {$a->course}, {$a->sectionname}: {$a->sectiontitle}'; +$string['coursesectiontitle'] = '{$a->sectionname}: {$a->sectiontitle} | {$a->course}'; +$string['coursesectiontitleediting'] = 'Edit {$a->sectionname}: {$a->sectiontitle} | {$a->course}'; $string['coursesettings'] = 'Course default settings'; $string['coursesmovedout'] = 'Courses moved out from {$a}'; $string['coursespending'] = 'Courses pending approval'; @@ -432,6 +433,7 @@ $string['coursestart'] = 'Course start'; $string['coursesummary'] = 'Course summary'; $string['coursesummary_help'] = 'A short description of your course. The content you add here is searchable.'; $string['coursetitle'] = 'Course: {$a->course}'; +$string['coursetitleediting'] = 'Edit course: {$a->course}'; $string['courseupdates'] = 'Course updates'; $string['coursevisibility'] = 'Course visibility'; $string['coursevisibility_help'] = '* Show: The course appears in the list of courses and students can access it.