From de0300ea3c2e7163a7639f6e677cab47bc62bcb7 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Fri, 13 Feb 2009 08:07:27 +0000 Subject: [PATCH] MDL-12631 Fixed breadcrumbs --- grade/lib.php | 44 ++++++++++++++++++++++++----------- grade/report/grader/index.php | 2 +- lib/grade/grade_scale.php | 2 +- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/grade/lib.php b/grade/lib.php index 5db45237ab..2b26615c1a 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -352,7 +352,6 @@ function print_grade_plugin_selector($plugin_info, $return=false) { * @param string $active_type type of plugin on current page - import, export, report or edit * @param string $active_plugin active plugin type - grader, user, cvs, ... * @param boolean $return return as string - * @param string $preferences_page_url Unless false, the link to a preferences page to print in the second row of tabs next to the current link. If true, we are ON the preferences page * @return nothing or string if $return true */ function grade_print_tabs($active_type, $active_plugin, $plugin_info, $return=false) { @@ -622,7 +621,24 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) { return $plugin_info; } -function print_grade_page_head($courseid, $active_type, $active_plugin=null, $heading = false, $return=false, $meta='', $preferences_page_url=false, $buttons=false) { +/** + * 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). + * + * @param int $courseid + * @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 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 tag + * @param string $buttons Additional buttons to display on the page + * + * @return string HTML code or nothing if $return == false + */ +function print_grade_page_head($courseid, $active_type, $active_plugin=null, $heading = false, $return=false, $bodytags='', $buttons=false) { global $CFG, $COURSE; $strgrades = get_string('grades'); $plugin_info = grade_get_plugin_info($courseid, $active_type, $active_plugin); @@ -632,29 +648,31 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null, $he $stractive_type = $plugin_info['strings'][$active_type]; $navlinks = array(); + $first_link = ''; + + if ($active_type == 'settings') { + $first_link = $plugin_info['report'][$active_plugin]['link']; + } elseif ($active_type != 'report') { + $first_link = $CFG->wwwroot.'/grade/index.php?id='.$COURSE->id; + } + $navlinks[] = array('name' => $strgrades, - 'link' => $CFG->wwwroot.'/grade/index.php?id='.$COURSE->id, + 'link' => $first_link, 'type' => 'misc'); $active_type_link = ''; - if (!empty($plugin_info[$active_type]['link'])) { + if (!empty($plugin_info[$active_type]['link']) && $plugin_info[$active_type]['link'] != qualified_me()) { $active_type_link = $plugin_info[$active_type]['link']; } $navlinks[] = array('name' => $stractive_type, 'link' => $active_type_link, 'type' => 'misc'); - - if ($preferences_page_url === true) { - $navlinks[] = array('name' => $stractive_plugin, 'link' => $plugin_info[$active_type][$active_plugin]['link'], 'type' => 'misc'); - $navlinks[] = array('name' => get_string('preferences'), 'link' => null, 'type' => 'misc'); - } else { - $navlinks[] = array('name' => $stractive_plugin, 'link' => null, 'type' => 'misc'); - } + $navlinks[] = array('name' => $stractive_plugin, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); $returnval = print_header_simple($strgrades . ': ' . $stractive_type, ': ' . $stractive_type . ': ' . $stractive_plugin, $navigation, '', - $meta, true, $buttons, navmenu($COURSE), false, '', $return); + $bodytags, true, $buttons, navmenu($COURSE), false, '', $return); // Guess heading if not given explicitly if (!$heading) { @@ -667,7 +685,7 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null, $he $returnval .= print_heading($heading); if ($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_TABS) { - $returnval .= grade_print_tabs($active_type, $active_plugin, $plugin_info, $return, $preferences_page_url); + $returnval .= grade_print_tabs($active_type, $active_plugin, $plugin_info, $return); } if ($return) { diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php index fa55d4307f..f509258ea0 100644 --- a/grade/report/grader/index.php +++ b/grade/report/grader/index.php @@ -135,7 +135,7 @@ $report->load_final_grades(); /// Print header $reportname = get_string('modulename', 'gradereport_grader'); -print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, null, $report->preferences_page, $buttons); +print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, null, $buttons); echo $report->group_selector; echo '
'; diff --git a/lib/grade/grade_scale.php b/lib/grade/grade_scale.php index 779d293c19..d9666a7190 100644 --- a/lib/grade/grade_scale.php +++ b/lib/grade/grade_scale.php @@ -191,7 +191,7 @@ class grade_scale extends grade_object { public function get_nearest_item($grade) { global $DB; // Obtain nearest scale item from average - $scales_array = $DB->get_records_list('scale', array('id' => $this->id)); + $scales_array = $DB->get_records('scale', array('id' => $this->id)); $scale = $scales_array[$this->id]; $scales = explode(",", $scale->scale); -- 2.39.5