catalyst / totara-mod-ojt

https://github.com/catalyst/totara-mod-ojt/wiki
5 stars 21 forks source link

Remove incorrect API calls in ojt_archive_completion() #50

Closed agwells closed 2 months ago

agwells commented 2 months ago

As can be seen in the Totara core activities, plugins aren't meant to actually clear records from the core completion tables within their archive_completion callback function. It's only meant to clear data in custom tables for the plugin.

In the case of OJT, the call to $completion->update_state() was breaking the reset of course completion when a user's completion status was archived due to a recertification window opening. The update_state() call fired an event, which triggered an observer, which re-evaluated the course completion status of the activity from the cache, and since the cache had not yet been cleared, it re-marked it as complete.

Removing this code allows the core code to correctly clear the completion status without this problem.