* @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.
*
* @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) {
+ $buttons=false, $shownavigation=true, $headerhelpidentifier = null, $headerhelpcomponent = null,
+ $user = null) {
global $CFG, $OUTPUT, $PAGE;
if ($active_type === 'preferences') {
}
if ($shownavigation) {
+ $navselector = null;
if ($courseid != SITEID &&
($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_DROPDOWN)) {
- $returnval .= print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return);
+ // 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 = '';
if (isset($headerhelpidentifier)) {
$output = $OUTPUT->heading_with_help($heading, $headerhelpidentifier, $headerhelpcomponent);
} else {
- $output = $OUTPUT->heading($heading);
+ if (isset($user)) {
+ $output = $OUTPUT->context_header(
+ array(
+ 'heading' => fullname($user),
+ 'user' => $user,
+ 'usercontext' => context_user::instance($user->id)
+ ), 2
+ ) . $navselector;
+ } else {
+ $output = $OUTPUT->heading($heading);
+ }
}
if ($return) {