Skip to content

Commit

Permalink
MDL-66147 mod_assign: grading table duedate column updates
Browse files Browse the repository at this point in the history
Couple of changes:
- The duedate, cutoffdate and allowsubmissionsfromdate are now always
shown for relative dates courses.
- When relative dates mode is enabled, calculate and apply the enrolment
start offset to the due date in SQL. No changes to col_duedate needed.
Sorting is supported.
  • Loading branch information
snake committed Aug 13, 2019
1 parent 9bf91ea commit c0bb682
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion mod/assign/gradingtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ public function __construct(assign $assignment,
ON u.id = uf.userid
AND uf.assignment = :assignmentid3 ';

if ($this->assignment->get_course()->relativedatesmode) {
$params['courseid1'] = $this->assignment->get_course()->id;
$from .= ' LEFT JOIN (
SELECT ue1.userid as enroluserid,
CASE WHEN MIN(ue1.timestart - c2.startdate) < 0 THEN 0 ELSE MIN(ue1.timestart - c2.startdate) END as enrolstartoffset
FROM {enrol} e1
JOIN {user_enrolments} ue1
ON (ue1.enrolid = e1.id AND ue1.status = 0)
JOIN {course} c2
ON c2.id = e1.courseid
WHERE e1.courseid = :courseid1 AND e1.status = 0
GROUP BY ue1.userid
) enroloffset
ON (enroloffset.enroluserid = u.id) ';
}

$hasoverrides = $this->assignment->has_overrides();

if ($hasoverrides) {
Expand Down Expand Up @@ -242,6 +258,14 @@ public function __construct(assign $assignment,
)
) effective ON effective.priority = priority.priority AND effective.userid = priority.userid ';
} else if ($this->assignment->get_course()->relativedatesmode) {
// In relative dates mode and when we don't have overrides, include the
// duedate, cutoffdate and allowsubmissionsfrom date anyway as this information is useful and can vary.
$params['assignmentid5'] = (int)$this->assignment->get_instance()->id;
$fields .= ', a.duedate + enroloffset.enrolstartoffset as duedate, ';
$fields .= 'a.allowsubmissionsfromdate, ';
$fields .= 'a.cutoffdate ';
$from .= 'JOIN {assign} a ON a.id = :assignmentid5 ';
}

if (!empty($this->assignment->get_instance()->blindmarking)) {
Expand Down Expand Up @@ -377,7 +401,7 @@ public function __construct(assign $assignment,
$columns[] = 'status';
$headers[] = get_string('status', 'assign');

if ($hasoverrides) {
if ($hasoverrides || $this->assignment->get_course()->relativedatesmode) {
// Allowsubmissionsfromdate.
$columns[] = 'allowsubmissionsfromdate';
$headers[] = get_string('allowsubmissionsfromdate', 'assign');
Expand Down

0 comments on commit c0bb682

Please sign in to comment.