Skip to content

Commit 92b3bc1

Browse files
committed
fix delayed courses table filter workflow
1 parent 3679e12 commit 92b3bc1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

classes/local/table/delayed_courses_table.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,16 @@ public function __construct($filterdata) {
7878
$fields .= 'null as workflowid, null as workflow, null AS workflowdelay, null AS workflowcount, ';
7979
}
8080

81-
if ($selectglobaldelays) {
81+
if ($selectglobaldelays && !$selectseperatedelays) { // Only globaldelays.
8282
$fields .= 'd.delayeduntil AS globaldelay, ';
83-
} else {
84-
$fields .= 'null AS globaldelay, ';
83+
$fields .= 'd.delaytype as delaytype ';
84+
} else if (!$selectglobaldelays) { // Only workflowdelays.
85+
$fields .= 'null AS globaldelay, wfdelay.workflowdelay, ';
86+
$fields .= 'wfdelay.delaytype as delaytype ';
87+
} else { // Both.
88+
$fields .= 'd.delayeduntil AS globaldelay, wfdelay.workflowdelay, ';
89+
$fields .= 'COALESCE(d.delaytype, wfdelay.delaytype) as delaytype ';
8590
}
86-
$fields .= 'COALESCE(wfdelay.delaytype, d.delaytype) as delaytype ';
8791

8892
$params = [];
8993
$where = ["TRUE"];
@@ -97,7 +101,7 @@ public function __construct($filterdata) {
97101
// For every course, add information about delays per workflow.
98102
'LEFT JOIN (' .
99103
'SELECT dw.courseid, dw.workflowid, w.title as workflow, ' .
100-
'dw.delayeduntil as workflowdelay,maxtable.wfcount as workflowcount, dw.delaytype ' .
104+
'dw.delayeduntil as workflowdelay, maxtable.wfcount as workflowcount, dw.delaytype ' .
101105
'FROM ( ' .
102106
'SELECT courseid, MAX(dw.id) AS maxid, COUNT(*) AS wfcount ' .
103107
'FROM {tool_lifecycle_delayed_workf} dw ' .
@@ -111,7 +115,7 @@ public function __construct($filterdata) {
111115
$params['workflowid'] = $workflowfilterid;
112116
}
113117

114-
$from .= 'GROUP BY courseid ' .
118+
$from .= ' GROUP BY courseid ' .
115119
') maxtable ' .
116120
'JOIN {tool_lifecycle_delayed_workf} dw ON maxtable.maxid = dw.id ' .
117121
'JOIN {tool_lifecycle_workflow} w ON dw.workflowid = w.id ' .
@@ -152,7 +156,6 @@ public function __construct($filterdata) {
152156
get_string('coursename', 'tool_lifecycle'),
153157
get_string('category'),
154158
get_string('delays', 'tool_lifecycle'),
155-
get_string('type', 'tool_lifecycle'),
156159
get_string('tools', 'tool_lifecycle'),
157160
]);
158161
}

0 commit comments

Comments
 (0)