diff --git a/grade/edit/letter/index.php b/grade/edit/letter/index.php index b6140e5c84c..e709d971bb8 100644 --- a/grade/edit/letter/index.php +++ b/grade/edit/letter/index.php @@ -92,7 +92,7 @@ if (!$edit) { echo $renderer->render_action_bar($actionbar); echo $OUTPUT->heading($heading); } else { - print_grade_page_head($course->id, 'letter', 'view', $heading, false, false, + print_grade_page_head($course->id, 'letter', 'view', false, false, false, true, null, null, null, $actionbar); } diff --git a/grade/edit/scale/index.php b/grade/edit/scale/index.php index f9e6e18f637..6a21e7dab7e 100644 --- a/grade/edit/scale/index.php +++ b/grade/edit/scale/index.php @@ -172,7 +172,7 @@ if ($scales = grade_scale::fetch_all_global()) { $actionbar = new \core_grades\output\scales_action_bar($context); if ($courseid) { - print_grade_page_head($courseid, 'scale', 'scale', get_string('coursescales', 'grades'), + print_grade_page_head($courseid, 'scale', 'scale', false, false, false, true, null, null, null, $actionbar); } else { $renderer = $PAGE->get_renderer('core_grades'); diff --git a/grade/edit/settings/index.php b/grade/edit/settings/index.php index eac3a216d62..98602f60412 100644 --- a/grade/edit/settings/index.php +++ b/grade/edit/settings/index.php @@ -73,7 +73,7 @@ if ($data = $mform->get_data()) { } } -print_grade_page_head($courseid, 'settings', 'coursesettings', get_string('coursegradesettings', 'grades')); +print_grade_page_head($courseid, 'settings', 'coursesettings'); // The settings could have been changed due to a notice shown in print_grade_page_head, we need to refresh them. $settings = grade_get_settings($course->id); diff --git a/grade/edit/tree/index.php b/grade/edit/tree/index.php index ae874d56f0e..fd60ee21acd 100644 --- a/grade/edit/tree/index.php +++ b/grade/edit/tree/index.php @@ -246,8 +246,8 @@ if (grade_regrade_final_grades_if_required($course, $grade_edit_tree_index_check } $actionbar = new \core_grades\output\gradebook_setup_action_bar($context); -print_grade_page_head($courseid, 'settings', 'setup', get_string('gradebooksetup', 'grades'), - false, false, true, null, null, null, $actionbar, false); +print_grade_page_head($courseid, 'settings', 'setup', false, + false, false, true, null, null, null, $actionbar); // Print Table of categories and items echo $OUTPUT->box_start('gradetreebox generalbox'); diff --git a/grade/lib.php b/grade/lib.php index c7524e9d52f..147c0dc9430 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -842,7 +842,7 @@ class grade_plugin_info { * @param string $active_type The type of the current page (report, settings, * import, export, scales, outcomes, letters) * @param string|null $active_plugin The plugin of the current page (grader, fullview etc...) - * @param string|bool $heading The heading of the page. Tries to guess if none is given + * @param string|bool $heading The heading of the page. * @param boolean $return Whether to return (true) or echo (false) the HTML generated by this function * @param string|bool $buttons Additional buttons to display on the page * @param boolean $shownavigation should the gradebook navigation be shown? @@ -852,14 +852,18 @@ class grade_plugin_info { * @param actionbar|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 * (\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 null $unused This parameter has been deprecated since 4.3 and should not be used anymore. * @return string HTML code or nothing if $return == false */ -function print_grade_page_head(int $courseid, string $active_type, ?string $active_plugin = null, $heading = false, +function print_grade_page_head(int $courseid, string $active_type, ?string $active_plugin = null, string|bool $heading = false, bool $return = false, $buttons = false, bool $shownavigation = true, ?string $headerhelpidentifier = null, - ?string $headerhelpcomponent = null, ?stdClass $user = null, ?action_bar $actionbar = null, $showtitle = true) { + ?string $headerhelpcomponent = null, ?stdClass $user = null, ?action_bar $actionbar = null, $unused = null) { global $CFG, $OUTPUT, $PAGE; + if ($unused !== null) { + debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER); + } + // 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)) { @@ -875,24 +879,15 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti $plugin_info = grade_get_plugin_info($courseid, $active_type, $active_plugin); // Determine the string of the active plugin - $stractive_plugin = ($active_plugin) ? $plugin_info['strings']['active_plugin_str'] : $heading; $stractive_type = $plugin_info['strings'][$active_type]; - if (!$showtitle) { - $title = $PAGE->course->fullname; - } else if (empty($plugin_info[$active_type]->id) || !empty($plugin_info[$active_type]->parent)) { - $title = $PAGE->course->fullname.': ' . $stractive_type . ': ' . $stractive_plugin; - } else { - $title = $PAGE->course->fullname.': ' . $stractive_plugin; - } - if ($active_type == 'report') { $PAGE->set_pagelayout('report'); } else { $PAGE->set_pagelayout('admin'); } $PAGE->set_title(get_string('grades') . ': ' . $stractive_type); - $PAGE->set_heading($title); + $PAGE->set_heading($PAGE->course->fullname); $PAGE->set_secondary_active_tab('grades'); if ($buttons instanceof single_button) { @@ -914,15 +909,6 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti echo $returnval; } - // Guess heading if not given explicitly - if (!$heading) { - $heading = $stractive_plugin; - } - - if (!$showtitle) { - $heading = ''; - } - if ($shownavigation) { $renderer = $PAGE->get_renderer('core_grades'); // If the navigation action bar is not explicitly defined, use the general (default) action bar. @@ -937,6 +923,8 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti } } + $heading = !empty($heading) ? $heading : ''; + $output = ''; // Add a help dialogue box if provided. if (isset($headerhelpidentifier)) { diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php index 3ba7858adac..96964c5f27d 100644 --- a/grade/report/grader/index.php +++ b/grade/report/grader/index.php @@ -138,8 +138,8 @@ $PAGE->requires->js_call_amd('gradereport_grader/collapse', 'init', [ $numusers = $report->get_numusers(true, true); $actionbar = new \gradereport_grader\output\action_bar($context, $report, $numusers); -print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons, true, - null, null, null, $actionbar, false); +print_grade_page_head($COURSE->id, 'report', 'grader', false, false, $buttons, true, + null, null, null, $actionbar); // make sure separate group does not prevent view if ($report->currentgroup == -2) { diff --git a/grade/report/grader/preferences.php b/grade/report/grader/preferences.php index e9e4e4c95ce..b20c1fa2ee9 100644 --- a/grade/report/grader/preferences.php +++ b/grade/report/grader/preferences.php @@ -62,7 +62,7 @@ if ($data = $mform->get_data()) { } } -print_grade_page_head($courseid, 'settings', 'grader', get_string('preferences', 'gradereport_grader')); +print_grade_page_head($courseid, 'settings', 'grader'); // If USER has admin capability, print a link to the site config page for this report if (has_capability('moodle/site:config', $systemcontext)) { diff --git a/grade/report/history/index.php b/grade/report/history/index.php index 469a2dec050..0c56d488c86 100644 --- a/grade/report/history/index.php +++ b/grade/report/history/index.php @@ -110,8 +110,7 @@ if ($table->is_downloading()) { // Print header. $actionbar = new \core_grades\output\general_action_bar($context, new moodle_url('/grade/report/history/index.php', ['id' => $courseid]), 'report', 'history'); -print_grade_page_head($COURSE->id, 'report', 'history', get_string('pluginname', - 'gradereport_history'), false, false, true, null, null, +print_grade_page_head($COURSE->id, 'report', 'history', false, false, false, true, null, null, null, $actionbar); $mform->display(); diff --git a/grade/report/summary/index.php b/grade/report/summary/index.php index a90af79fd04..854cc909d02 100644 --- a/grade/report/summary/index.php +++ b/grade/report/summary/index.php @@ -47,7 +47,7 @@ require_capability('moodle/grade:viewall', $context); print_grade_page_head($courseid, 'report', 'summary', false, false, false, true, null, null, - null, null, false); + null, null); $report = system_report_factory::create(summary::class, context_course::instance($courseid)); diff --git a/grade/report/user/index.php b/grade/report/user/index.php index ffd16cac34a..b70773de593 100644 --- a/grade/report/user/index.php +++ b/grade/report/user/index.php @@ -130,13 +130,13 @@ if (has_capability('moodle/grade:viewall', $context)) { $actionbar = new \gradereport_user\output\action_bar($context, $userview, null, $currentgroup); // Print header. - print_grade_page_head($courseid, 'report', 'user', ' ', false, null, true, + print_grade_page_head($courseid, 'report', 'user', false, false, null, true, null, null, null, $actionbar); echo $report->output_report_zerostate(); } else if ($userid == 0) { // Show all reports. $actionbar = new \gradereport_user\output\action_bar($context, $userview, 0, $currentgroup); - print_grade_page_head($courseid, 'report', 'user', ' ', false, null, true, + print_grade_page_head($courseid, 'report', 'user', false, false, null, true, null, null, null, $actionbar); while ($userdata = $gui->next_user()) { @@ -177,7 +177,7 @@ if (has_capability('moodle/grade:viewall', $context)) { $userheading = $gradesrenderer->user_heading($report->user, $courseid, false); // Print the page. - print_grade_page_head($courseid, 'report', 'user', ' '); + print_grade_page_head($courseid, 'report', 'user'); echo $OUTPUT->heading($userheading); diff --git a/grade/upgrade.txt b/grade/upgrade.txt index c51175a4936..420d320dd0a 100644 --- a/grade/upgrade.txt +++ b/grade/upgrade.txt @@ -1,6 +1,10 @@ This file describes API changes in /grade/* ; Information provided here is intended especially for developers. +=== 4.3 === + +* The $showtitle parameter in the print_grade_page_head function located inside grade/lib.php has been deprecated and is not used anymore. + === 4.1 === * The $importactiveurl parameter in the constructor of the core_grades\output\import_action_bar class has been deprecated and is not used anymore. * The $exportactiveurl parameter in the constructor of the core_grades\output\export_action_bar class has been deprecated and is not used anymore. diff --git a/mod/lesson/tests/behat/link_to_gradebook.feature b/mod/lesson/tests/behat/link_to_gradebook.feature index e428bea9534..6f581479c3f 100644 --- a/mod/lesson/tests/behat/link_to_gradebook.feature +++ b/mod/lesson/tests/behat/link_to_gradebook.feature @@ -44,7 +44,6 @@ Feature: link to gradebook on the end of lesson page Then I should see "Congratulations - end of lesson reached" And I should see "View grades" And I follow "View grades" - And I should see "User report" in the "page-header" "region" And I should see "Student 1" in the "region-main" "region" And I should see "Test lesson"