Browse files

MDL-26835 gradebook: grader report now marks suspended students

  • Loading branch information...
1 parent eb9d692 commit 0a23dec07afb043ac6c1328824b8d34d13d0b822 @andyjdavis andyjdavis committed Apr 11, 2011
View
33 grade/report/grader/lib.php
@@ -391,9 +391,26 @@ public function load_users() {
$this->users = array();
$this->userselect_params = array();
} else {
- list($usql, $params) = $DB->get_in_or_equal(array_keys($this->users), SQL_PARAMS_NAMED, 'usid0');
+ list($usql, $uparams) = $DB->get_in_or_equal(array_keys($this->users), SQL_PARAMS_NAMED, 'usid0');
$this->userselect = "AND g.userid $usql";
- $this->userselect_params = $params;
+ $this->userselect_params = $uparams;
+
+ //add a flag to each user indicating whether their enrolment is active
+ $sql = "SELECT ue.userid
+ FROM {user_enrolments} ue
+ JOIN {enrol} e ON e.id = ue.enrolid
+ WHERE ue.userid $usql
+ AND ue.status = :uestatus
+ AND e.status = :estatus
+ AND e.courseid = :courseid
+ GROUP BY ue.userid";
+ $coursecontext = get_course_context($this->context);
+ $params = array_merge($uparams, array('estatus'=>ENROL_INSTANCE_ENABLED, 'uestatus'=>ENROL_USER_ACTIVE, 'courseid'=>$coursecontext->instanceid));
+ $useractiveenrolments = $DB->get_records_sql($sql, $params);
+
+ foreach ($this->users as $user) {
+ $this->users[$user->id]->suspendedenrolment = !array_key_exists($user->id, $useractiveenrolments);
+ }
}
return $this->users;
@@ -602,13 +619,15 @@ public function get_left_rows() {
$rowclasses = array('even', 'odd');
+ $suspendedstring = null;
foreach ($this->users as $userid => $user) {
$userrow = new html_table_row();
$userrow->id = 'fixed_user_'.$userid;
$userrow->attributes['class'] = 'r'.$this->rowcount++.' '.$rowclasses[$this->rowcount % 2];
$usercell = new html_table_cell();
$usercell->attributes['class'] = 'user';
+
$usercell->header = true;
$usercell->scope = 'row';
@@ -618,6 +637,16 @@ public function get_left_rows() {
$usercell->text .= html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $this->course->id)), fullname($user));
+ if (!empty($user->suspendedenrolment)) {
+ $usercell->attributes['class'] .= ' usersuspended';
+
+ //may be lots of suspended users so only get the string once
+ if (empty($suspendedstring)) {
+ $suspendedstring = get_string('userenrolmentsuspended', 'grades');
+ }
+ $usercell->text .= html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/enrolmentsuspended'), 'title'=>$suspendedstring, 'alt'=>$suspendedstring, 'class'=>'usersuspendedicon'));
+ }
+
$userrow->cells[] = $usercell;
if (has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context)) {
View
8 grade/report/grader/styles.css
@@ -565,6 +565,14 @@ text-align:left;
vertical-align:middle;
}
+.path-grade-report-grader table th.usersuspended a:link {
+ color:#111111;
+}
+
+.path-grade-report-grader table th.usersuspended img.usersuspendedicon {
+vertical-align:middle;
+}
+
.path-grade-report-grader .yui-overlay {
background-color: #FFEE69;
border-color: #D4C237 #A6982B #A6982B;
View
1 lang/en/grades.php
@@ -634,6 +634,7 @@
$string['user'] = 'User';
$string['usergrade'] = 'User {$a->fullname} ({$a->useridnumber}) on item {$a->gradeidnumber}';
$string['userpreferences'] = 'User preferences';
+$string['userenrolmentsuspended'] = 'User enrolment suspended';
$string['useweighted'] = 'Use weighted';
$string['verbosescales'] = 'Verbose scales';
$string['viewbygroup'] = 'Group';
View
BIN pix/i/enrolmentsuspended.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0a23dec

Please sign in to comment.