Code Duplication    Length = 26-26 lines in 2 locations

includes/class-sensei-updates.php 1 location

@@ 1610-1635 (lines=26) @@
1607
					foreach( $course_lesson_ids[ $course_id ] AS $lesson_id ) {
1608
						$lesson_status = $lesson_user_statuses[ $lesson_id ][ $user_id ];
1609
						// If lessons are complete without needing quizzes to be passed
1610
						if ( 'passed' != $course_completion ) {
1611
							switch ( $lesson_status ) {
1612
								// A user cannot 'complete' a course if a lesson...
1613
								case 'in-progress': // ...is still in progress
1614
								case 'ungraded': // ...hasn't yet been graded
1615
									break;
1616
1617
								default:
1618
									$lessons_completed++;
1619
									break;
1620
							}
1621
						}
1622
						else {
1623
							switch ( $lesson_status ) {
1624
								case 'complete': // Lesson has no quiz/questions
1625
								case 'graded': // Lesson has quiz, but it's not important what the grade was
1626
								case 'passed': // Lesson has quiz and the user passed
1627
									$lessons_completed++;
1628
									break;
1629
1630
								// A user cannot 'complete' a course if on a lesson...
1631
								case 'failed': // ...a user failed the passmark on a quiz
1632
								default:
1633
									break;
1634
							}
1635
						}
1636
					} // Each lesson
1637
				} // Check for lessons
1638
				if ( $lessons_completed == $total_lessons ) {

includes/class-sensei-utils.php 1 location

@@ 1493-1518 (lines=26) @@
1490
			}
1491
			foreach( $all_lesson_statuses as $lesson_status ) {
1492
				// If lessons are complete without needing quizzes to be passed
1493
				if ( 'passed' != $course_completion ) {
1494
					switch ( $lesson_status->comment_approved ) {
1495
						// A user cannot 'complete' a course if a lesson...
1496
						case 'in-progress': // ...is still in progress
1497
						case 'ungraded': // ...hasn't yet been graded
1498
							break;
1499
1500
						default:
1501
							$lessons_completed++;
1502
							break;
1503
					}
1504
				}
1505
				else {
1506
					switch ( $lesson_status->comment_approved ) {
1507
						case 'complete': // Lesson has no quiz/questions
1508
						case 'graded': // Lesson has quiz, but it's not important what the grade was
1509
						case 'passed': // Lesson has quiz and the user passed
1510
							$lessons_completed++;
1511
							break;
1512
1513
						// A user cannot 'complete' a course if on a lesson...
1514
						case 'failed': // ...a user failed the passmark on a quiz
1515
						default:
1516
							break;
1517
					}
1518
				}
1519
			} // Each lesson
1520
			if ( $lessons_completed == $total_lessons ) {
1521
				$course_status = 'complete';