Skip to content

Commit

Permalink
MDL-70110 assign: fixed ws get_submissions for groups
Browse files Browse the repository at this point in the history
  • Loading branch information
t-schroeder authored and septatrix committed Apr 24, 2021
1 parent fe04d07 commit 647c5ac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mod/assign/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,14 +754,15 @@ public static function get_submissions($assignmentids, $status = '', $since = 0,
$placeholders = array('assignid1' => $assign->get_instance()->id,
'assignid2' => $assign->get_instance()->id);

$submissionmaxattempt = 'SELECT mxs.userid, MAX(mxs.attemptnumber) AS maxattempt
$submissionmaxattempt = 'SELECT mxs.userid, mxs.groupid, MAX(mxs.attemptnumber) AS maxattempt
FROM {assign_submission} mxs
WHERE mxs.assignment = :assignid1 GROUP BY mxs.userid';
WHERE mxs.assignment = :assignid1 GROUP BY mxs.userid, mxs.groupid';

$sql = "SELECT mas.id, mas.assignment,mas.userid,".
"mas.timecreated,mas.timemodified,mas.status,mas.groupid,mas.attemptnumber ".
"FROM {assign_submission} mas ".
"JOIN ( " . $submissionmaxattempt . " ) smx ON mas.userid = smx.userid ".
"AND mas.groupid = smx.groupid ".
"WHERE mas.assignment = :assignid2 AND mas.attemptnumber = smx.maxattempt";

if (!empty($params['status'])) {
Expand Down

0 comments on commit 647c5ac

Please sign in to comment.