Skip to content

Commit 0a23dec

Browse files
committed
MDL-26835 gradebook: grader report now marks suspended students
1 parent eb9d692 commit 0a23dec

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

grade/report/grader/lib.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,26 @@ public function load_users() {
391391
$this->users = array();
392392
$this->userselect_params = array();
393393
} else {
394-
list($usql, $params) = $DB->get_in_or_equal(array_keys($this->users), SQL_PARAMS_NAMED, 'usid0');
394+
list($usql, $uparams) = $DB->get_in_or_equal(array_keys($this->users), SQL_PARAMS_NAMED, 'usid0');
395395
$this->userselect = "AND g.userid $usql";
396-
$this->userselect_params = $params;
396+
$this->userselect_params = $uparams;
397+
398+
//add a flag to each user indicating whether their enrolment is active
399+
$sql = "SELECT ue.userid
400+
FROM {user_enrolments} ue
401+
JOIN {enrol} e ON e.id = ue.enrolid
402+
WHERE ue.userid $usql
403+
AND ue.status = :uestatus
404+
AND e.status = :estatus
405+
AND e.courseid = :courseid
406+
GROUP BY ue.userid";
407+
$coursecontext = get_course_context($this->context);
408+
$params = array_merge($uparams, array('estatus'=>ENROL_INSTANCE_ENABLED, 'uestatus'=>ENROL_USER_ACTIVE, 'courseid'=>$coursecontext->instanceid));
409+
$useractiveenrolments = $DB->get_records_sql($sql, $params);
410+
411+
foreach ($this->users as $user) {
412+
$this->users[$user->id]->suspendedenrolment = !array_key_exists($user->id, $useractiveenrolments);
413+
}
397414
}
398415

399416
return $this->users;
@@ -602,13 +619,15 @@ public function get_left_rows() {
602619

603620
$rowclasses = array('even', 'odd');
604621

622+
$suspendedstring = null;
605623
foreach ($this->users as $userid => $user) {
606624
$userrow = new html_table_row();
607625
$userrow->id = 'fixed_user_'.$userid;
608626
$userrow->attributes['class'] = 'r'.$this->rowcount++.' '.$rowclasses[$this->rowcount % 2];
609627

610628
$usercell = new html_table_cell();
611629
$usercell->attributes['class'] = 'user';
630+
612631
$usercell->header = true;
613632
$usercell->scope = 'row';
614633

@@ -618,6 +637,16 @@ public function get_left_rows() {
618637

619638
$usercell->text .= html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $this->course->id)), fullname($user));
620639

640+
if (!empty($user->suspendedenrolment)) {
641+
$usercell->attributes['class'] .= ' usersuspended';
642+
643+
//may be lots of suspended users so only get the string once
644+
if (empty($suspendedstring)) {
645+
$suspendedstring = get_string('userenrolmentsuspended', 'grades');
646+
}
647+
$usercell->text .= html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/enrolmentsuspended'), 'title'=>$suspendedstring, 'alt'=>$suspendedstring, 'class'=>'usersuspendedicon'));
648+
}
649+
621650
$userrow->cells[] = $usercell;
622651

623652
if (has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context)) {

grade/report/grader/styles.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,14 @@ text-align:left;
565565
vertical-align:middle;
566566
}
567567

568+
.path-grade-report-grader table th.usersuspended a:link {
569+
color:#111111;
570+
}
571+
572+
.path-grade-report-grader table th.usersuspended img.usersuspendedicon {
573+
vertical-align:middle;
574+
}
575+
568576
.path-grade-report-grader .yui-overlay {
569577
background-color: #FFEE69;
570578
border-color: #D4C237 #A6982B #A6982B;

lang/en/grades.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@
634634
$string['user'] = 'User';
635635
$string['usergrade'] = 'User {$a->fullname} ({$a->useridnumber}) on item {$a->gradeidnumber}';
636636
$string['userpreferences'] = 'User preferences';
637+
$string['userenrolmentsuspended'] = 'User enrolment suspended';
637638
$string['useweighted'] = 'Use weighted';
638639
$string['verbosescales'] = 'Verbose scales';
639640
$string['viewbygroup'] = 'Group';

pix/i/enrolmentsuspended.gif

88 Bytes
Loading

0 commit comments

Comments
 (0)