Browse Source

Simplifying quey in compute_users_points function

MOODLE_31_STABLE
Antonio Carlos Mariani 9 years ago
parent
commit
1af298d4e4
  1. 7
      classes/summary.php

7
classes/summary.php

@ -186,8 +186,8 @@ class mod_attendance_summary {
$where .= ' AND ats.groupid = 0'; $where .= ' AND ats.groupid = 0';
} }
$sql = "SELECT userid, COUNT(*) AS numtakensessions, SUM(grade) AS points, SUM(maxgrade) AS maxpoints $sql = " SELECT atl.studentid AS userid, COUNT(DISTINCT ats.id) AS numtakensessions,
FROM (SELECT atl.studentid AS userid, ats.id AS sessionid, stg.grade, stm.maxgrade SUM(stg.grade) AS points, SUM(stm.maxgrade) AS maxpoints
FROM {attendance_sessions} ats FROM {attendance_sessions} ats
JOIN {attendance_log} atl ON (atl.sessionid = ats.id) JOIN {attendance_log} atl ON (atl.sessionid = ats.id)
JOIN {attendance_statuses} stg ON (stg.id = atl.statusid AND stg.deleted = 0 AND stg.visible = 1) JOIN {attendance_statuses} stg ON (stg.id = atl.statusid AND stg.deleted = 0 AND stg.visible = 1)
@ -203,8 +203,7 @@ class mod_attendance_summary {
AND ats.sessdate >= :cstartdate AND ats.sessdate >= :cstartdate
AND ats.lasttakenby != 0 AND ats.lasttakenby != 0
{$where} {$where}
) sess GROUP BY atl.studentid";
GROUP BY userid";
$this->userspoints = $DB->get_records_sql($sql, $params); $this->userspoints = $DB->get_records_sql($sql, $params);
} }

Loading…
Cancel
Save