Code Duplication    Length = 15-26 lines in 2 locations

includes/class-sensei-question.php 1 location

@@ 988-1013 (lines=26) @@
985
                if( $answer_order_string ) {
986
987
                    $answer_order = array_filter( explode( ',', $answer_order_string ) );
988
                    if( count( $answer_order ) > 0 ) {
989
990
                        foreach( $answer_order as $answer_id ) {
991
992
                            if( isset( $question_answers_options[ $answer_id ] ) ) {
993
994
                                $answer_options_sorted[ $answer_id ] = $question_answers_options[ $answer_id ];
995
                                unset( $question_answers_options[ $answer_id ] );
996
997
                            }
998
999
                        }
1000
1001
                        if( count( $question_answers_options ) > 0 ) {
1002
                            foreach( $question_answers_options as $id => $answer ) {
1003
1004
                                $answer_options_sorted[ $id ] = $answer;
1005
1006
                            }
1007
                        }
1008
1009
                    }else{
1010
1011
                        $answer_options_sorted = $question_answers_options;
1012
1013
                    }
1014
1015
                }else{
1016

includes/class-sensei-lesson.php 1 location

@@ 1396-1410 (lines=15) @@
1393
                        } // end for each
1394
1395
				    	$answers_sorted = $answers;
1396
				    	if( $question_id && count( $answer_order ) > 0 ) {
1397
				    		$answers_sorted = array();
1398
				    		foreach( $answer_order as $answer_id ) {
1399
				    			if( isset( $answers[ $answer_id ] ) ) {
1400
				    				$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1401
				    				unset( $answers[ $answer_id ] );
1402
				    			}
1403
				    		}
1404
1405
				    		if( count( $answers ) > 0 ) {
1406
						    	foreach( $answers as $id => $answer ) {
1407
						    		$answers_sorted[ $id ] = $answer;
1408
						    	}
1409
						    }
1410
				    	}
1411
1412
						foreach( $answers_sorted as $id => $answer ) {
1413
				    		$html .= $answer;