Code Duplication    Length = 7-8 lines in 5 locations

includes/class-sensei-quiz.php 4 locations

@@ 169-176 (lines=8) @@
166
        }
167
168
        // make sure the parameters are valid before continuing
169
		if( empty( $lesson_id ) || empty( $user_id )
170
			|| 'lesson' != get_post_type( $lesson_id )
171
			||!get_userdata( $user_id )
172
			|| !is_array( $quiz_answers ) ){
173
174
			return false;
175
176
		}
177
178
179
        // start the lesson before saving the data in case the user has not started the lesson
@@ 533-540 (lines=8) @@
530
         }
531
532
         // make sure the parameters are valid before continuing
533
         if( empty( $lesson_id ) || empty( $user_id )
534
             || 'lesson' != get_post_type( $lesson_id )
535
             ||!get_userdata( $user_id )
536
             || !is_array( $quiz_answers ) ){
537
538
             return false;
539
540
         }
541
542
         // Default grade
543
         $grade = 0;
@@ 722-729 (lines=8) @@
719
         }
720
721
         // make sure the parameters are valid before continuing
722
         if( empty( $lesson_id ) || empty( $user_id )
723
             || 'lesson' != get_post_type( $lesson_id )
724
             ||!get_userdata( $user_id )
725
             || !is_array( $quiz_grades ) ){
726
727
             return false;
728
729
         }
730
731
         $success = false;
732
@@ 871-878 (lines=8) @@
868
    public function save_user_answers_feedback( $answers_feedback, $lesson_id , $user_id = 0 ){
869
870
        // make sure the parameters are valid before continuing
871
        if( empty( $lesson_id ) || empty( $user_id )
872
            || 'lesson' != get_post_type( $lesson_id )
873
            ||!get_userdata( $user_id )
874
            || !is_array( $answers_feedback ) ){
875
876
            return false;
877
878
        }
879
880
881
        // check if the lesson is started before saving, if not start the lesson for the user

includes/class-sensei-lesson.php 1 location

@@ 3440-3446 (lines=7) @@
3437
     */
3438
    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3439
3440
        if( empty( $lesson_id ) || empty( $user_id )
3441
        || 'lesson' != get_post_type( $lesson_id )
3442
        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3443
3444
            return false;
3445
3446
        }
3447
3448
        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3449