Skip to content

Commit

Permalink
MDL-29529 Assignment: Fix regression (order by status) caused by MDL-…
Browse files Browse the repository at this point in the history
…27638
  • Loading branch information
Stephen Bourget authored and stronk7 committed Nov 11, 2011
1 parent 9d7e30f commit ee1692e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions mod/assignment/lib.php
Expand Up @@ -838,7 +838,10 @@ function display_submission($extra_javascript = '') {
if ($users) {
$select = 'SELECT u.id, u.firstname, u.lastname, u.picture, u.imagealt,
s.id AS submissionid, s.grade, s.submissioncomment,
s.timemodified, s.timemarked ';
s.timemodified, s.timemarked,
CASE WHEN s.timemarked > 0 AND s.timemarked >= s.timemodified THEN 1
ELSE 0 END AS status ';

$sql = 'FROM '.$CFG->prefix.'user u '.
'LEFT JOIN '.$CFG->prefix.'assignment_submissions s ON u.id = s.userid
AND s.assignment = '.$this->assignment->id.' '.
Expand All @@ -850,8 +853,6 @@ function display_submission($extra_javascript = '') {

if (($auser = get_records_sql($select.$sql.$sort, $offset+1, 1)) !== false) {
$nextuser = array_shift($auser);
/// Calculate user status
$nextuser->status = ($nextuser->timemarked > 0) && ($nextuser->timemarked >= $nextuser->timemodified);
$nextid = $nextuser->id;
}
}
Expand Down Expand Up @@ -1166,7 +1167,10 @@ function display_submissions($message='') {

$select = 'SELECT u.id, u.firstname, u.lastname, u.picture, u.imagealt,
s.id AS submissionid, s.grade, s.submissioncomment,
s.timemodified, s.timemarked ';
s.timemodified, s.timemarked,
CASE WHEN s.timemarked > 0 AND s.timemarked >= s.timemodified THEN 1
ELSE 0 END AS status ';

$sql = 'FROM '.$CFG->prefix.'user u '.
'LEFT JOIN '.$CFG->prefix.'assignment_submissions s ON u.id = s.userid
AND s.assignment = '.$this->assignment->id.' '.
Expand All @@ -1192,8 +1196,6 @@ function display_submissions($message='') {
$locked_overridden = 'overridden';
}

/// Calculate user status
$auser->status = ($auser->timemarked > 0) && ($auser->timemarked >= $auser->timemodified);
$picture = print_user_picture($auser, $course->id, $auser->picture, false, true);

if (empty($auser->submissionid)) {
Expand Down

0 comments on commit ee1692e

Please sign in to comment.