Hi @fredrikmbp ,
Thank you for the report!
Are you able to reliably reproduce this, or does it seem to happen randomly?
Would you let us know how to reproduce this step-by-step, if that’s applicable?
In your database, what does the sensei_lesson_status comment record for an affected user’s user_id show?
[As a workaround, deleting the duplicate record from the comments table manually should resolve this situation.]
Have there been any changes to your site recently – upgrades, custom code, data migration, etc?
Best,
Hi @cena,
Thank you for your reply!
I have not been able to reproduce this, over the course of 6 months there’s been 5 affected users which is not a great deal.
The comment record shows two duplicated rows sensei_lesson_status (except for the commend ID).
Deleting one of the duplicated rows does resolves the issue for the user, but not the root of this issue which is still unknown.
The site is upgraded periodically, none to my knowledge that would be the cause of this issue
I see this issue happen like you’ve described – probably 2-3 times per day with our students. We have to manually go in and remove them from the lesson (both session that will appear there) and then get the student to try complete the lesson again. It’s quite frustrating…
Hi @fredrikmbp and @alex92828 ,
We have a high priority issue open for this here: https://github.com/Automattic/sensei/issues/2748
which is thee best place to follow along for updates to the issue.
The current recommended method for ‘fixing’ this is:
– get the Code Snippets plugin (https://ww.wp.xz.cn/plugins/code-snippets)
– create a new snippet in that plugin:
add_filter( 'sensei_check_for_activity', 'sensei_filter_duplicate_user_status' );
function sensei_filter_duplicate_user_status( $comments ) {
if(! is_array($comments)) {
return $comments;
}
$found = [];
$filtered = [];
foreach ( $comments as $comment ) {
$key = $comment->comment_post_ID . '-' . $comment->comment_type . '-' . $comment->user_id;
if ( empty( $found[ $key ] ) ) {
$filtered[] = $comment;
}
$found[ $key ] = true;
}
return $filtered;
}
PLEASE NOTE THESE CAVEATS using this snippet:
While it should prevent duplicated entries causing any harm, it doesn’t delete them. There will be still some inaccuracies in the admin side, like In Progress count for a lesson, but it should resolve the issue of users getting stuck in a loop.
Best,
Cena
Thank you @cena, I’ll implement this filter to resolve the issue while you’re working on a permanent fix.
Thanks again!