Skip to content

Commit

Permalink
MDL-80121 grade: Trim heading
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
junpataleta committed Nov 15, 2023
1 parent 14414fe commit 51a6181
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions grade/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, $unused = null) {
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);
}

if ($unused !== null) {
debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER);
}
Expand Down

0 comments on commit 51a6181

Please sign in to comment.