|
|
@ -1070,6 +1070,20 @@ class attendance { |
|
|
|
global $DB; |
|
|
|
|
|
|
|
if (!array_key_exists($userid, $this->userstatusesstat)) { |
|
|
|
if (!empty($this->cm->groupmode)) { |
|
|
|
$qry = "SELECT al.statusid, count(al.statusid) AS stcnt |
|
|
|
FROM {attendance_log} al |
|
|
|
JOIN {attendance_sessions} ats ON al.sessionid = ats.id |
|
|
|
JOIN {groups_members} gm ON gm.userid = al.studentid AND gm.groupid = ats.groupid |
|
|
|
WHERE ats.attendanceid = :aid AND |
|
|
|
ats.sessdate >= :cstartdate AND |
|
|
|
al.studentid = :uid |
|
|
|
GROUP BY al.statusid"; |
|
|
|
$params = array( |
|
|
|
'aid' => $this->id, |
|
|
|
'cstartdate' => $this->course->startdate, |
|
|
|
'uid' => $userid); |
|
|
|
} else { |
|
|
|
$qry = "SELECT al.statusid, count(al.statusid) AS stcnt |
|
|
|
FROM {attendance_log} al |
|
|
|
JOIN {attendance_sessions} ats |
|
|
@ -1082,6 +1096,7 @@ class attendance { |
|
|
|
'aid' => $this->id, |
|
|
|
'cstartdate' => $this->course->startdate, |
|
|
|
'uid' => $userid); |
|
|
|
} |
|
|
|
|
|
|
|
$this->userstatusesstat[$userid] = $DB->get_records_sql($qry, $params); |
|
|
|
} |
|
|
@ -1127,7 +1142,22 @@ class attendance { |
|
|
|
} else { |
|
|
|
$where = "ats.attendanceid = :aid AND ats.sessdate >= :csdate"; |
|
|
|
} |
|
|
|
if (!empty($this->cm->groupmode)) { |
|
|
|
$sql = "SELECT ats.id, ats.sessdate, ats.groupid, al.statusid, al.remarks |
|
|
|
FROM {attendance_sessions} ats |
|
|
|
JOIN {attendance_log} al ON ats.id = al.sessionid AND al.studentid = :uid |
|
|
|
JOIN {groups_members} gm ON gm.userid = al.studentid AND gm.groupid = ats.groupid |
|
|
|
WHERE $where |
|
|
|
ORDER BY ats.sessdate ASC"; |
|
|
|
|
|
|
|
$params = array( |
|
|
|
'uid' => $userid, |
|
|
|
'aid' => $this->id, |
|
|
|
'csdate' => $this->course->startdate, |
|
|
|
'sdate' => $this->pageparams->startdate, |
|
|
|
'edate' => $this->pageparams->enddate); |
|
|
|
|
|
|
|
} else { |
|
|
|
$sql = "SELECT ats.id, ats.sessdate, ats.groupid, al.statusid, al.remarks |
|
|
|
FROM {attendance_sessions} ats |
|
|
|
JOIN {attendance_log} al |
|
|
@ -1141,6 +1171,7 @@ class attendance { |
|
|
|
'csdate' => $this->course->startdate, |
|
|
|
'sdate' => $this->pageparams->startdate, |
|
|
|
'edate' => $this->pageparams->enddate); |
|
|
|
} |
|
|
|
$sessions = $DB->get_records_sql($sql, $params); |
|
|
|
|
|
|
|
return $sessions; |
|
|
|