From 68d0c80c2136e133395d823d8ff48634444e921b Mon Sep 17 00:00:00 2001 From: skodak Date: Wed, 16 May 2007 20:25:12 +0000 Subject: [PATCH] MDL-9761 Student's Gradebook view doesn't follow defaults establ;ished by the Instructor; patch by Jason Skinner; merged from MOODLE_18_STABLE --- grade/lib.php | 62 +++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/grade/lib.php b/grade/lib.php index d52193afd9..be143a8e0e 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -311,12 +311,9 @@ function grade_get_formatted_grades() { } - if (isset($_REQUEST['group'])) { - $group = clean_param($_REQUEST['group'], PARAM_INT); - } // if the user has selected a group to view by get the group members - if (isset($group) && $group != 0) { - $groupmembers = get_group_users($group); + if ($currentgroup = get_current_group($course->id)) { + $groupmembers = get_group_users($currentgroup); } // this next block catches any students who do not have a grade for any item in a particular category @@ -1064,7 +1061,7 @@ function grade_set_preferences($course, $newprefs) { } -function grade_preferences_menu($action, $course, $group=0) { +function grade_preferences_menu($action, $course) { if (!has_capability('moodle/course:managegrades', get_context_instance(CONTEXT_COURSE, $course->id))) { return; @@ -1206,17 +1203,7 @@ function grade_download($download, $id) { $stractivityreport = get_string("activityreport"); /// Check to see if groups are being used in this course - if ($groupmode = groupmode($course)) { // Groups are being used - if (isset($_GET['group'])) { - $changegroup = $_GET['group']; /// 0 or higher - } else { - $changegroup = -1; /// This means no group change was specified - } - - $currentgroup = get_and_set_current_group($course, $groupmode, $changegroup); - } else { - $currentgroup = false; - } + $currentgroup = get_current_group($course->id); if ($currentgroup) { $students = get_group_students($currentgroup, "u.lastname ASC"); @@ -1741,13 +1728,12 @@ function grade_view_category_grades($view_by_student) { global $course; global $USER; global $preferences; - global $group; $context = get_context_instance(CONTEXT_COURSE, $course->id); // if can't see course grades, print single grade view if (!has_capability('moodle/course:viewcoursegrades', $context)) { - return print_student_grade($USER, $course); + $view_by_student = $USER->id; } if ($preferences->use_advanced == 0) { @@ -1783,11 +1769,11 @@ function grade_view_category_grades($view_by_student) { $student_heading_link = get_string('student','grades'); //only set sorting links if more than one student displayed. if ($view_by_student == -1) { - $student_heading_link .='
'.get_string('sortbylastname','grades').''; - $student_heading_link .= '
'.get_string('sortbyfirstname','grades').''; + $student_heading_link .='
'.get_string('sortbylastname','grades').''; + $student_heading_link .= '
'.get_string('sortbyfirstname','grades').''; } else { - $student_heading_link .= '
'.get_string('showallstudents','grades').''; + $student_heading_link .= '
'.get_string('showallstudents','grades').''; } } echo ''; @@ -1848,7 +1834,7 @@ function grade_view_category_grades($view_by_student) { $student_link = ''; } else { - $student_link = ''; + $student_link = ''; } $student_link .= $grades_by_student[$student]['student_data']['lastname'].', '.$grades_by_student[$student]['student_data']['firstname'].''; $row .= ''; @@ -1933,14 +1919,14 @@ function grade_view_category_grades($view_by_student) { if ($first == 0) { if (has_capability('moodle/course:viewcoursegrades', $context) && $view_by_student == -1) { - $total_sort_link = ''.get_string('highgradedescending','grades').''; - $total_sort_link .= ''.get_string('highgradeascending','grades').''; + $total_sort_link = ''.get_string('highgradedescending','grades').''; + $total_sort_link .= ''.get_string('highgradeascending','grades').''; } else { $total_sort_link = ''; } - $stats_link = ''.get_string('statslink','grades').''; + $stats_link = ''.get_string('statslink','grades').''; if ($all_categories[$cview]['stats']['drop'] != 0) { $header .= ''; } @@ -2039,7 +2025,6 @@ function grade_view_all_grades($view_by_student) { // if mode=='grade' then we a global $CFG; global $course; global $USER; - global $group; // yu: fix for 5814 global $preferences; if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) { @@ -2048,7 +2033,7 @@ function grade_view_all_grades($view_by_student) { // if mode=='grade' then we a // if can't see course grades, print single grade view if (!has_capability('moodle/course:viewcoursegrades', $context)) { - return print_student_grade($USER, $course); + $view_by_student = $USER->id; } list($grades_by_student, $all_categories) = grade_get_formatted_grades(); @@ -2078,8 +2063,8 @@ function grade_view_all_grades($view_by_student) { // if mode=='grade' then we a if (has_capability('moodle/course:viewcoursegrades', $context)) { $student_heading_link = get_string('student','grades'); if ($view_by_student == -1) { - $student_heading_link .='
'.get_string('sortbylastname','grades').'
'; - $student_heading_link .= '
'.get_string('sortbyfirstname','grades').'
'; + $student_heading_link .='
'.get_string('sortbylastname','grades').'
'; + $student_heading_link .= '
'.get_string('sortbyfirstname','grades').'
'; } else { $student_heading_link .= '
'.get_string('showallstudents','grades').''; @@ -2184,14 +2169,14 @@ function grade_view_all_grades($view_by_student) { // if mode=='grade' then we a } if (has_capability('moodle/course:viewcoursegrades', $context) && $view_by_student == -1) { - $grade_sort_link = ''.get_string('highgradedescending','grades').''; - $grade_sort_link .= ''.get_string('highgradeascending','grades').''; - $points_sort_link = ''.get_string('pointsdescending','grades').''; - $points_sort_link .= ''.get_string('pointsascending','grades').''; - $weighted_sort_link = ''.get_string('weighteddescending','grades').''; - $weighted_sort_link .= ''.get_string('weightedascending','grades').''; - $percent_sort_link = ''.get_string('percentdescending','grades').''; - $percent_sort_link .= ''.get_string('percentascending','grades').''; + $grade_sort_link = ''.get_string('highgradedescending','grades').''; + $grade_sort_link .= ''.get_string('highgradeascending','grades').''; + $points_sort_link = ''.get_string('pointsdescending','grades').''; + $points_sort_link .= ''.get_string('pointsascending','grades').''; + $weighted_sort_link = ''.get_string('weighteddescending','grades').''; + $weighted_sort_link .= ''.get_string('weightedascending','grades').''; + $percent_sort_link = ''.get_string('percentdescending','grades').''; + $percent_sort_link .= ''.get_string('percentascending','grades').''; } $stats_link = ''.get_string('statslink','grades').''; $header .= ''; @@ -3010,7 +2995,6 @@ function grade_download_form($type='both') { $url .= '&cview='.$cview; } } - setup_and_print_groups($course, $course->groupmode, $url); echo ''; echo '
'.$student_link.''.get_string('total','grades').'  (Lowest '. $all_categories[$cview]['stats']['drop']. ' Dropped)'.$total_sort_link.' '.$stats_link.''.get_string('total','grades').' '.$stats_link.'
'; -- 2.39.5