mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-72873 core_grades: Add general tertiary navigation
This commit is contained in:
parent
508fe3937e
commit
d1a0e4a95c
9 changed files with 415 additions and 68 deletions
118
grade/lib.php
118
grade/lib.php
|
@ -25,6 +25,9 @@
|
|||
require_once($CFG->libdir . '/gradelib.php');
|
||||
require_once($CFG->dirroot . '/grade/export/lib.php');
|
||||
|
||||
use \core_grades\output\action_bar;
|
||||
use \core_grades\output\general_action_bar;
|
||||
|
||||
/**
|
||||
* This class iterates over all users that are graded in a course.
|
||||
* Returns detailed info about users and their grades.
|
||||
|
@ -966,31 +969,29 @@ class grade_plugin_info {
|
|||
}
|
||||
|
||||
/**
|
||||
* Prints the page headers, breadcrumb trail, page heading, (optional) dropdown navigation menu and
|
||||
* (optional) navigation tabs for any gradebook page. All gradebook pages MUST use these functions
|
||||
* in favour of the usual print_header(), print_header_simple(), print_heading() etc.
|
||||
* !IMPORTANT! Use of tabs.php file in gradebook pages is forbidden unless tabs are switched off at
|
||||
* the site level for the gradebook ($CFG->grade_navmethod = GRADE_NAVMETHOD_DROPDOWN).
|
||||
* Prints the page headers, breadcrumb trail, page heading, (optional) navigation and for any gradebook page.
|
||||
* All gradebook pages MUST use these functions in favour of the usual print_header(), print_header_simple(),
|
||||
* print_heading() etc.
|
||||
*
|
||||
* @param int $courseid Course id
|
||||
* @param string $active_type The type of the current page (report, settings,
|
||||
* import, export, scales, outcomes, letters)
|
||||
* @param string $active_plugin The plugin of the current page (grader, fullview etc...)
|
||||
* @param string $heading The heading of the page. Tries to guess if none is given
|
||||
* @param int $courseid Course id
|
||||
* @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 boolean $return Whether to return (true) or echo (false) the HTML generated by this function
|
||||
* @param string $bodytags Additional attributes that will be added to the <body> tag
|
||||
* @param string $buttons Additional buttons to display on the page
|
||||
* @param boolean $shownavigation should the gradebook navigation drop down (or tabs) be shown?
|
||||
* @param string $headerhelpidentifier The help string identifier if required.
|
||||
* @param string $headerhelpcomponent The component for the help string.
|
||||
* @param stdClass $user The user object for use with the user context header.
|
||||
*
|
||||
* @param string|bool $buttons Additional buttons to display on the page
|
||||
* @param boolean $shownavigation should the gradebook navigation be shown?
|
||||
* @param string|null $headerhelpidentifier The help string identifier if required.
|
||||
* @param string|null $headerhelpcomponent The component for the help string.
|
||||
* @param stdClass|null $user The user object for use with the user context header.
|
||||
* @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.
|
||||
* @return string HTML code or nothing if $return == false
|
||||
*/
|
||||
function print_grade_page_head($courseid, $active_type, $active_plugin=null,
|
||||
$heading = false, $return=false,
|
||||
$buttons=false, $shownavigation=true, $headerhelpidentifier = null, $headerhelpcomponent = null,
|
||||
$user = null) {
|
||||
function print_grade_page_head(int $courseid, string $active_type, ?string $active_plugin = null, $heading = false,
|
||||
bool $return = false, $buttons = false, bool $shownavigation = true, ?string $headerhelpidentifier = null,
|
||||
?string $headerhelpcomponent = null, ?stdClass $user = null, ?action_bar $actionbar = null) {
|
||||
global $CFG, $OUTPUT, $PAGE;
|
||||
|
||||
// Put a warning on all gradebook pages if the course has modules currently scheduled for background deletion.
|
||||
|
@ -1024,6 +1025,8 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null,
|
|||
}
|
||||
$PAGE->set_title(get_string('grades') . ': ' . $stractive_type);
|
||||
$PAGE->set_heading($title);
|
||||
$PAGE->set_secondary_active_tab('grades');
|
||||
|
||||
if ($buttons instanceof single_button) {
|
||||
$buttons = $OUTPUT->render($buttons);
|
||||
}
|
||||
|
@ -1049,53 +1052,46 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null,
|
|||
}
|
||||
|
||||
if ($shownavigation) {
|
||||
$navselector = null;
|
||||
if ($courseid != SITEID &&
|
||||
($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_DROPDOWN)) {
|
||||
// It's absolutely essential that this grade plugin selector is shown after the user header. Just ask Fred.
|
||||
$navselector = print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, true);
|
||||
if ($return) {
|
||||
$returnval .= $navselector;
|
||||
} else if (!isset($user)) {
|
||||
echo $navselector;
|
||||
}
|
||||
}
|
||||
|
||||
$output = '';
|
||||
// Add a help dialogue box if provided.
|
||||
if (isset($headerhelpidentifier)) {
|
||||
$output = $OUTPUT->heading_with_help($heading, $headerhelpidentifier, $headerhelpcomponent);
|
||||
} else {
|
||||
if (isset($user)) {
|
||||
$output = $OUTPUT->context_header(
|
||||
array(
|
||||
'heading' => html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id,
|
||||
'course' => $courseid)), fullname($user)),
|
||||
'user' => $user,
|
||||
'usercontext' => context_user::instance($user->id)
|
||||
), 2
|
||||
) . $navselector;
|
||||
} else {
|
||||
$output = $OUTPUT->heading($heading);
|
||||
}
|
||||
$renderer = $PAGE->get_renderer('core_grades');
|
||||
// If the navigation action bar is not explicitly defined, use the general (default) action bar.
|
||||
if (!$actionbar) {
|
||||
$actionbar = new general_action_bar($PAGE->context, $PAGE->url, $active_type, $active_plugin);
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
$returnval .= $output;
|
||||
$returnval .= $renderer->render_action_bar($actionbar);
|
||||
} else {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
if ($courseid != SITEID &&
|
||||
($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_TABS)) {
|
||||
$returnval .= grade_print_tabs($active_type, $active_plugin, $plugin_info, $return);
|
||||
echo $renderer->render_action_bar($actionbar);
|
||||
}
|
||||
}
|
||||
|
||||
$returnval .= print_natural_aggregation_upgrade_notice($courseid,
|
||||
context_course::instance($courseid),
|
||||
$PAGE->url,
|
||||
$return);
|
||||
$output = '';
|
||||
// Add a help dialogue box if provided.
|
||||
if (isset($headerhelpidentifier)) {
|
||||
$output = $OUTPUT->heading_with_help($heading, $headerhelpidentifier, $headerhelpcomponent);
|
||||
} else {
|
||||
if (isset($user)) {
|
||||
$output = $OUTPUT->context_header(
|
||||
array(
|
||||
'heading' => html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id,
|
||||
'course' => $courseid)), fullname($user)),
|
||||
'user' => $user,
|
||||
'usercontext' => context_user::instance($user->id)
|
||||
), 2
|
||||
);
|
||||
} else {
|
||||
$output = $OUTPUT->heading($heading);
|
||||
}
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
$returnval .= $output;
|
||||
} else {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
$returnval .= print_natural_aggregation_upgrade_notice($courseid, context_course::instance($courseid), $PAGE->url,
|
||||
$return);
|
||||
|
||||
if ($return) {
|
||||
return $returnval;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue