Browse Source

correct usage of group check Fixes #26

MOODLE_26_STABLE
Dan Marsden 11 years ago
parent
commit
c1596896f1
  1. 6
      locallib.php

6
locallib.php

@ -1070,7 +1070,7 @@ class attendance {
global $DB; global $DB;
if (!array_key_exists($userid, $this->userstatusesstat)) { if (!array_key_exists($userid, $this->userstatusesstat)) {
if (!empty($this->get_group_mode())) { if ($this->get_group_mode()) {
$qry = "SELECT al.statusid, count(al.statusid) AS stcnt $qry = "SELECT al.statusid, count(al.statusid) AS stcnt
FROM {attendance_log} al FROM {attendance_log} al
JOIN {attendance_sessions} ats ON al.sessionid = ats.id JOIN {attendance_sessions} ats ON al.sessionid = ats.id
@ -1142,7 +1142,7 @@ class attendance {
} else { } else {
$where = "ats.attendanceid = :aid AND ats.sessdate >= :csdate"; $where = "ats.attendanceid = :aid AND ats.sessdate >= :csdate";
} }
if (!empty($this->get_group_mode())) { if ($this->get_group_mode()) {
$sql = "SELECT ats.id, ats.sessdate, ats.groupid, al.statusid, al.remarks $sql = "SELECT ats.id, ats.sessdate, ats.groupid, al.statusid, al.remarks
FROM {attendance_sessions} ats FROM {attendance_sessions} ats
JOIN {attendance_log} al ON ats.id = al.sessionid AND al.studentid = :uid JOIN {attendance_log} al ON ats.id = al.sessionid AND al.studentid = :uid
@ -1192,7 +1192,7 @@ class attendance {
// If the array's index is a number it will not merge entries. // If the array's index is a number it will not merge entries.
// It would be better as a UNION query butunfortunatly MS SQL does not seem to support doing a DISTINCT on a the description field. // It would be better as a UNION query butunfortunatly MS SQL does not seem to support doing a DISTINCT on a the description field.
$id = $DB->sql_concat(':value', 'ats.id'); $id = $DB->sql_concat(':value', 'ats.id');
if (!empty($this->get_group_mode())) { if ($this->get_group_mode()) {
$sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, al.statusid, al.remarks $sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, al.statusid, al.remarks
FROM {attendance_sessions} ats FROM {attendance_sessions} ats
RIGHT JOIN {attendance_log} al RIGHT JOIN {attendance_log} al

Loading…
Cancel
Save