diff --git a/grade/lib.php b/grade/lib.php
index d52193afd9c..be143a8e0e1 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 '
| '.$student_link.' | '; @@ -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('total','grades').' (Lowest '. $all_categories[$cview]['stats']['drop']. ' Dropped)'.$total_sort_link.' '.$stats_link.' | '; } @@ -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('total','grades').' '.$stats_link.' | '; @@ -3010,7 +2995,6 @@ function grade_download_form($type='both') { $url .= '&cview='.$cview; } } - setup_and_print_groups($course, $course->groupmode, $url); echo ''; echo '
|---|