@@ -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 Question Class |
@@ -211,7 +214,9 @@ discard block |
||
| 211 | 214 | |
| 212 | 215 | $lesson_id = get_post_meta( $quiz, '_quiz_lesson', true ); |
| 213 | 216 | |
| 214 | - if( ! $lesson_id ) continue; |
|
| 217 | + if( ! $lesson_id ) { |
|
| 218 | + continue; |
|
| 219 | + } |
|
| 215 | 220 | |
| 216 | 221 | $lessons[ $lesson_id ]['title'] = get_the_title( $lesson_id ); |
| 217 | 222 | $lessons[ $lesson_id ]['link'] = admin_url( 'post.php?post=' . $lesson_id . '&action=edit' ); |
@@ -880,7 +885,7 @@ discard block |
||
| 880 | 885 | |
| 881 | 886 | $merged_options = array_merge( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] ); |
| 882 | 887 | |
| 883 | - } else { |
|
| 888 | + } else { |
|
| 884 | 889 | |
| 885 | 890 | array_push( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] ); |
| 886 | 891 | $merged_options = $question_data[ 'question_wrong_answers' ]; |
@@ -908,7 +913,7 @@ discard block |
||
| 908 | 913 | |
| 909 | 914 | $user_correct = true; |
| 910 | 915 | |
| 911 | - } else if( $question_data[ 'user_question_grade' ] > 0 ) { |
|
| 916 | + } else if( $question_data[ 'user_question_grade' ] > 0 ) { |
|
| 912 | 917 | |
| 913 | 918 | $user_correct = true; |
| 914 | 919 | |
@@ -923,7 +928,7 @@ discard block |
||
| 923 | 928 | |
| 924 | 929 | $answer_class .= ' right_answer'; |
| 925 | 930 | |
| 926 | - } elseif( !is_array($question_data['question_right_answer']) && $question_data['question_right_answer'] == $answer ) { |
|
| 931 | + } elseif( !is_array($question_data['question_right_answer']) && $question_data['question_right_answer'] == $answer ) { |
|
| 927 | 932 | |
| 928 | 933 | $answer_class .= ' right_answer'; |
| 929 | 934 | |
@@ -1006,13 +1011,13 @@ discard block |
||
| 1006 | 1011 | } |
| 1007 | 1012 | } |
| 1008 | 1013 | |
| 1009 | - }else{ |
|
| 1014 | + } else{ |
|
| 1010 | 1015 | |
| 1011 | 1016 | $answer_options_sorted = $question_answers_options; |
| 1012 | 1017 | |
| 1013 | 1018 | } |
| 1014 | 1019 | |
| 1015 | - }else{ |
|
| 1020 | + } else{ |
|
| 1016 | 1021 | |
| 1017 | 1022 | $answer_options_sorted = $question_answers_options; |
| 1018 | 1023 | |
@@ -1075,12 +1080,12 @@ discard block |
||
| 1075 | 1080 | |
| 1076 | 1081 | $right_answer = ucfirst($right_answer); |
| 1077 | 1082 | |
| 1078 | - }elseif( 'multiple-choice' == $type ) { |
|
| 1083 | + } elseif( 'multiple-choice' == $type ) { |
|
| 1079 | 1084 | |
| 1080 | 1085 | $right_answer = (array) $right_answer; |
| 1081 | 1086 | $right_answer = implode( ', ', $right_answer ); |
| 1082 | 1087 | |
| 1083 | - }elseif( 'gap-fill' == $type ) { |
|
| 1088 | + } elseif( 'gap-fill' == $type ) { |
|
| 1084 | 1089 | |
| 1085 | 1090 | $right_answer_array = explode( '||', $right_answer ); |
| 1086 | 1091 | if ( isset( $right_answer_array[0] ) ) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; } |
@@ -1089,7 +1094,7 @@ discard block |
||
| 1089 | 1094 | |
| 1090 | 1095 | $right_answer = $gapfill_pre . ' <span class="highlight">' . $gapfill_gap . '</span> ' . $gapfill_post; |
| 1091 | 1096 | |
| 1092 | - }else{ |
|
| 1097 | + } else{ |
|
| 1093 | 1098 | |
| 1094 | 1099 | // for non auto gradable question types no answer should be returned. |
| 1095 | 1100 | $right_answer = ''; |
@@ -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 Course Class |
@@ -614,7 +617,7 @@ discard block |
||
| 614 | 617 | |
| 615 | 618 | return $results_array; |
| 616 | 619 | |
| 617 | - }else{ |
|
| 620 | + } else{ |
|
| 618 | 621 | |
| 619 | 622 | //reset the pagination as this widgets do not need it |
| 620 | 623 | $post_args['paged'] = 1; |
@@ -835,7 +838,7 @@ discard block |
||
| 835 | 838 | |
| 836 | 839 | return $html; |
| 837 | 840 | |
| 838 | - }else{ |
|
| 841 | + } else{ |
|
| 839 | 842 | |
| 840 | 843 | echo $html; |
| 841 | 844 | |
@@ -982,8 +985,7 @@ discard block |
||
| 982 | 985 | $has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
| 983 | 986 | if ( $has_questions && $boolean_check ) { |
| 984 | 987 | return true; |
| 985 | - } |
|
| 986 | - elseif ( $has_questions ) { |
|
| 988 | + } elseif ( $has_questions ) { |
|
| 987 | 989 | $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
| 988 | 990 | // $questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id ); |
| 989 | 991 | // if( count( $questions ) > 0 ) { |
@@ -1805,11 +1807,11 @@ discard block |
||
| 1805 | 1807 | |
| 1806 | 1808 | $course_id = $email['course_id']; |
| 1807 | 1809 | |
| 1808 | - }elseif( isset( $email['lesson_id'] ) ){ |
|
| 1810 | + } elseif( isset( $email['lesson_id'] ) ){ |
|
| 1809 | 1811 | |
| 1810 | 1812 | $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] ); |
| 1811 | 1813 | |
| 1812 | - }elseif( isset( $email['quiz_id'] ) ){ |
|
| 1814 | + } elseif( isset( $email['quiz_id'] ) ){ |
|
| 1813 | 1815 | |
| 1814 | 1816 | $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] ); |
| 1815 | 1817 | $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
@@ -1870,7 +1872,7 @@ discard block |
||
| 1870 | 1872 | |
| 1871 | 1873 | if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification'] ) { |
| 1872 | 1874 | $new_val = true; |
| 1873 | - }else{ |
|
| 1875 | + } else{ |
|
| 1874 | 1876 | $new_val = false; |
| 1875 | 1877 | } |
| 1876 | 1878 | |
@@ -2009,7 +2011,7 @@ discard block |
||
| 2009 | 2011 | |
| 2010 | 2012 | $classes[] = 'user-status-completed'; |
| 2011 | 2013 | |
| 2012 | - }else{ |
|
| 2014 | + } else{ |
|
| 2013 | 2015 | |
| 2014 | 2016 | $classes[] = 'user-status-active'; |
| 2015 | 2017 | |
@@ -2826,7 +2828,7 @@ discard block |
||
| 2826 | 2828 | |
| 2827 | 2829 | $title = $term->name; |
| 2828 | 2830 | |
| 2829 | - }else{ |
|
| 2831 | + } else{ |
|
| 2830 | 2832 | |
| 2831 | 2833 | $title = 'Course Category'; |
| 2832 | 2834 | |
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// security check, don't load file outside WP |
|
| 3 | 6 | /** |
| 4 | 7 | * Sensei Template Class |
| 5 | 8 | * |
@@ -69,8 +72,9 @@ discard block |
||
| 69 | 72 | */ |
| 70 | 73 | public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 71 | 74 | |
| 72 | - if ( $args && is_array($args) ) |
|
| 73 | - extract( $args ); |
|
| 75 | + if ( $args && is_array($args) ) { |
|
| 76 | + extract( $args ); |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | $located = self::locate_template( $template_name, $template_path, $default_path ); |
| 76 | 80 | |
@@ -99,8 +103,12 @@ discard block |
||
| 99 | 103 | */ |
| 100 | 104 | public static function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
| 101 | 105 | |
| 102 | - if ( ! $template_path ) $template_path = Sensei()->template_url; |
|
| 103 | - if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/'; |
|
| 106 | + if ( ! $template_path ) { |
|
| 107 | + $template_path = Sensei()->template_url; |
|
| 108 | + } |
|
| 109 | + if ( ! $default_path ) { |
|
| 110 | + $default_path = Sensei()->plugin_path() . '/templates/'; |
|
| 111 | + } |
|
| 104 | 112 | |
| 105 | 113 | // Look within passed path within the theme - this is priority |
| 106 | 114 | $template = locate_template( |
@@ -261,7 +269,7 @@ discard block |
||
| 261 | 269 | $find[] = $file; |
| 262 | 270 | $find[] = Sensei()->template_url . $file; |
| 263 | 271 | |
| 264 | - }elseif( is_author() |
|
| 272 | + } elseif( is_author() |
|
| 265 | 273 | && Sensei_Teacher::is_a_teacher( get_query_var('author') ) |
| 266 | 274 | && ! user_can( get_query_var('author'), 'manage_options' ) ){ |
| 267 | 275 | |
@@ -274,7 +282,9 @@ discard block |
||
| 274 | 282 | if ( $file ) { |
| 275 | 283 | |
| 276 | 284 | $template = locate_template( $find ); |
| 277 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 285 | + if ( ! $template ) { |
|
| 286 | + $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 287 | + } |
|
| 278 | 288 | |
| 279 | 289 | } // End If Statement |
| 280 | 290 | |
@@ -305,7 +315,9 @@ discard block |
||
| 305 | 315 | $find[] = Sensei()->template_url . $file; |
| 306 | 316 | |
| 307 | 317 | $template = locate_template( $find ); |
| 308 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 318 | + if ( ! $template ) { |
|
| 319 | + $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 320 | + } |
|
| 309 | 321 | |
| 310 | 322 | return $template; |
| 311 | 323 | |
@@ -335,7 +347,7 @@ discard block |
||
| 335 | 347 | include( $found_template ); |
| 336 | 348 | get_sensei_footer(); |
| 337 | 349 | |
| 338 | - }else{ |
|
| 350 | + } else{ |
|
| 339 | 351 | |
| 340 | 352 | include( $found_template ); |
| 341 | 353 | |
@@ -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 Messages Class |
@@ -73,7 +76,9 @@ discard block |
||
| 73 | 76 | |
| 74 | 77 | public function add_meta_box( $post_type, $post ) { |
| 75 | 78 | |
| 76 | - if( ! $post_type == $this->post_type ) return; |
|
| 79 | + if( ! $post_type == $this->post_type ) { |
|
| 80 | + return; |
|
| 81 | + } |
|
| 77 | 82 | |
| 78 | 83 | add_meta_box( $this->post_type . '-data', __( 'Message Information', 'woothemes-sensei' ), array( $this, 'meta_box_content' ), $this->post_type, 'normal', 'default' ); |
| 79 | 84 | |
@@ -138,7 +143,9 @@ discard block |
||
| 138 | 143 | public function save_message( $post_id = 0 ) { |
| 139 | 144 | global $post; |
| 140 | 145 | |
| 141 | - if( $this->post_type != get_post_type() ) return; |
|
| 146 | + if( $this->post_type != get_post_type() ) { |
|
| 147 | + return; |
|
| 148 | + } |
|
| 142 | 149 | |
| 143 | 150 | if( isset( $_POST['sender'] ) && $_POST['sender'] ) { |
| 144 | 151 | update_post_meta( $post_id, '_sender', $_POST['sender'] ); |
@@ -174,7 +181,9 @@ discard block |
||
| 174 | 181 | |
| 175 | 182 | if( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) { |
| 176 | 183 | |
| 177 | - if( ! is_user_logged_in() ) return; |
|
| 184 | + if( ! is_user_logged_in() ) { |
|
| 185 | + return; |
|
| 186 | + } |
|
| 178 | 187 | |
| 179 | 188 | if( isset( $_GET['contact'] ) ) { |
| 180 | 189 | $html .= $this->teacher_contact_form( $post ); |
@@ -185,7 +194,7 @@ discard block |
||
| 185 | 194 | $contact_button_text = __( 'Contact Lesson Teacher', 'woothemes-sensei' ); |
| 186 | 195 | } elseif( 'course' == $post->post_type ) { |
| 187 | 196 | $contact_button_text = __( 'Contact Course Teacher', 'woothemes-sensei' ); |
| 188 | - }else{ |
|
| 197 | + } else{ |
|
| 189 | 198 | $contact_button_text = __( 'Contact Teacher', 'woothemes-sensei' ); |
| 190 | 199 | } |
| 191 | 200 | |
@@ -203,14 +212,18 @@ discard block |
||
| 203 | 212 | |
| 204 | 213 | public function teacher_contact_form( $post ) { |
| 205 | 214 | |
| 206 | - if( ! is_user_logged_in() ) return; |
|
| 215 | + if( ! is_user_logged_in() ) { |
|
| 216 | + return; |
|
| 217 | + } |
|
| 207 | 218 | |
| 208 | 219 | global $current_user; |
| 209 | 220 | wp_get_current_user(); |
| 210 | 221 | |
| 211 | 222 | $html = ''; |
| 212 | 223 | |
| 213 | - if( ! isset( $post->ID ) ) return $html; |
|
| 224 | + if( ! isset( $post->ID ) ) { |
|
| 225 | + return $html; |
|
| 226 | + } |
|
| 214 | 227 | |
| 215 | 228 | //confirm private message |
| 216 | 229 | $confirmation = ''; |
@@ -244,9 +257,13 @@ discard block |
||
| 244 | 257 | |
| 245 | 258 | public function save_new_message() { |
| 246 | 259 | |
| 247 | - if( ! isset( $_POST['sensei_message_teacher_nonce'] ) ) return; |
|
| 260 | + if( ! isset( $_POST['sensei_message_teacher_nonce'] ) ) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 248 | 263 | |
| 249 | - if( ! wp_verify_nonce( $_POST['sensei_message_teacher_nonce'], 'message_teacher' ) ) return; |
|
| 264 | + if( ! wp_verify_nonce( $_POST['sensei_message_teacher_nonce'], 'message_teacher' ) ) { |
|
| 265 | + return; |
|
| 266 | + } |
|
| 250 | 267 | |
| 251 | 268 | $message_id = $this->save_new_message_post( $_POST['sender_id'], $_POST['receiver_id'], $_POST['contact_message'], $_POST['post_id'] ); |
| 252 | 269 | |
@@ -257,12 +274,16 @@ discard block |
||
| 257 | 274 | // Get comment object |
| 258 | 275 | $comment = get_comment( $comment_id ); |
| 259 | 276 | |
| 260 | - if( is_null( $comment ) ) return; |
|
| 277 | + if( is_null( $comment ) ) { |
|
| 278 | + return; |
|
| 279 | + } |
|
| 261 | 280 | |
| 262 | 281 | // Get message post object |
| 263 | 282 | $message = get_post( $comment->comment_post_ID ); |
| 264 | 283 | |
| 265 | - if( $message->post_type != $this->post_type ) return; |
|
| 284 | + if( $message->post_type != $this->post_type ) { |
|
| 285 | + return; |
|
| 286 | + } |
|
| 266 | 287 | |
| 267 | 288 | // Force comment to be approved |
| 268 | 289 | wp_set_comment_status( $comment_id, 'approve' ); |
@@ -360,7 +381,9 @@ discard block |
||
| 360 | 381 | */ |
| 361 | 382 | private function view_message( $message_id, $user_id = 0) { |
| 362 | 383 | |
| 363 | - if( ! is_user_logged_in() ) return false; |
|
| 384 | + if( ! is_user_logged_in() ) { |
|
| 385 | + return false; |
|
| 386 | + } |
|
| 364 | 387 | |
| 365 | 388 | if( $user_id == 0 ) { |
| 366 | 389 | global $current_user; |
@@ -424,9 +447,7 @@ discard block |
||
| 424 | 447 | |
| 425 | 448 | wp_redirect($my_courses_url, 303); |
| 426 | 449 | exit; |
| 427 | - } |
|
| 428 | - |
|
| 429 | - else { |
|
| 450 | + } else { |
|
| 430 | 451 | |
| 431 | 452 | wp_redirect(home_url('/wp-login.php'), 303); |
| 432 | 453 | exit; |
@@ -442,7 +463,9 @@ discard block |
||
| 442 | 463 | public function message_list( $query ) { |
| 443 | 464 | global $current_user; |
| 444 | 465 | |
| 445 | - if( is_admin() ) return; |
|
| 466 | + if( is_admin() ) { |
|
| 467 | + return; |
|
| 468 | + } |
|
| 446 | 469 | |
| 447 | 470 | if( is_post_type_archive( $this->post_type ) && $query->is_main_query() ) { |
| 448 | 471 | wp_get_current_user(); |
@@ -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 Learners Overview List Table Class |
@@ -409,8 +412,7 @@ discard block |
||
| 409 | 412 | if( $this->lesson_id ) { |
| 410 | 413 | $post_id = intval( $this->lesson_id ); |
| 411 | 414 | $activity = 'sensei_lesson_status'; |
| 412 | - } |
|
| 413 | - elseif( $this->course_id ) { |
|
| 415 | + } elseif( $this->course_id ) { |
|
| 414 | 416 | $post_id = intval( $this->course_id ); |
| 415 | 417 | $activity = 'sensei_course_status'; |
| 416 | 418 | } |
@@ -601,8 +603,7 @@ discard block |
||
| 601 | 603 | $post_type = __( 'Course', 'woothemes-sensei' ); |
| 602 | 604 | $form_post_type = 'course'; |
| 603 | 605 | $form_course_id = $this->course_id; |
| 604 | - } |
|
| 605 | - elseif( $this->course_id && $this->lesson_id ) { |
|
| 606 | + } elseif( $this->course_id && $this->lesson_id ) { |
|
| 606 | 607 | $post_title = get_the_title( $this->lesson_id ); |
| 607 | 608 | $post_type = __( 'Lesson', 'woothemes-sensei' ); |
| 608 | 609 | $form_post_type = 'lesson'; |
@@ -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 Generic List Table Class |
@@ -131,8 +134,9 @@ discard block |
||
| 131 | 134 | * @return array |
| 132 | 135 | */ |
| 133 | 136 | function get_column_info() { |
| 134 | - if ( isset( $this->_column_headers ) ) |
|
| 135 | - return $this->_column_headers; |
|
| 137 | + if ( isset( $this->_column_headers ) ) { |
|
| 138 | + return $this->_column_headers; |
|
| 139 | + } |
|
| 136 | 140 | |
| 137 | 141 | $columns = $this->get_columns(); |
| 138 | 142 | $hidden = get_hidden_columns( $this->screen ); |
@@ -152,12 +156,14 @@ discard block |
||
| 152 | 156 | |
| 153 | 157 | $sortable = array(); |
| 154 | 158 | foreach ( $_sortable as $id => $data ) { |
| 155 | - if ( empty( $data ) ) |
|
| 156 | - continue; |
|
| 159 | + if ( empty( $data ) ) { |
|
| 160 | + continue; |
|
| 161 | + } |
|
| 157 | 162 | |
| 158 | 163 | $data = (array) $data; |
| 159 | - if ( !isset( $data[1] ) ) |
|
| 160 | - $data[1] = false; |
|
| 164 | + if ( !isset( $data[1] ) ) { |
|
| 165 | + $data[1] = false; |
|
| 166 | + } |
|
| 161 | 167 | |
| 162 | 168 | $sortable[$id] = $data; |
| 163 | 169 | } |
@@ -188,8 +194,9 @@ discard block |
||
| 188 | 194 | $class = "class='$column_name column-$column_name'"; |
| 189 | 195 | |
| 190 | 196 | $style = ''; |
| 191 | - if ( in_array( $column_name, $hidden ) ) |
|
| 192 | - $style = ' style="display:none;"'; |
|
| 197 | + if ( in_array( $column_name, $hidden ) ) { |
|
| 198 | + $style = ' style="display:none;"'; |
|
| 199 | + } |
|
| 193 | 200 | |
| 194 | 201 | $attributes = "$class$style"; |
| 195 | 202 | |
@@ -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 Analysis Course List Table Class |
@@ -359,31 +362,26 @@ discard block |
||
| 359 | 362 | $status_class = 'graded'; |
| 360 | 363 | |
| 361 | 364 | $grade = __( 'No Grade', 'woothemes-sensei' ); |
| 362 | - } |
|
| 363 | - elseif( 'graded' == $lesson_status->comment_approved ) { |
|
| 365 | + } elseif( 'graded' == $lesson_status->comment_approved ) { |
|
| 364 | 366 | $status = __( 'Graded', 'woothemes-sensei' ); |
| 365 | 367 | $status_class = 'graded'; |
| 366 | 368 | |
| 367 | 369 | $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
| 368 | - } |
|
| 369 | - elseif( 'passed' == $lesson_status->comment_approved ) { |
|
| 370 | + } elseif( 'passed' == $lesson_status->comment_approved ) { |
|
| 370 | 371 | $status = __( 'Passed', 'woothemes-sensei' ); |
| 371 | 372 | $status_class = 'graded'; |
| 372 | 373 | |
| 373 | 374 | $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
| 374 | - } |
|
| 375 | - elseif( 'failed' == $lesson_status->comment_approved ) { |
|
| 375 | + } elseif( 'failed' == $lesson_status->comment_approved ) { |
|
| 376 | 376 | $status = __( 'Failed', 'woothemes-sensei' ); |
| 377 | 377 | $status_class = 'failed'; |
| 378 | 378 | |
| 379 | 379 | $grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true); |
| 380 | - } |
|
| 381 | - elseif( 'ungraded' == $lesson_status->comment_approved ) { |
|
| 380 | + } elseif( 'ungraded' == $lesson_status->comment_approved ) { |
|
| 382 | 381 | $status = __( 'Ungraded', 'woothemes-sensei' ); |
| 383 | 382 | $status_class = 'ungraded'; |
| 384 | 383 | |
| 385 | - } |
|
| 386 | - elseif( 'in-progress' == $lesson_status->comment_approved ) { |
|
| 384 | + } elseif( 'in-progress' == $lesson_status->comment_approved ) { |
|
| 387 | 385 | $status = __( 'In Progress', 'woothemes-sensei' ); |
| 388 | 386 | $user_end_date = ''; |
| 389 | 387 | } |
@@ -392,8 +390,7 @@ discard block |
||
| 392 | 390 | // Output users data |
| 393 | 391 | if ( $this->csv_output ) { |
| 394 | 392 | $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
| 395 | - } |
|
| 396 | - else { |
|
| 393 | + } else { |
|
| 397 | 394 | $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
| 398 | 395 | $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
| 399 | 396 | |
@@ -448,8 +445,7 @@ discard block |
||
| 448 | 445 | // Output lesson data |
| 449 | 446 | if ( $this->csv_output ) { |
| 450 | 447 | $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
| 451 | - } |
|
| 452 | - else { |
|
| 448 | + } else { |
|
| 453 | 449 | $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
| 454 | 450 | $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
| 455 | 451 | |
@@ -582,8 +578,7 @@ discard block |
||
| 582 | 578 | public function data_table_header() { |
| 583 | 579 | if ( $this->user_id ) { |
| 584 | 580 | $learners_text = __( 'Other Learners taking this Course', 'woothemes-sensei' ); |
| 585 | - } |
|
| 586 | - else { |
|
| 581 | + } else { |
|
| 587 | 582 | $learners_text = __( 'Learners taking this Course', 'woothemes-sensei' ); |
| 588 | 583 | } |
| 589 | 584 | $lessons_text = __( 'Lessons in this Course', 'woothemes-sensei' ); |
@@ -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 Updates Class |
@@ -769,9 +772,15 @@ discard block |
||
| 769 | 772 | $all_activity = get_comments( array( 'status' => 'approve' ) ); |
| 770 | 773 | $activity_count = array(); |
| 771 | 774 | foreach( $all_activity as $activity ) { |
| 772 | - if( '' == $activity->comment_type ) continue; |
|
| 773 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; |
|
| 774 | - if( 0 == $activity->user_id ) continue; |
|
| 775 | + if( '' == $activity->comment_type ) { |
|
| 776 | + continue; |
|
| 777 | + } |
|
| 778 | + if( strpos( 'sensei_', $activity->comment_type ) != 0 ) { |
|
| 779 | + continue; |
|
| 780 | + } |
|
| 781 | + if( 0 == $activity->user_id ) { |
|
| 782 | + continue; |
|
| 783 | + } |
|
| 775 | 784 | $activity_count[] = $activity->comment_ID; |
| 776 | 785 | } |
| 777 | 786 | |
@@ -784,9 +793,15 @@ discard block |
||
| 784 | 793 | $activities = get_comments( $args ); |
| 785 | 794 | |
| 786 | 795 | foreach( $activities as $activity ) { |
| 787 | - if( '' == $activity->comment_type ) continue; |
|
| 788 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; |
|
| 789 | - if( 0 == $activity->user_id ) continue; |
|
| 796 | + if( '' == $activity->comment_type ) { |
|
| 797 | + continue; |
|
| 798 | + } |
|
| 799 | + if( strpos( 'sensei_', $activity->comment_type ) != 0 ) { |
|
| 800 | + continue; |
|
| 801 | + } |
|
| 802 | + if( 0 == $activity->user_id ) { |
|
| 803 | + continue; |
|
| 804 | + } |
|
| 790 | 805 | |
| 791 | 806 | $user_exists = get_userdata( $activity->user_id ); |
| 792 | 807 | |
@@ -845,7 +860,9 @@ discard block |
||
| 845 | 860 | |
| 846 | 861 | foreach( $questions as $question ) { |
| 847 | 862 | |
| 848 | - if( ! isset( $question->ID ) ) continue; |
|
| 863 | + if( ! isset( $question->ID ) ) { |
|
| 864 | + continue; |
|
| 865 | + } |
|
| 849 | 866 | |
| 850 | 867 | $quiz_id = get_post_meta( $question->ID, '_quiz_id', true ); |
| 851 | 868 | |
@@ -882,7 +899,9 @@ discard block |
||
| 882 | 899 | |
| 883 | 900 | foreach( $quizzes as $quiz ) { |
| 884 | 901 | |
| 885 | - if( ! isset( $quiz->ID ) ) continue; |
|
| 902 | + if( ! isset( $quiz->ID ) ) { |
|
| 903 | + continue; |
|
| 904 | + } |
|
| 886 | 905 | |
| 887 | 906 | if( isset( $lesson_completion ) && 'passed' == $lesson_completion ) { |
| 888 | 907 | update_post_meta( $quiz->ID, '_pass_required', 'on' ); |
@@ -910,7 +929,9 @@ discard block |
||
| 910 | 929 | |
| 911 | 930 | foreach( $lessons as $lesson ) { |
| 912 | 931 | |
| 913 | - if( ! isset( $lesson->ID ) ) continue; |
|
| 932 | + if( ! isset( $lesson->ID ) ) { |
|
| 933 | + continue; |
|
| 934 | + } |
|
| 914 | 935 | |
| 915 | 936 | $course_id = get_post_meta( $lesson->ID, '_lesson_course', true); |
| 916 | 937 | |
@@ -984,11 +1005,15 @@ discard block |
||
| 984 | 1005 | |
| 985 | 1006 | foreach( $quizzes as $quiz ) { |
| 986 | 1007 | |
| 987 | - if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) continue; |
|
| 1008 | + if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) { |
|
| 1009 | + continue; |
|
| 1010 | + } |
|
| 988 | 1011 | |
| 989 | 1012 | $lesson_id = get_post_meta( $quiz->ID, '_quiz_lesson', true ); |
| 990 | 1013 | |
| 991 | - if( empty( $lesson_id ) ) continue; |
|
| 1014 | + if( empty( $lesson_id ) ) { |
|
| 1015 | + continue; |
|
| 1016 | + } |
|
| 992 | 1017 | |
| 993 | 1018 | $data = array( |
| 994 | 1019 | 'ID' => $quiz->ID, |
@@ -1071,8 +1096,7 @@ discard block |
||
| 1071 | 1096 | delete_post_meta( $quiz_id, '_quiz_passmark' ); |
| 1072 | 1097 | delete_post_meta( $lesson_id, '_quiz_has_questions' ); |
| 1073 | 1098 | $d_count++; |
| 1074 | - } |
|
| 1075 | - else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) { |
|
| 1099 | + } else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) { |
|
| 1076 | 1100 | |
| 1077 | 1101 | // Quiz has no questions, drop the corresponding data |
| 1078 | 1102 | update_post_meta( $lesson_id, '_quiz_has_questions', true ); |
@@ -1222,20 +1246,16 @@ discard block |
||
| 1222 | 1246 | // Check if the user has to get the passmark and has or not |
| 1223 | 1247 | if ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] <= $quiz_grade ) { |
| 1224 | 1248 | $status = 'passed'; |
| 1225 | - } |
|
| 1226 | - elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) { |
|
| 1249 | + } elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) { |
|
| 1227 | 1250 | $status = 'failed'; |
| 1228 | - } |
|
| 1229 | - else { |
|
| 1251 | + } else { |
|
| 1230 | 1252 | $status = 'graded'; |
| 1231 | 1253 | } |
| 1232 | - } |
|
| 1233 | - else { |
|
| 1254 | + } else { |
|
| 1234 | 1255 | // If the lesson has a quiz, but the user doesn't have a grade, it's not yet been graded |
| 1235 | 1256 | $status = 'ungraded'; |
| 1236 | 1257 | } |
| 1237 | - } |
|
| 1238 | - else { |
|
| 1258 | + } else { |
|
| 1239 | 1259 | // Lesson has no quiz, so it can only ever be this status |
| 1240 | 1260 | $status = 'complete'; |
| 1241 | 1261 | } |
@@ -1374,8 +1394,7 @@ discard block |
||
| 1374 | 1394 | } |
| 1375 | 1395 | $meta_data['complete'] = $lessons_completed; |
| 1376 | 1396 | $meta_data['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ); |
| 1377 | - } |
|
| 1378 | - else { |
|
| 1397 | + } else { |
|
| 1379 | 1398 | // Course has no lessons, therefore cannot be 'complete' |
| 1380 | 1399 | $status = 'in-progress'; |
| 1381 | 1400 | } |
@@ -1506,8 +1525,7 @@ discard block |
||
| 1506 | 1525 | $lessons_completed++; |
| 1507 | 1526 | break; |
| 1508 | 1527 | } |
| 1509 | - } |
|
| 1510 | - else { |
|
| 1528 | + } else { |
|
| 1511 | 1529 | switch ( $lesson_status ) { |
| 1512 | 1530 | case 'complete': // Lesson has no quiz/questions |
| 1513 | 1531 | case 'graded': // Lesson has quiz, but it's not important what the grade was |
@@ -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 | } |