@@ -108,9 +108,12 @@ |
||
| 108 | 108 | ?> |
| 109 | 109 | |
| 110 | 110 | </form> |
| 111 | - <?php else: ?> |
|
| 111 | + <?php else { |
|
| 112 | + : ?> |
|
| 112 | 113 | |
| 113 | - <div class="sensei-message alert"> <?php _e( 'There are no questions for this Quiz yet. Check back soon.', 'woothemes-sensei' ); ?></div> |
|
| 114 | + <div class="sensei-message alert"> <?php _e( 'There are no questions for this Quiz yet. Check back soon.', 'woothemes-sensei' ); |
|
| 115 | +} |
|
| 116 | +?></div> |
|
| 114 | 117 | |
| 115 | 118 | <?php endif; // End If have questions ?> |
| 116 | 119 | |
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Lessons Class |
@@ -378,8 +381,7 @@ discard block |
||
| 378 | 381 | $quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id ); |
| 379 | 382 | if( 0 < count( $quiz_questions ) ) { |
| 380 | 383 | update_post_meta( $post_id, '_quiz_has_questions', '1' ); |
| 381 | - } |
|
| 382 | - else { |
|
| 384 | + } else { |
|
| 383 | 385 | delete_post_meta( $post_id, '_quiz_has_questions' ); |
| 384 | 386 | } |
| 385 | 387 | |
@@ -390,7 +392,9 @@ discard block |
||
| 390 | 392 | |
| 391 | 393 | public function get_submitted_setting_value( $field = false ) { |
| 392 | 394 | |
| 393 | - if( ! $field ) return; |
|
| 395 | + if( ! $field ) { |
|
| 396 | + return; |
|
| 397 | + } |
|
| 394 | 398 | |
| 395 | 399 | $value = false; |
| 396 | 400 | |
@@ -1507,7 +1511,7 @@ discard block |
||
| 1507 | 1511 | |
| 1508 | 1512 | $field_name = 'answer_feedback_boolean'; |
| 1509 | 1513 | |
| 1510 | - }elseif( 'multiple-choice' == $question_type ){ |
|
| 1514 | + } elseif( 'multiple-choice' == $question_type ){ |
|
| 1511 | 1515 | |
| 1512 | 1516 | $field_name = 'answer_feedback_multiple_choice'; |
| 1513 | 1517 | |
@@ -1603,7 +1607,9 @@ discard block |
||
| 1603 | 1607 | |
| 1604 | 1608 | $html = ''; |
| 1605 | 1609 | |
| 1606 | - if( ! $lesson_id && ! $quiz_id ) return $html; |
|
| 1610 | + if( ! $lesson_id && ! $quiz_id ) { |
|
| 1611 | + return $html; |
|
| 1612 | + } |
|
| 1607 | 1613 | |
| 1608 | 1614 | $settings = $this->get_quiz_settings( $quiz_id ); |
| 1609 | 1615 | |
@@ -2258,11 +2264,11 @@ discard block |
||
| 2258 | 2264 | |
| 2259 | 2265 | $answer_feedback = $data[ 'answer_feedback_boolean' ]; |
| 2260 | 2266 | |
| 2261 | - }elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){ |
|
| 2267 | + } elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){ |
|
| 2262 | 2268 | |
| 2263 | 2269 | $answer_feedback = $data[ 'answer_feedback_multiple_choice' ]; |
| 2264 | 2270 | |
| 2265 | - }elseif( isset( $data[ 'answer_feedback' ] ) ){ |
|
| 2271 | + } elseif( isset( $data[ 'answer_feedback' ] ) ){ |
|
| 2266 | 2272 | |
| 2267 | 2273 | $answer_feedback = $data[ 'answer_feedback' ]; |
| 2268 | 2274 | |
@@ -2275,8 +2281,7 @@ discard block |
||
| 2275 | 2281 | // Handle the extended question text |
| 2276 | 2282 | if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) { |
| 2277 | 2283 | $post_content = $data[ 'question_description' ]; |
| 2278 | - } |
|
| 2279 | - else { |
|
| 2284 | + } else { |
|
| 2280 | 2285 | $post_content = ''; |
| 2281 | 2286 | } |
| 2282 | 2287 | // Question Query Arguments |
@@ -2484,8 +2489,7 @@ discard block |
||
| 2484 | 2489 | 'key' => '_lesson_course', |
| 2485 | 2490 | 'value' => $course_id, |
| 2486 | 2491 | ); |
| 2487 | - } |
|
| 2488 | - else { |
|
| 2492 | + } else { |
|
| 2489 | 2493 | // Simple check for connection to a Course |
| 2490 | 2494 | $post_args['meta_query'][] = array( |
| 2491 | 2495 | 'key' => '_lesson_course', |
@@ -2613,9 +2617,13 @@ discard block |
||
| 2613 | 2617 | // Fetch each question in the order in which they were asked |
| 2614 | 2618 | $questions = array(); |
| 2615 | 2619 | foreach( $selected_questions as $question_id ) { |
| 2616 | - if( ! $question_id ) continue; |
|
| 2620 | + if( ! $question_id ) { |
|
| 2621 | + continue; |
|
| 2622 | + } |
|
| 2617 | 2623 | $question = get_post( $question_id ); |
| 2618 | - if( ! isset( $question ) || ! isset( $question->ID ) ) continue; |
|
| 2624 | + if( ! isset( $question ) || ! isset( $question->ID ) ) { |
|
| 2625 | + continue; |
|
| 2626 | + } |
|
| 2619 | 2627 | $questions[] = $question; |
| 2620 | 2628 | } |
| 2621 | 2629 | |
@@ -2628,7 +2636,9 @@ discard block |
||
| 2628 | 2636 | |
| 2629 | 2637 | // Set array of questions that already exist so we can prevent duplicates from appearing |
| 2630 | 2638 | foreach( $questions_array as $question ) { |
| 2631 | - if( 'question' != $question->post_type ) continue; |
|
| 2639 | + if( 'question' != $question->post_type ) { |
|
| 2640 | + continue; |
|
| 2641 | + } |
|
| 2632 | 2642 | $existing_questions[] = $question->ID; |
| 2633 | 2643 | } |
| 2634 | 2644 | |
@@ -2668,7 +2678,9 @@ discard block |
||
| 2668 | 2678 | |
| 2669 | 2679 | // Add selected questions to existing questions array to prevent duplicates from being added |
| 2670 | 2680 | foreach( $questions_array as $cat_question ) { |
| 2671 | - if( in_array( $cat_question->ID, $existing_questions ) ) continue; |
|
| 2681 | + if( in_array( $cat_question->ID, $existing_questions ) ) { |
|
| 2682 | + continue; |
|
| 2683 | + } |
|
| 2672 | 2684 | $existing_questions[] = $cat_question->ID; |
| 2673 | 2685 | } |
| 2674 | 2686 | } |
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Utilities Class |
@@ -181,8 +184,7 @@ discard block |
||
| 181 | 184 | // ...use a filter to switch the encoding back |
| 182 | 185 | add_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) ); |
| 183 | 186 | } |
| 184 | - } |
|
| 185 | - else { |
|
| 187 | + } else { |
|
| 186 | 188 | $args['status'] = 'any'; // 'log' == 'sensei_user_answer' |
| 187 | 189 | } |
| 188 | 190 | |
@@ -307,8 +309,12 @@ discard block |
||
| 307 | 309 | } |
| 308 | 310 | |
| 309 | 311 | foreach( $activities as $activity ) { |
| 310 | - if( '' == $activity->comment_type ) continue; |
|
| 311 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; |
|
| 312 | + if( '' == $activity->comment_type ) { |
|
| 313 | + continue; |
|
| 314 | + } |
|
| 315 | + if( strpos( 'sensei_', $activity->comment_type ) != 0 ) { |
|
| 316 | + continue; |
|
| 317 | + } |
|
| 312 | 318 | $dataset_changes = wp_delete_comment( intval( $activity->comment_ID ), true ); |
| 313 | 319 | wp_cache_flush(); |
| 314 | 320 | } |
@@ -360,11 +366,13 @@ discard block |
||
| 360 | 366 | $emails[] = $user->user_email; |
| 361 | 367 | } |
| 362 | 368 | |
| 363 | - if ( is_email( $customer_email ) ) |
|
| 364 | - $emails[] = $customer_email; |
|
| 369 | + if ( is_email( $customer_email ) ) { |
|
| 370 | + $emails[] = $customer_email; |
|
| 371 | + } |
|
| 365 | 372 | |
| 366 | - if ( sizeof( $emails ) == 0 ) |
|
| 367 | - return false; |
|
| 373 | + if ( sizeof( $emails ) == 0 ) { |
|
| 374 | + return false; |
|
| 375 | + } |
|
| 368 | 376 | |
| 369 | 377 | return Sensei_WC::has_customer_bought_product( $user_id, $product_id ); |
| 370 | 378 | |
@@ -379,7 +387,9 @@ discard block |
||
| 379 | 387 | */ |
| 380 | 388 | public static function sensei_text_editor( $content = '', $editor_id = 'senseitexteditor', $input_name = '' ) { |
| 381 | 389 | |
| 382 | - if( ! $input_name ) $input_name = $editor_id; |
|
| 390 | + if( ! $input_name ) { |
|
| 391 | + $input_name = $editor_id; |
|
| 392 | + } |
|
| 383 | 393 | |
| 384 | 394 | $buttons = 'bold,italic,underline,strikethrough,blockquote,bullist,numlist,justifyleft,justifycenter,justifyright,undo,redo,pastetext'; |
| 385 | 395 | |
@@ -689,8 +699,7 @@ discard block |
||
| 689 | 699 | if ( $has_questions ) { |
| 690 | 700 | $status = 'passed'; // Force a pass |
| 691 | 701 | $metadata['grade'] = 0; |
| 692 | - } |
|
| 693 | - else { |
|
| 702 | + } else { |
|
| 694 | 703 | $status = 'complete'; |
| 695 | 704 | } |
| 696 | 705 | } |
@@ -738,7 +747,9 @@ discard block |
||
| 738 | 747 | public static function sensei_remove_user_from_lesson( $lesson_id = 0, $user_id = 0, $from_course = false ) { |
| 739 | 748 | |
| 740 | 749 | |
| 741 | - if( ! $lesson_id ) return false; |
|
| 750 | + if( ! $lesson_id ) { |
|
| 751 | + return false; |
|
| 752 | + } |
|
| 742 | 753 | |
| 743 | 754 | if( intval( $user_id ) == 0 ) { |
| 744 | 755 | $user_id = get_current_user_id(); |
@@ -776,7 +787,9 @@ discard block |
||
| 776 | 787 | public static function sensei_remove_user_from_course( $course_id = 0, $user_id = 0 ) { |
| 777 | 788 | |
| 778 | 789 | |
| 779 | - if( ! $course_id ) return false; |
|
| 790 | + if( ! $course_id ) { |
|
| 791 | + return false; |
|
| 792 | + } |
|
| 780 | 793 | |
| 781 | 794 | if( intval( $user_id ) == 0 ) { |
| 782 | 795 | $user_id = get_current_user_id(); |
@@ -844,8 +857,7 @@ discard block |
||
| 844 | 857 | if( $question ) { |
| 845 | 858 | if ( is_object( $question ) ) { |
| 846 | 859 | $user_answer_id = $question->comment_ID; |
| 847 | - } |
|
| 848 | - else { |
|
| 860 | + } else { |
|
| 849 | 861 | if( intval( $user_id ) == 0 ) { |
| 850 | 862 | $user_id = get_current_user_id(); |
| 851 | 863 | } |
@@ -872,8 +884,7 @@ discard block |
||
| 872 | 884 | if( $question ) { |
| 873 | 885 | if ( is_object( $question ) ) { |
| 874 | 886 | $user_answer_id = $question->comment_ID; |
| 875 | - } |
|
| 876 | - else { |
|
| 887 | + } else { |
|
| 877 | 888 | if( intval( $user_id ) == 0 ) { |
| 878 | 889 | $user_id = get_current_user_id(); |
| 879 | 890 | } |
@@ -938,8 +949,7 @@ discard block |
||
| 938 | 949 | if ( !empty($notes) ) { |
| 939 | 950 | $user_lesson_id = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); |
| 940 | 951 | $activity_logged = update_comment_meta( $user_lesson_id, 'answer_note', $notes ); |
| 941 | - } |
|
| 942 | - else { |
|
| 952 | + } else { |
|
| 943 | 953 | $activity_logged = true; |
| 944 | 954 | } |
| 945 | 955 | } |
@@ -1451,8 +1461,7 @@ discard block |
||
| 1451 | 1461 | $lessons_completed++; |
| 1452 | 1462 | break; |
| 1453 | 1463 | } |
| 1454 | - } |
|
| 1455 | - else { |
|
| 1464 | + } else { |
|
| 1456 | 1465 | switch ( $lesson_status->comment_approved ) { |
| 1457 | 1466 | case 'complete': // Lesson has no quiz/questions |
| 1458 | 1467 | case 'graded': // Lesson has quiz, but it's not important what the grade was |
@@ -1500,11 +1509,9 @@ discard block |
||
| 1500 | 1509 | if( $course ) { |
| 1501 | 1510 | if ( is_object( $course ) && is_a( $course,'WP_Comment') ) { |
| 1502 | 1511 | $user_course_status = $course->comment_approved; |
| 1503 | - } |
|
| 1504 | - elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) { |
|
| 1512 | + } elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) { |
|
| 1505 | 1513 | $user_course_status = $course; |
| 1506 | - } |
|
| 1507 | - else { |
|
| 1514 | + } else { |
|
| 1508 | 1515 | if( ! $user_id ) { |
| 1509 | 1516 | $user_id = get_current_user_id(); |
| 1510 | 1517 | } |
@@ -1564,11 +1571,9 @@ discard block |
||
| 1564 | 1571 | if ( is_object( $lesson ) ) { |
| 1565 | 1572 | $user_lesson_status = $lesson->comment_approved; |
| 1566 | 1573 | $lesson_id = $lesson->comment_post_ID; |
| 1567 | - } |
|
| 1568 | - elseif ( ! is_numeric( $lesson ) ) { |
|
| 1574 | + } elseif ( ! is_numeric( $lesson ) ) { |
|
| 1569 | 1575 | $user_lesson_status = $lesson; |
| 1570 | - } |
|
| 1571 | - else { |
|
| 1576 | + } else { |
|
| 1572 | 1577 | if( ! $user_id ) { |
| 1573 | 1578 | $user_id = get_current_user_id(); |
| 1574 | 1579 | } |
@@ -1581,8 +1586,7 @@ discard block |
||
| 1581 | 1586 | |
| 1582 | 1587 | if ( $_user_lesson_status ) { |
| 1583 | 1588 | $user_lesson_status = $_user_lesson_status->comment_approved; |
| 1584 | - } |
|
| 1585 | - else { |
|
| 1589 | + } else { |
|
| 1586 | 1590 | return false; // No status means not complete |
| 1587 | 1591 | } |
| 1588 | 1592 | $lesson_id = $lesson; |
@@ -1683,7 +1687,9 @@ discard block |
||
| 1683 | 1687 | |
| 1684 | 1688 | public static function user_passed_quiz( $quiz_id = 0, $user_id = 0 ) { |
| 1685 | 1689 | |
| 1686 | - if( ! $quiz_id ) return false; |
|
| 1690 | + if( ! $quiz_id ) { |
|
| 1691 | + return false; |
|
| 1692 | + } |
|
| 1687 | 1693 | |
| 1688 | 1694 | if( ! $user_id ) { |
| 1689 | 1695 | $user_id = get_current_user_id(); |
@@ -1921,7 +1927,7 @@ discard block |
||
| 1921 | 1927 | $start_function = 'user_start_'.$post_type; |
| 1922 | 1928 | $sensei_user_activity_id = self::$start_function( $user_id, $post_id ); |
| 1923 | 1929 | |
| 1924 | - }else{ |
|
| 1930 | + } else{ |
|
| 1925 | 1931 | |
| 1926 | 1932 | $sensei_user_activity_id = $sensei_user_status->comment_ID; |
| 1927 | 1933 | |
@@ -2138,7 +2144,7 @@ discard block |
||
| 2138 | 2144 | |
| 2139 | 2145 | return round( $val, $precision, $mode ); |
| 2140 | 2146 | |
| 2141 | - }else{ |
|
| 2147 | + } else{ |
|
| 2142 | 2148 | |
| 2143 | 2149 | return round( $val, $precision ); |
| 2144 | 2150 | |
@@ -33,10 +33,6 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * |
| 35 | 35 | * |
| 36 | - * @param string $message |
|
| 37 | - * @param string $type defaults to alert options( alert, tick , download , info ) |
|
| 38 | - * |
|
| 39 | - * @return void |
|
| 40 | 36 | */ |
| 41 | 37 | |
| 42 | 38 | public function add_notice( $content , $type = 'alert' ){ |
@@ -47,10 +43,6 @@ discard block |
||
| 47 | 43 | /** |
| 48 | 44 | * Output all notices added |
| 49 | 45 | * |
| 50 | - * @param string $message |
|
| 51 | - * @param string $type |
|
| 52 | - * |
|
| 53 | - * @return void |
|
| 54 | 46 | */ |
| 55 | 47 | |
| 56 | 48 | public function print_notices(){ |