MDL-80121 grade: Trim heading

In order to prevent rendering an empty heading <h2>, we need to make
sure that the $heading parameter passed to print_grade_page_head() is
not an empty string.
This commit is contained in:
Jun Pataleta 2023-11-15 15:37:00 +08:00
parent 8ad9114050
commit d8dbfe5d25
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7

View File

@ -891,6 +891,12 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti
?string $headerhelpcomponent = null, ?stdClass $user = null, ?action_bar $actionbar = null, $showtitle = true) {
global $CFG, $OUTPUT, $PAGE, $USER;
if ($heading !== false) {
// Make sure to trim heading, including the non-breaking space character.
$heading = str_replace("&nbsp;", " ", $heading);
$heading = trim($heading);
}
// Put a warning on all gradebook pages if the course has modules currently scheduled for background deletion.
require_once($CFG->dirroot . '/course/lib.php');
if (course_modules_pending_deletion($courseid, true)) {