@@ -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 | } |
@@ -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 Quiz Class |
@@ -104,7 +107,7 @@ discard block |
||
| 104 | 107 | global $post; |
| 105 | 108 | if( 'quiz' == get_post_type( $post ) ){ |
| 106 | 109 | $quiz_id = $post->ID; |
| 107 | - }else{ |
|
| 110 | + } else{ |
|
| 108 | 111 | return false; |
| 109 | 112 | } |
| 110 | 113 | |
@@ -234,7 +237,7 @@ discard block |
||
| 234 | 237 | |
| 235 | 238 | $encoded_user_answers = $transient_cached_answers; |
| 236 | 239 | |
| 237 | - }else{ |
|
| 240 | + } else{ |
|
| 238 | 241 | |
| 239 | 242 | $encoded_user_answers = WooThemes_Sensei_Utils::get_user_data( 'quiz_answers', $lesson_id , $user_id ); |
| 240 | 243 | |
@@ -424,7 +427,7 @@ discard block |
||
| 424 | 427 | // compress the answer for saving |
| 425 | 428 | if( 'multi-line' == $question_type ) { |
| 426 | 429 | $answer = esc_html( $answer ); |
| 427 | - }elseif( 'file-upload' == $question_type ){ |
|
| 430 | + } elseif( 'file-upload' == $question_type ){ |
|
| 428 | 431 | $file_key = 'file_upload_' . $question_id; |
| 429 | 432 | if( isset( $files[ $file_key ] ) ) { |
| 430 | 433 | $attachment_id = WooThemes_Sensei_Utils::upload_file( $files[ $file_key ] ); |
@@ -1,5 +1,8 @@ |
||
| 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 User Profile List Table Class |
@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 3 | 5 | /** |
| 4 | 6 | * The Template for displaying the my course page data. |
| 5 | 7 | * |