Title: Multiple &#8220;in-progress&#8221; statuses for same lesson
Last modified: November 17, 2020

---

# Multiple “in-progress” statuses for same lesson

 *  Resolved [fredrikmbp](https://wordpress.org/support/users/fredrikmbp/)
 * (@fredrikmbp)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-in-progress-statuses-for-same-lession/)
 * I’ve been encountering a few members of mine that cannot complete a lesson because
   of a a previous lesson have not been completed even though they just pressed 
   quiz_save.
 * I found that these users had 2 entries of in-progress status in the comments 
   table with the same comment_post_ID.
 * This puts the user in and endless loop as the function user_completed_lesson 
   in Utils on the line 1728 doesn’t take into account that multiple entries somehow
   can be present.
 * A quick and dirty fix would be to check if $_user_lesson_status is an array and
   not an object then reset the array to use the first object available on line 
   1726 in class-sensei-utils.php
    -  This topic was modified 5 years, 6 months ago by [fredrikmbp](https://wordpress.org/support/users/fredrikmbp/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Cena (a11n)](https://wordpress.org/support/users/cena/)
 * (@cena)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-in-progress-statuses-for-same-lession/#post-13688899)
 * Hi [@fredrikmbp](https://wordpress.org/support/users/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,
 *  Thread Starter [fredrikmbp](https://wordpress.org/support/users/fredrikmbp/)
 * (@fredrikmbp)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-in-progress-statuses-for-same-lession/#post-13696248)
 * Hi [@cena](https://wordpress.org/support/users/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
 *  [alex92828](https://wordpress.org/support/users/alex92828/)
 * (@alex92828)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-in-progress-statuses-for-same-lession/#post-13698461)
 * 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…
 *  [Cena (a11n)](https://wordpress.org/support/users/cena/)
 * (@cena)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-in-progress-statuses-for-same-lession/#post-13713050)
 * Hi [@fredrikmbp](https://wordpress.org/support/users/fredrikmbp/) and [@alex92828](https://wordpress.org/support/users/alex92828/),
 * We have a high priority issue open for this here: [https://github.com/Automattic/sensei/issues/2748](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://wordpress.org/plugins/code-snippets](https://wordpress.org/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
 *  Thread Starter [fredrikmbp](https://wordpress.org/support/users/fredrikmbp/)
 * (@fredrikmbp)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-in-progress-statuses-for-same-lession/#post-13713120)
 * Thank you [@cena](https://wordpress.org/support/users/cena/), I’ll implement 
   this filter to resolve the issue while you’re working on a permanent fix.
 * Thanks again!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Multiple “in-progress” statuses for same lesson’ is closed to new replies.

 * ![](https://ps.w.org/sensei-lms/assets/icon-128x128.gif?rev=2914239)
 * [Sensei LMS - Online Courses, Quizzes, & Learning](https://wordpress.org/plugins/sensei-lms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sensei-lms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sensei-lms/)
 * [Active Topics](https://wordpress.org/support/plugin/sensei-lms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sensei-lms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sensei-lms/reviews/)

## Tags

 * [duplicate](https://wordpress.org/support/topic-tag/duplicate/)

 * 5 replies
 * 3 participants
 * Last reply from: [fredrikmbp](https://wordpress.org/support/users/fredrikmbp/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/multiple-in-progress-statuses-for-same-lession/#post-13713120)
 * Status: resolved