Hi,
Whenever I acesse the page "[moodle site]/mod/attendance/coursesummary.php" I got this error message:
"Error reading from database
Debug info: ERROR: division by zero
SELECT courseid, coursename, sum(points) / sum(maxpoints) as percentage FROM (
SELECT a.id, a.course as courseid, c.fullname as coursename, atl.studentid AS userid, COUNT(DISTINCT ats.id) AS numtakensessions,
SUM(stg.grade) AS points, SUM(stm.maxgrade) AS maxpoints
FROM mdl_attendance_sessions ats
JOIN mdl_attendance a ON a.id = ats.attendanceid
JOIN mdl_course c ON c.id = a.course
JOIN mdl_attendance_log atl ON (atl.sessionid = ats.id)
JOIN mdl_attendance_statuses stg ON (stg.id = atl.statusid AND stg.deleted = 0 AND stg.visible = 1)
JOIN (SELECT attendanceid, setnumber, MAX(grade) AS maxgrade
FROM mdl_attendance_statuses
WHERE deleted = 0
AND visible = 1
GROUP BY attendanceid, setnumber) stm
ON (stm.setnumber = ats.statusset AND stm.attendanceid = ats.attendanceid)
LEFT JOIN mdl_groups_members gm ON (gm.userid = atl.studentid AND gm.groupid = ats.groupid)
WHERE ats.sessdate >= c.startdate
AND ats.lasttaken != 0
AND ats.sessdate < $1 AND (ats.groupid = 0 or gm.id is NOT NULL)
GROUP BY a.id, a.course, c.fullname, atl.studentid
) p GROUP by courseid, coursename ORDER BY percentage ASC
[array (
0 => 1623198875,
)]
Error code: dmlreadexception
Stack trace:
line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 329 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
line 920 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
line 985 of /mod/attendance/locallib.php: call to pgsql_native_moodle_database->get_records_sql()
line 115 of /mod/attendance/coursesummary.php: call to attendance_course_users_points()"
Moodle 3.10.3+
PostgreSQL 12
PHP 7.4
Apache2
Looks like you've got an invalid status set in use somewhere that doesn't allow a grade value to be set? - see if you can work out how to reproduce that and let me know - I'll see if we can add some error checking to prevent the complete failure. - maybe by adjusting the "STM" join to only return items that have a maxgrade > 0.
Hi Dan,
Thanks for the reply.
Is this "invalid status" related to plugin configuration or it is related to some course configuration?
Ricardo
Thanks for the reply.
Is this "invalid status" related to plugin configuration or it is related to some course configuration?
Ricardo
Attendance activities use a status set with values like "passed, Late, Absent" etc - customisable by the teacher. One of those status sets will have something missing/configured that is causing it to fail. Possible an empty status set, or one that doesn't have any grade values set in the status. We need to work out what conditions cause the error and then either add some validation to the status set page, or fix the sql to ignore those attendance activities.
Hi Dan,
No changes were made to default values.
But what are you saying is that in some instance of Attendance a teacher may have locally configured the plugin with some wrong value?
Ricardo
No changes were made to default values.
But what are you saying is that in some instance of Attendance a teacher may have locally configured the plugin with some wrong value?
Ricardo
I think I understand what you mean.
So I need to find which course has the wrong setup, right?
So I need to find which course has the wrong setup, right?