Merge branch 'MDL-77144-master' of https://github.com/davewoloszyn/moodle

This commit is contained in:
Andrew Nicols 2023-05-15 21:59:24 +08:00
commit c25b54d12e
No known key found for this signature in database
GPG key ID: 6D1E3157C8CFBF14
12 changed files with 28 additions and 38 deletions

View file

@ -92,7 +92,7 @@ if (!$edit) {
echo $renderer->render_action_bar($actionbar); echo $renderer->render_action_bar($actionbar);
echo $OUTPUT->heading($heading); echo $OUTPUT->heading($heading);
} else { } 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); true, null, null, null, $actionbar);
} }

View file

@ -172,7 +172,7 @@ if ($scales = grade_scale::fetch_all_global()) {
$actionbar = new \core_grades\output\scales_action_bar($context); $actionbar = new \core_grades\output\scales_action_bar($context);
if ($courseid) { 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); false, false, true, null, null, null, $actionbar);
} else { } else {
$renderer = $PAGE->get_renderer('core_grades'); $renderer = $PAGE->get_renderer('core_grades');

View file

@ -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. // 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); $settings = grade_get_settings($course->id);

View file

@ -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); $actionbar = new \core_grades\output\gradebook_setup_action_bar($context);
print_grade_page_head($courseid, 'settings', 'setup', get_string('gradebooksetup', 'grades'), print_grade_page_head($courseid, 'settings', 'setup', false,
false, false, true, null, null, null, $actionbar, false); false, false, true, null, null, null, $actionbar);
// Print Table of categories and items // Print Table of categories and items
echo $OUTPUT->box_start('gradetreebox generalbox'); echo $OUTPUT->box_start('gradetreebox generalbox');

View file

@ -842,7 +842,7 @@ class grade_plugin_info {
* @param string $active_type The type of the current page (report, settings, * @param string $active_type The type of the current page (report, settings,
* import, export, scales, outcomes, letters) * import, export, scales, outcomes, letters)
* @param string|null $active_plugin The plugin of the current page (grader, fullview etc...) * @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 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 string|bool $buttons Additional buttons to display on the page
* @param boolean $shownavigation should the gradebook navigation be shown? * @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 * @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 * to true. If $actionbar is not explicitly defined, the general action bar
* (\core_grades\output\general_action_bar) will be used by default. * (\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 * @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, 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; 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. // Put a warning on all gradebook pages if the course has modules currently scheduled for background deletion.
require_once($CFG->dirroot . '/course/lib.php'); require_once($CFG->dirroot . '/course/lib.php');
if (course_modules_pending_deletion($courseid, true)) { 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); $plugin_info = grade_get_plugin_info($courseid, $active_type, $active_plugin);
// Determine the string of the 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]; $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') { if ($active_type == 'report') {
$PAGE->set_pagelayout('report'); $PAGE->set_pagelayout('report');
} else { } else {
$PAGE->set_pagelayout('admin'); $PAGE->set_pagelayout('admin');
} }
$PAGE->set_title(get_string('grades') . ': ' . $stractive_type); $PAGE->set_title(get_string('grades') . ': ' . $stractive_type);
$PAGE->set_heading($title); $PAGE->set_heading($PAGE->course->fullname);
$PAGE->set_secondary_active_tab('grades'); $PAGE->set_secondary_active_tab('grades');
if ($buttons instanceof single_button) { if ($buttons instanceof single_button) {
@ -914,15 +909,6 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti
echo $returnval; echo $returnval;
} }
// Guess heading if not given explicitly
if (!$heading) {
$heading = $stractive_plugin;
}
if (!$showtitle) {
$heading = '';
}
if ($shownavigation) { if ($shownavigation) {
$renderer = $PAGE->get_renderer('core_grades'); $renderer = $PAGE->get_renderer('core_grades');
// If the navigation action bar is not explicitly defined, use the general (default) action bar. // 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 = ''; $output = '';
// Add a help dialogue box if provided. // Add a help dialogue box if provided.
if (isset($headerhelpidentifier)) { if (isset($headerhelpidentifier)) {

View file

@ -138,8 +138,8 @@ $PAGE->requires->js_call_amd('gradereport_grader/collapse', 'init', [
$numusers = $report->get_numusers(true, true); $numusers = $report->get_numusers(true, true);
$actionbar = new \gradereport_grader\output\action_bar($context, $report, $numusers); $actionbar = new \gradereport_grader\output\action_bar($context, $report, $numusers);
print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons, true, print_grade_page_head($COURSE->id, 'report', 'grader', false, false, $buttons, true,
null, null, null, $actionbar, false); null, null, null, $actionbar);
// make sure separate group does not prevent view // make sure separate group does not prevent view
if ($report->currentgroup == -2) { if ($report->currentgroup == -2) {

View file

@ -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 USER has admin capability, print a link to the site config page for this report
if (has_capability('moodle/site:config', $systemcontext)) { if (has_capability('moodle/site:config', $systemcontext)) {

View file

@ -110,8 +110,7 @@ if ($table->is_downloading()) {
// Print header. // Print header.
$actionbar = new \core_grades\output\general_action_bar($context, $actionbar = new \core_grades\output\general_action_bar($context,
new moodle_url('/grade/report/history/index.php', ['id' => $courseid]), 'report', 'history'); new moodle_url('/grade/report/history/index.php', ['id' => $courseid]), 'report', 'history');
print_grade_page_head($COURSE->id, 'report', 'history', get_string('pluginname', print_grade_page_head($COURSE->id, 'report', 'history', false, false, false, true, null, null,
'gradereport_history'), false, false, true, null, null,
null, $actionbar); null, $actionbar);
$mform->display(); $mform->display();

View file

@ -47,7 +47,7 @@ require_capability('moodle/grade:viewall', $context);
print_grade_page_head($courseid, 'report', 'summary', false, print_grade_page_head($courseid, 'report', 'summary', false,
false, false, true, null, null, false, false, true, null, null,
null, null, false); null, null);
$report = system_report_factory::create(summary::class, context_course::instance($courseid)); $report = system_report_factory::create(summary::class, context_course::instance($courseid));

View file

@ -130,13 +130,13 @@ if (has_capability('moodle/grade:viewall', $context)) {
$actionbar = new \gradereport_user\output\action_bar($context, $userview, null, $currentgroup); $actionbar = new \gradereport_user\output\action_bar($context, $userview, null, $currentgroup);
// Print header. // 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); null, null, null, $actionbar);
echo $report->output_report_zerostate(); echo $report->output_report_zerostate();
} else if ($userid == 0) { // Show all reports. } else if ($userid == 0) { // Show all reports.
$actionbar = new \gradereport_user\output\action_bar($context, $userview, 0, $currentgroup); $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); null, null, null, $actionbar);
while ($userdata = $gui->next_user()) { while ($userdata = $gui->next_user()) {
@ -177,7 +177,7 @@ if (has_capability('moodle/grade:viewall', $context)) {
$userheading = $gradesrenderer->user_heading($report->user, $courseid, false); $userheading = $gradesrenderer->user_heading($report->user, $courseid, false);
// Print the page. // Print the page.
print_grade_page_head($courseid, 'report', 'user', ' '); print_grade_page_head($courseid, 'report', 'user');
echo $OUTPUT->heading($userheading); echo $OUTPUT->heading($userheading);

View file

@ -1,6 +1,10 @@
This file describes API changes in /grade/* ; This file describes API changes in /grade/* ;
Information provided here is intended especially for developers. 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 === === 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 $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. * The $exportactiveurl parameter in the constructor of the core_grades\output\export_action_bar class has been deprecated and is not used anymore.

View file

@ -44,7 +44,6 @@ Feature: link to gradebook on the end of lesson page
Then I should see "Congratulations - end of lesson reached" Then I should see "Congratulations - end of lesson reached"
And I should see "View grades" And I should see "View grades"
And I follow "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 "Student 1" in the "region-main" "region"
And I should see "Test lesson" And I should see "Test lesson"