-
Bug
-
Resolution: Fixed
-
Critical
-
2.0.3, 2.1
-
None
-
MOODLE_20_STABLE, MOODLE_21_STABLE
-
MOODLE_20_STABLE
-
MDL-28021-master -
We have a client heavily using activity completion within their course, and users sometimes get stuck with activities showing as not completed, despite the activity completion report showing them completion. Sometimes the completion state can even spontaneously reverse.
I tracked this down to having duplicate completion records for each activity, i.e the records in prefix_course_modules_completion are not unique by (userid, cmid) which some of the code seems to assume e.g use of get_record. Our DB is postgres but any DB can return the records in any order it likes, so results are inconsistent.
I have resolved this in my patch (will github soon) by only using the latest record in the php code, as the database is not indexed on time so an ORDER BY is not a trivial option.
If it is intended for course_modules_completion to be unique by (userid, cmid) then this must be enforced by code & UNIQUE INDEX, and corrected by an upgrade script. If an audit trail of completion states should exist, then either my fix can be used or the table should be indexed by time and only the most recent records used.
For now, my patch will resolve the immediate issue and allow students to progress in their courses.