diff --git a/grade/lib.php b/grade/lib.php index 43b6d358778..fcddcdb0007 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -818,12 +818,14 @@ class grade_plugin_info { * @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') { @@ -870,9 +872,16 @@ 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)) { - $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 = ''; @@ -880,7 +889,17 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null, 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) {