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.
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. Theupdate_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.