@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @since 1.0.0 |
| 21 | 21 | */ |
| 22 | 22 | public function __construct () { |
| 23 | - $this->token = 'question'; |
|
| 23 | + $this->token = 'question'; |
|
| 24 | 24 | $this->question_types = $this->question_types(); |
| 25 | 25 | $this->meta_fields = array( 'question_right_answer', 'question_wrong_answers' ); |
| 26 | 26 | if ( is_admin() ) { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | if( isset( $post->ID ) ) { |
| 119 | 119 | |
| 120 | - $question_type = Sensei()->question->get_question_type( $post->ID ); |
|
| 120 | + $question_type = Sensei()->question->get_question_type( $post->ID ); |
|
| 121 | 121 | |
| 122 | 122 | if( $question_type ) { |
| 123 | 123 | $type = $this->question_types[ $question_type ]; |
@@ -237,15 +237,15 @@ discard block |
||
| 237 | 237 | public function save_question( $post_id = 0 ) { |
| 238 | 238 | |
| 239 | 239 | if( ! isset( $_POST['post_type'] |
| 240 | - ) || 'question' != $_POST['post_type'] ) { |
|
| 241 | - return; |
|
| 242 | - } |
|
| 240 | + ) || 'question' != $_POST['post_type'] ) { |
|
| 241 | + return; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | 244 | |
| 245 | 245 | |
| 246 | - //setup the data for saving |
|
| 246 | + //setup the data for saving |
|
| 247 | 247 | $data = $_POST ; |
| 248 | - $data['quiz_id'] = 0; |
|
| 248 | + $data['quiz_id'] = 0; |
|
| 249 | 249 | $data['question_id'] = $post_id; |
| 250 | 250 | |
| 251 | 251 | if ( ! wp_is_post_revision( $post_id ) ){ |
@@ -339,34 +339,34 @@ discard block |
||
| 339 | 339 | return $request; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - /** |
|
| 343 | - * Get the type of question by id |
|
| 344 | - * |
|
| 345 | - * This function uses the post terms to determine which question type |
|
| 346 | - * the passed question id belongs to. |
|
| 347 | - * |
|
| 348 | - * @since 1.7.4 |
|
| 349 | - * |
|
| 350 | - * @param int $question_id |
|
| 351 | - * |
|
| 352 | - * @return string $question_type | bool |
|
| 353 | - */ |
|
| 354 | - public function get_question_type( $question_id ){ |
|
| 355 | - |
|
| 356 | - if( empty( $question_id ) || ! intval( $question_id ) > 0 |
|
| 357 | - || 'question' != get_post_type( $question_id ) ){ |
|
| 358 | - return false; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - $question_type = 'multiple-choice'; |
|
| 362 | - $question_types = wp_get_post_terms( $question_id, 'question-type' ); |
|
| 363 | - foreach( $question_types as $type ) { |
|
| 364 | - $question_type = $type->slug; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - return $question_type; |
|
| 368 | - |
|
| 369 | - }// end get_question_type |
|
| 342 | + /** |
|
| 343 | + * Get the type of question by id |
|
| 344 | + * |
|
| 345 | + * This function uses the post terms to determine which question type |
|
| 346 | + * the passed question id belongs to. |
|
| 347 | + * |
|
| 348 | + * @since 1.7.4 |
|
| 349 | + * |
|
| 350 | + * @param int $question_id |
|
| 351 | + * |
|
| 352 | + * @return string $question_type | bool |
|
| 353 | + */ |
|
| 354 | + public function get_question_type( $question_id ){ |
|
| 355 | + |
|
| 356 | + if( empty( $question_id ) || ! intval( $question_id ) > 0 |
|
| 357 | + || 'question' != get_post_type( $question_id ) ){ |
|
| 358 | + return false; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + $question_type = 'multiple-choice'; |
|
| 362 | + $question_types = wp_get_post_terms( $question_id, 'question-type' ); |
|
| 363 | + foreach( $question_types as $type ) { |
|
| 364 | + $question_type = $type->slug; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + return $question_type; |
|
| 368 | + |
|
| 369 | + }// end get_question_type |
|
| 370 | 370 | |
| 371 | 371 | /** |
| 372 | 372 | * Given a question ID, return the grade that can be achieved. |
@@ -398,317 +398,317 @@ discard block |
||
| 398 | 398 | } // end get_question_grade |
| 399 | 399 | |
| 400 | 400 | |
| 401 | - /** |
|
| 402 | - * This function simply loads the question type template |
|
| 403 | - * |
|
| 404 | - * @since 1.9.0 |
|
| 405 | - * @param $question_type |
|
| 406 | - */ |
|
| 407 | - public static function load_question_template( $question_type ){ |
|
| 408 | - |
|
| 409 | - Sensei_Templates::get_template ( 'single-quiz/question_type-' . $question_type . '.php' ); |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - /** |
|
| 413 | - * Echo the sensei question title. |
|
| 414 | - * |
|
| 415 | - * @uses WooThemes_Sensei_Question::get_the_question_title |
|
| 416 | - * |
|
| 417 | - * @since 1.9.0 |
|
| 418 | - * @param $question_id |
|
| 419 | - */ |
|
| 420 | - public static function the_question_title( $question_id ){ |
|
| 421 | - |
|
| 422 | - echo self::get_the_question_title( $question_id ); |
|
| 423 | - |
|
| 424 | - }// end the_question_title |
|
| 425 | - |
|
| 426 | - /** |
|
| 427 | - * Generate the question title with it's grade. |
|
| 428 | - * |
|
| 429 | - * @since 1.9.0 |
|
| 430 | - * |
|
| 431 | - * @param $question_id |
|
| 432 | - * @return string |
|
| 433 | - */ |
|
| 434 | - public static function get_the_question_title( $question_id ){ |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * Filter the sensei question title |
|
| 438 | - * |
|
| 439 | - * @since 1.3.0 |
|
| 440 | - * @param $question_title |
|
| 441 | - */ |
|
| 442 | - $title = apply_filters( 'sensei_question_title', get_the_title( $question_id ) ); |
|
| 443 | - |
|
| 444 | - /** |
|
| 445 | - * hook document in class-woothemes-sensei-message.php the_title() |
|
| 446 | - */ |
|
| 447 | - $title = apply_filters( 'sensei_single_title', $title, 'question'); |
|
| 448 | - |
|
| 449 | - $title_html = '<span class="question question-title">'; |
|
| 450 | - $title_html .= $title; |
|
| 451 | - $title_html .= '<span class="grade"><?php sensi_the_question_grade()?></span>'; |
|
| 452 | - $title_html .='</span>'; |
|
| 453 | - |
|
| 454 | - return $title_html; |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * Tech the question description |
|
| 459 | - * |
|
| 460 | - * @param $question_id |
|
| 461 | - * @return string |
|
| 462 | - */ |
|
| 463 | - public static function get_the_question_description( $question_id ){ |
|
| 464 | - |
|
| 465 | - $question = get_post( $question_id ); |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * Already documented within WordPress Core |
|
| 469 | - */ |
|
| 470 | - return apply_filters( 'the_content', $question->post_content ); |
|
| 471 | - |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * Output the question description |
|
| 476 | - * |
|
| 477 | - * @since 1.9.0 |
|
| 478 | - * @param $question_id |
|
| 479 | - */ |
|
| 480 | - public static function the_question_description( $question_id ){ |
|
| 481 | - |
|
| 482 | - echo self::get_the_question_description( $question_id ); |
|
| 483 | - |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - /** |
|
| 487 | - * Get the questions media markup |
|
| 488 | - * |
|
| 489 | - * @since 1.9.0 |
|
| 490 | - * @param $question_id |
|
| 491 | - * @return string |
|
| 492 | - */ |
|
| 493 | - public static function get_the_question_media( $question_id ){ |
|
| 494 | - |
|
| 495 | - $question_media = get_post_meta( $question_id, '_question_media', true ); |
|
| 496 | - $question_media_link = ''; |
|
| 497 | - if( 0 < intval( $question_media ) ) { |
|
| 498 | - $mimetype = get_post_mime_type( $question_media ); |
|
| 499 | - if( $mimetype ) { |
|
| 500 | - $mimetype_array = explode( '/', $mimetype); |
|
| 501 | - if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) { |
|
| 502 | - $question_media_type = $mimetype_array[0]; |
|
| 503 | - $question_media_url = wp_get_attachment_url( $question_media ); |
|
| 504 | - $attachment = get_post( $question_media ); |
|
| 505 | - $question_media_title = $attachment->post_title; |
|
| 506 | - $question_media_description = $attachment->post_content; |
|
| 507 | - switch( $question_media_type ) { |
|
| 508 | - case 'image': |
|
| 509 | - $image_size = apply_filters( 'sensei_question_image_size', 'medium', $question_id ); |
|
| 510 | - $attachment_src = wp_get_attachment_image_src( $question_media, $image_size ); |
|
| 511 | - $question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank"><img src="' . $attachment_src[0] . '" width="' . $attachment_src[1] . '" height="' . $attachment_src[2] . '" /></a>'; |
|
| 512 | - break; |
|
| 513 | - |
|
| 514 | - case 'audio': |
|
| 515 | - $question_media_link = wp_audio_shortcode( array( 'src' => $question_media_url ) ); |
|
| 516 | - break; |
|
| 517 | - |
|
| 518 | - case 'video': |
|
| 519 | - $question_media_link = wp_video_shortcode( array( 'src' => $question_media_url ) ); |
|
| 520 | - break; |
|
| 521 | - |
|
| 522 | - default: |
|
| 523 | - $question_media_filename = basename( $question_media_url ); |
|
| 524 | - $question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_filename . '</a>'; |
|
| 525 | - break; |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - } |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - $output = ''; |
|
| 532 | - if( $question_media_link ) { |
|
| 533 | - |
|
| 534 | - $output .= '<div class="question_media_display">'; |
|
| 535 | - $output .= $question_media_link; |
|
| 536 | - $output .= '<dl>'; |
|
| 537 | - |
|
| 538 | - if( $question_media_title ) { |
|
| 539 | - |
|
| 540 | - $output .= '<dt>'. $question_media_title. '</dt>'; |
|
| 541 | - |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - if( $question_media_description ) { |
|
| 545 | - |
|
| 546 | - $output .= '<dd>' . $question_media_description . '</dd>'; |
|
| 547 | - |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - $output .= '</dl>'; |
|
| 551 | - $output .= '</div>'; |
|
| 401 | + /** |
|
| 402 | + * This function simply loads the question type template |
|
| 403 | + * |
|
| 404 | + * @since 1.9.0 |
|
| 405 | + * @param $question_type |
|
| 406 | + */ |
|
| 407 | + public static function load_question_template( $question_type ){ |
|
| 408 | + |
|
| 409 | + Sensei_Templates::get_template ( 'single-quiz/question_type-' . $question_type . '.php' ); |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + /** |
|
| 413 | + * Echo the sensei question title. |
|
| 414 | + * |
|
| 415 | + * @uses WooThemes_Sensei_Question::get_the_question_title |
|
| 416 | + * |
|
| 417 | + * @since 1.9.0 |
|
| 418 | + * @param $question_id |
|
| 419 | + */ |
|
| 420 | + public static function the_question_title( $question_id ){ |
|
| 421 | + |
|
| 422 | + echo self::get_the_question_title( $question_id ); |
|
| 423 | + |
|
| 424 | + }// end the_question_title |
|
| 425 | + |
|
| 426 | + /** |
|
| 427 | + * Generate the question title with it's grade. |
|
| 428 | + * |
|
| 429 | + * @since 1.9.0 |
|
| 430 | + * |
|
| 431 | + * @param $question_id |
|
| 432 | + * @return string |
|
| 433 | + */ |
|
| 434 | + public static function get_the_question_title( $question_id ){ |
|
| 435 | + |
|
| 436 | + /** |
|
| 437 | + * Filter the sensei question title |
|
| 438 | + * |
|
| 439 | + * @since 1.3.0 |
|
| 440 | + * @param $question_title |
|
| 441 | + */ |
|
| 442 | + $title = apply_filters( 'sensei_question_title', get_the_title( $question_id ) ); |
|
| 443 | + |
|
| 444 | + /** |
|
| 445 | + * hook document in class-woothemes-sensei-message.php the_title() |
|
| 446 | + */ |
|
| 447 | + $title = apply_filters( 'sensei_single_title', $title, 'question'); |
|
| 448 | + |
|
| 449 | + $title_html = '<span class="question question-title">'; |
|
| 450 | + $title_html .= $title; |
|
| 451 | + $title_html .= '<span class="grade"><?php sensi_the_question_grade()?></span>'; |
|
| 452 | + $title_html .='</span>'; |
|
| 453 | + |
|
| 454 | + return $title_html; |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * Tech the question description |
|
| 459 | + * |
|
| 460 | + * @param $question_id |
|
| 461 | + * @return string |
|
| 462 | + */ |
|
| 463 | + public static function get_the_question_description( $question_id ){ |
|
| 464 | + |
|
| 465 | + $question = get_post( $question_id ); |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * Already documented within WordPress Core |
|
| 469 | + */ |
|
| 470 | + return apply_filters( 'the_content', $question->post_content ); |
|
| 471 | + |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * Output the question description |
|
| 476 | + * |
|
| 477 | + * @since 1.9.0 |
|
| 478 | + * @param $question_id |
|
| 479 | + */ |
|
| 480 | + public static function the_question_description( $question_id ){ |
|
| 481 | + |
|
| 482 | + echo self::get_the_question_description( $question_id ); |
|
| 483 | + |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + /** |
|
| 487 | + * Get the questions media markup |
|
| 488 | + * |
|
| 489 | + * @since 1.9.0 |
|
| 490 | + * @param $question_id |
|
| 491 | + * @return string |
|
| 492 | + */ |
|
| 493 | + public static function get_the_question_media( $question_id ){ |
|
| 494 | + |
|
| 495 | + $question_media = get_post_meta( $question_id, '_question_media', true ); |
|
| 496 | + $question_media_link = ''; |
|
| 497 | + if( 0 < intval( $question_media ) ) { |
|
| 498 | + $mimetype = get_post_mime_type( $question_media ); |
|
| 499 | + if( $mimetype ) { |
|
| 500 | + $mimetype_array = explode( '/', $mimetype); |
|
| 501 | + if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) { |
|
| 502 | + $question_media_type = $mimetype_array[0]; |
|
| 503 | + $question_media_url = wp_get_attachment_url( $question_media ); |
|
| 504 | + $attachment = get_post( $question_media ); |
|
| 505 | + $question_media_title = $attachment->post_title; |
|
| 506 | + $question_media_description = $attachment->post_content; |
|
| 507 | + switch( $question_media_type ) { |
|
| 508 | + case 'image': |
|
| 509 | + $image_size = apply_filters( 'sensei_question_image_size', 'medium', $question_id ); |
|
| 510 | + $attachment_src = wp_get_attachment_image_src( $question_media, $image_size ); |
|
| 511 | + $question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank"><img src="' . $attachment_src[0] . '" width="' . $attachment_src[1] . '" height="' . $attachment_src[2] . '" /></a>'; |
|
| 512 | + break; |
|
| 513 | + |
|
| 514 | + case 'audio': |
|
| 515 | + $question_media_link = wp_audio_shortcode( array( 'src' => $question_media_url ) ); |
|
| 516 | + break; |
|
| 517 | + |
|
| 518 | + case 'video': |
|
| 519 | + $question_media_link = wp_video_shortcode( array( 'src' => $question_media_url ) ); |
|
| 520 | + break; |
|
| 521 | + |
|
| 522 | + default: |
|
| 523 | + $question_media_filename = basename( $question_media_url ); |
|
| 524 | + $question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_filename . '</a>'; |
|
| 525 | + break; |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + } |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + $output = ''; |
|
| 532 | + if( $question_media_link ) { |
|
| 552 | 533 | |
| 534 | + $output .= '<div class="question_media_display">'; |
|
| 535 | + $output .= $question_media_link; |
|
| 536 | + $output .= '<dl>'; |
|
| 553 | 537 | |
| 554 | - } |
|
| 555 | - |
|
| 556 | - return $output; |
|
| 557 | - |
|
| 558 | - } // end get_the_question_media |
|
| 559 | - |
|
| 538 | + if( $question_media_title ) { |
|
| 560 | 539 | |
| 561 | - /** |
|
| 562 | - * Output the question media |
|
| 563 | - * |
|
| 564 | - * @since 1.9.0 |
|
| 565 | - * @param string $question_id |
|
| 566 | - */ |
|
| 567 | - public static function the_question_media( $question_id ){ |
|
| 540 | + $output .= '<dt>'. $question_media_title. '</dt>'; |
|
| 568 | 541 | |
| 569 | - echo self::get_the_question_media( $question_id ); |
|
| 542 | + } |
|
| 570 | 543 | |
| 571 | - } |
|
| 544 | + if( $question_media_description ) { |
|
| 572 | 545 | |
| 573 | - /** |
|
| 574 | - * Output a special field for the question needed for question submission. |
|
| 575 | - * |
|
| 576 | - * @since 1.9.0 |
|
| 577 | - * |
|
| 578 | - * @param $question_id |
|
| 579 | - */ |
|
| 580 | - public static function the_question_hidden_fields( $question_id ){ |
|
| 581 | - ?> |
|
| 546 | + $output .= '<dd>' . $question_media_description . '</dd>'; |
|
| 547 | + |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + $output .= '</dl>'; |
|
| 551 | + $output .= '</div>'; |
|
| 552 | + |
|
| 553 | + |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + return $output; |
|
| 557 | + |
|
| 558 | + } // end get_the_question_media |
|
| 559 | + |
|
| 560 | + |
|
| 561 | + /** |
|
| 562 | + * Output the question media |
|
| 563 | + * |
|
| 564 | + * @since 1.9.0 |
|
| 565 | + * @param string $question_id |
|
| 566 | + */ |
|
| 567 | + public static function the_question_media( $question_id ){ |
|
| 568 | + |
|
| 569 | + echo self::get_the_question_media( $question_id ); |
|
| 570 | + |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * Output a special field for the question needed for question submission. |
|
| 575 | + * |
|
| 576 | + * @since 1.9.0 |
|
| 577 | + * |
|
| 578 | + * @param $question_id |
|
| 579 | + */ |
|
| 580 | + public static function the_question_hidden_fields( $question_id ){ |
|
| 581 | + ?> |
|
| 582 | 582 | |
| 583 | 583 | <input type="hidden" name="question_id_<?php $question_id;?>" value="<?php $question_id;?>" /> |
| 584 | 584 | <input type="hidden" name="questions_asked[]" value="<?php esc_attr_e( $question_id ); ?>" /> |
| 585 | 585 | |
| 586 | 586 | <?php |
| 587 | - } |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | - /** |
|
| 590 | - * This function can only be run withing the single quiz question loop |
|
| 591 | - * |
|
| 592 | - * @since 1.9.0 |
|
| 593 | - * @param $question_id |
|
| 594 | - */ |
|
| 595 | - public static function answer_feedback_notes( $question_id ){ |
|
| 589 | + /** |
|
| 590 | + * This function can only be run withing the single quiz question loop |
|
| 591 | + * |
|
| 592 | + * @since 1.9.0 |
|
| 593 | + * @param $question_id |
|
| 594 | + */ |
|
| 595 | + public static function answer_feedback_notes( $question_id ){ |
|
| 596 | 596 | |
| 597 | - //IDS |
|
| 598 | - $quiz_id = get_the_ID(); |
|
| 599 | - $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 597 | + //IDS |
|
| 598 | + $quiz_id = get_the_ID(); |
|
| 599 | + $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 600 | 600 | |
| 601 | - // Data to check before showing feedback |
|
| 602 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, get_current_user_id() ); |
|
| 603 | - $user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() ); |
|
| 604 | - $not_empty_user_quiz_grade = !empty( $user_quiz_grade ); |
|
| 605 | - $reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id ); |
|
| 606 | - $lesson_completed = Sensei_Utils::user_completed_lesson( $lesson_id ); |
|
| 607 | - $quiz_grade_type = get_post_meta( $quiz_id , '_quiz_grade_type', true ); |
|
| 601 | + // Data to check before showing feedback |
|
| 602 | + $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, get_current_user_id() ); |
|
| 603 | + $user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() ); |
|
| 604 | + $not_empty_user_quiz_grade = !empty( $user_quiz_grade ); |
|
| 605 | + $reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id ); |
|
| 606 | + $lesson_completed = Sensei_Utils::user_completed_lesson( $lesson_id ); |
|
| 607 | + $quiz_grade_type = get_post_meta( $quiz_id , '_quiz_grade_type', true ); |
|
| 608 | 608 | |
| 609 | - if( ( $lesson_completed && $not_empty_user_quiz_grade ) |
|
| 610 | - || ( $lesson_completed && ! $reset_quiz_allowed && 'auto' == $quiz_grade_type ) |
|
| 611 | - || ( 'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $not_empty_user_quiz_grade ) ) { |
|
| 609 | + if( ( $lesson_completed && $not_empty_user_quiz_grade ) |
|
| 610 | + || ( $lesson_completed && ! $reset_quiz_allowed && 'auto' == $quiz_grade_type ) |
|
| 611 | + || ( 'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $not_empty_user_quiz_grade ) ) { |
|
| 612 | 612 | |
| 613 | - $answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, get_current_user_id() ); |
|
| 613 | + $answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, get_current_user_id() ); |
|
| 614 | 614 | |
| 615 | - if( $answer_notes ) { ?> |
|
| 615 | + if( $answer_notes ) { ?> |
|
| 616 | 616 | |
| 617 | 617 | <div class="sensei-message info info-special answer-feedback"> |
| 618 | 618 | |
| 619 | 619 | <?php |
| 620 | 620 | |
| 621 | - /** |
|
| 622 | - * Filter the answer feedback |
|
| 623 | - * Since 1.9.0 |
|
| 624 | - * |
|
| 625 | - * @param string $answer_notes |
|
| 626 | - * @param string $question_id |
|
| 627 | - * @param string $lesson_id |
|
| 628 | - */ |
|
| 629 | - echo apply_filters( 'sensei_question_answer_notes', $answer_notes, $question_id, $lesson_id ); |
|
| 621 | + /** |
|
| 622 | + * Filter the answer feedback |
|
| 623 | + * Since 1.9.0 |
|
| 624 | + * |
|
| 625 | + * @param string $answer_notes |
|
| 626 | + * @param string $question_id |
|
| 627 | + * @param string $lesson_id |
|
| 628 | + */ |
|
| 629 | + echo apply_filters( 'sensei_question_answer_notes', $answer_notes, $question_id, $lesson_id ); |
|
| 630 | 630 | |
| 631 | - ?> |
|
| 631 | + ?> |
|
| 632 | 632 | |
| 633 | 633 | </div> |
| 634 | 634 | |
| 635 | 635 | <?php } |
| 636 | 636 | |
| 637 | - }// end if we can show answer feedback |
|
| 637 | + }// end if we can show answer feedback |
|
| 638 | 638 | |
| 639 | - }// end answer_feedback_notes |
|
| 639 | + }// end answer_feedback_notes |
|
| 640 | 640 | |
| 641 | - /** |
|
| 642 | - * This function has to be run inside the quiz question loop on the single quiz page. |
|
| 643 | - * |
|
| 644 | - * |
|
| 645 | - * @since 1.9.0 |
|
| 646 | - * @param string $question_id |
|
| 647 | - */ |
|
| 648 | - public static function the_answer_result_indication( $question_id ){ |
|
| 641 | + /** |
|
| 642 | + * This function has to be run inside the quiz question loop on the single quiz page. |
|
| 643 | + * |
|
| 644 | + * |
|
| 645 | + * @since 1.9.0 |
|
| 646 | + * @param string $question_id |
|
| 647 | + */ |
|
| 648 | + public static function the_answer_result_indication( $question_id ){ |
|
| 649 | 649 | |
| 650 | - global $post, $current_user, $sensei_question_loop; |
|
| 650 | + global $post, $current_user, $sensei_question_loop; |
|
| 651 | 651 | |
| 652 | - // Post Data |
|
| 653 | - $quiz_id = $sensei_question_loop['quiz_id']; |
|
| 654 | - $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 655 | - $question_item = $sensei_question_loop['current_question']; |
|
| 652 | + // Post Data |
|
| 653 | + $quiz_id = $sensei_question_loop['quiz_id']; |
|
| 654 | + $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 655 | + $question_item = $sensei_question_loop['current_question']; |
|
| 656 | 656 | |
| 657 | - // Setup variable needed to determine if the message should show and what it should show |
|
| 658 | - $user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() ); |
|
| 659 | - $lesson_complete = Sensei_Utils::user_completed_lesson( $lesson_id, get_current_user_id() ); |
|
| 660 | - $reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id ); |
|
| 661 | - $quiz_grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true ); |
|
| 657 | + // Setup variable needed to determine if the message should show and what it should show |
|
| 658 | + $user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() ); |
|
| 659 | + $lesson_complete = Sensei_Utils::user_completed_lesson( $lesson_id, get_current_user_id() ); |
|
| 660 | + $reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id ); |
|
| 661 | + $quiz_grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true ); |
|
| 662 | 662 | |
| 663 | - // retrieve the question total grade |
|
| 664 | - $question_grade = Sensei()->question->get_question_grade( $question_id ); |
|
| 663 | + // retrieve the question total grade |
|
| 664 | + $question_grade = Sensei()->question->get_question_grade( $question_id ); |
|
| 665 | 665 | |
| 666 | - // retrieve grade the user achieved |
|
| 667 | - $user_question_grade = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id, get_current_user_id() ); |
|
| 666 | + // retrieve grade the user achieved |
|
| 667 | + $user_question_grade = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id, get_current_user_id() ); |
|
| 668 | 668 | |
| 669 | - // Question ID |
|
| 670 | - $question_id = $question_item->ID; |
|
| 669 | + // Question ID |
|
| 670 | + $question_id = $question_item->ID; |
|
| 671 | 671 | |
| 672 | - // conditions to check |
|
| 673 | - $completed_with_valid_grade = $lesson_complete && $user_quiz_grade != '' ; |
|
| 674 | - $completed_with_valid_grade_and_reset_not_allowed = $lesson_complete && $user_quiz_grade != '' && ! $reset_quiz_allowed ; |
|
| 675 | - $grade_type_auto_a_valid_grade_and_reset_not_allowed = 'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $user_quiz_grade != '' ; |
|
| 672 | + // conditions to check |
|
| 673 | + $completed_with_valid_grade = $lesson_complete && $user_quiz_grade != '' ; |
|
| 674 | + $completed_with_valid_grade_and_reset_not_allowed = $lesson_complete && $user_quiz_grade != '' && ! $reset_quiz_allowed ; |
|
| 675 | + $grade_type_auto_a_valid_grade_and_reset_not_allowed = 'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $user_quiz_grade != '' ; |
|
| 676 | 676 | |
| 677 | - if ( $completed_with_valid_grade |
|
| 678 | - || $completed_with_valid_grade_and_reset_not_allowed |
|
| 679 | - || $grade_type_auto_a_valid_grade_and_reset_not_allowed ) { |
|
| 677 | + if ( $completed_with_valid_grade |
|
| 678 | + || $completed_with_valid_grade_and_reset_not_allowed |
|
| 679 | + || $grade_type_auto_a_valid_grade_and_reset_not_allowed ) { |
|
| 680 | 680 | |
| 681 | - $user_correct = false; |
|
| 682 | - $answer_message = __( 'Incorrect', 'woothemes-sensei' ); |
|
| 683 | - $answer_message_class = 'user_wrong'; |
|
| 684 | - // For zero grade mark as 'correct' but add no classes |
|
| 685 | - if ( 0 == $question_grade ) { |
|
| 681 | + $user_correct = false; |
|
| 682 | + $answer_message = __( 'Incorrect', 'woothemes-sensei' ); |
|
| 683 | + $answer_message_class = 'user_wrong'; |
|
| 684 | + // For zero grade mark as 'correct' but add no classes |
|
| 685 | + if ( 0 == $question_grade ) { |
|
| 686 | 686 | |
| 687 | - $user_correct = true; |
|
| 688 | - $answer_message = ''; |
|
| 689 | - $answer_message_class = ''; |
|
| 687 | + $user_correct = true; |
|
| 688 | + $answer_message = ''; |
|
| 689 | + $answer_message_class = ''; |
|
| 690 | 690 | |
| 691 | - } else if( $user_question_grade > 0 ) { |
|
| 691 | + } else if( $user_question_grade > 0 ) { |
|
| 692 | 692 | |
| 693 | - $user_correct = true; |
|
| 694 | - $answer_message = sprintf( __( 'Grade: %d', 'woothemes-sensei' ), $user_question_grade ); |
|
| 695 | - $answer_message_class = 'user_right'; |
|
| 693 | + $user_correct = true; |
|
| 694 | + $answer_message = sprintf( __( 'Grade: %d', 'woothemes-sensei' ), $user_question_grade ); |
|
| 695 | + $answer_message_class = 'user_right'; |
|
| 696 | 696 | |
| 697 | - } |
|
| 697 | + } |
|
| 698 | 698 | |
| 699 | - // attach the correct answer if the question is auto gradable and user got it wrong |
|
| 700 | - if( !$reset_quiz_allowed && !$user_correct ){ |
|
| 699 | + // attach the correct answer if the question is auto gradable and user got it wrong |
|
| 700 | + if( !$reset_quiz_allowed && !$user_correct ){ |
|
| 701 | 701 | |
| 702 | - $answer_message .= ' - '. __('Right Answer:','woothemes-sensei') . ' ' . self::get_correct_answer( $question_item->ID ); |
|
| 702 | + $answer_message .= ' - '. __('Right Answer:','woothemes-sensei') . ' ' . self::get_correct_answer( $question_item->ID ); |
|
| 703 | 703 | |
| 704 | - } |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | - // answer feedback |
|
| 707 | - $answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, $current_user->ID ); |
|
| 708 | - if( $answer_notes ) { |
|
| 709 | - $answer_message_class .= ' has_notes'; |
|
| 710 | - } |
|
| 711 | - ?> |
|
| 706 | + // answer feedback |
|
| 707 | + $answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, $current_user->ID ); |
|
| 708 | + if( $answer_notes ) { |
|
| 709 | + $answer_message_class .= ' has_notes'; |
|
| 710 | + } |
|
| 711 | + ?> |
|
| 712 | 712 | |
| 713 | 713 | <div class="answer_message <?php esc_attr_e( $answer_message_class ); ?>"> |
| 714 | 714 | |
@@ -718,387 +718,387 @@ discard block |
||
| 718 | 718 | |
| 719 | 719 | <?php |
| 720 | 720 | |
| 721 | - } // end if user can see all the goodies |
|
| 722 | - |
|
| 723 | - }// end the_answer_result_indication |
|
| 724 | - |
|
| 725 | - /** |
|
| 726 | - * Generate the question template data and return it as an array. |
|
| 727 | - * |
|
| 728 | - * @since 1.9.0 |
|
| 729 | - * |
|
| 730 | - * @param string $question_id |
|
| 731 | - * @param $quiz_id |
|
| 732 | - * @return array $question_data |
|
| 733 | - */ |
|
| 734 | - public static function get_template_data( $question_id, $quiz_id ){ |
|
| 735 | - |
|
| 736 | - $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 737 | - |
|
| 738 | - $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true ); |
|
| 739 | - //backwards compatibility |
|
| 740 | - if( 'on' == $reset_allowed ) { |
|
| 741 | - $reset_allowed = 1; |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - // Check again that the lesson is complete |
|
| 745 | - $user_lesson_end = Sensei_Utils::user_completed_lesson( Sensei()->quiz->get_lesson_id( $quiz_id), get_current_user_id() ); |
|
| 746 | - $user_lesson_complete = false; |
|
| 747 | - if ( $user_lesson_end ) { |
|
| 748 | - $user_lesson_complete = true; |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - //setup the question data |
|
| 752 | - $data[ 'ID' ] = $question_id; |
|
| 753 | - $data[ 'title' ] = get_the_title( $question_id ); |
|
| 754 | - $data[ 'content' ] = get_post( $question_id )->post_content; |
|
| 755 | - $data[ 'quiz_id' ] = $quiz_id; |
|
| 756 | - $data[ 'lesson_id' ] = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 757 | - $data[ 'type' ] = Sensei()->question->get_question_type( $question_id ); |
|
| 758 | - $data[ 'question_grade' ] = Sensei()->question->get_question_grade( $question_id ); |
|
| 759 | - $data[ 'user_question_grade' ] = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id , get_current_user_id()); |
|
| 760 | - $data[ 'question_right_answer' ] = get_post_meta( $question_id , '_question_right_answer', true ); |
|
| 761 | - $data[ 'question_wrong_answers' ] = get_post_meta( $question_id , '_question_wrong_answers', true ); |
|
| 762 | - $data[ 'user_answer_entry' ] = Sensei()->quiz->get_user_question_answer( $lesson_id, $question_id , get_current_user_id() ); |
|
| 763 | - $data[ 'lesson_completed' ] = Sensei_Utils::user_completed_course( $lesson_id, get_current_user_id( ) ); |
|
| 764 | - $data[ 'quiz_grade_type' ] = get_post_meta( $quiz_id , '_quiz_grade_type', true ); |
|
| 765 | - $data[ 'reset_quiz_allowed' ] = $reset_allowed; |
|
| 766 | - $data[ 'lesson_complete' ] = $user_lesson_complete; |
|
| 767 | - |
|
| 768 | - /** |
|
| 769 | - * Filter the question template data. This filter fires in |
|
| 770 | - * the get_template_data function |
|
| 771 | - * |
|
| 772 | - * @hooked self::boolean_load_question_data |
|
| 773 | - * |
|
| 774 | - * @since 1.9.0 |
|
| 775 | - * |
|
| 776 | - * @param array $data |
|
| 777 | - * @param string $question_id |
|
| 778 | - * @param string $quiz_id |
|
| 779 | - */ |
|
| 780 | - return apply_filters( 'sensei_get_question_template_data', $data, $question_id, $quiz_id ); |
|
| 721 | + } // end if user can see all the goodies |
|
| 781 | 722 | |
| 782 | - } |
|
| 723 | + }// end the_answer_result_indication |
|
| 783 | 724 | |
| 784 | - /** |
|
| 785 | - * Load multiple choice question data on the sensei_get_question_template_data |
|
| 786 | - * filter. |
|
| 787 | - * |
|
| 788 | - * @since 1.9.0 |
|
| 789 | - * |
|
| 790 | - * @param $question_data |
|
| 791 | - * @param $question_id |
|
| 792 | - * @param $quiz_id |
|
| 793 | - * |
|
| 794 | - * @return array() |
|
| 795 | - */ |
|
| 796 | - public static function file_upload_load_question_data ( $question_data, $question_id, $quiz_id ){ |
|
| 725 | + /** |
|
| 726 | + * Generate the question template data and return it as an array. |
|
| 727 | + * |
|
| 728 | + * @since 1.9.0 |
|
| 729 | + * |
|
| 730 | + * @param string $question_id |
|
| 731 | + * @param $quiz_id |
|
| 732 | + * @return array $question_data |
|
| 733 | + */ |
|
| 734 | + public static function get_template_data( $question_id, $quiz_id ){ |
|
| 797 | 735 | |
| 736 | + $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 798 | 737 | |
| 799 | - if( 'file-upload' == Sensei()->question->get_question_type( $question_id ) ) { |
|
| 738 | + $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true ); |
|
| 739 | + //backwards compatibility |
|
| 740 | + if( 'on' == $reset_allowed ) { |
|
| 741 | + $reset_allowed = 1; |
|
| 742 | + } |
|
| 800 | 743 | |
| 801 | - // Get uploaded file |
|
| 802 | - $attachment_id = $question_data[ 'user_answer_entry' ]; |
|
| 803 | - $answer_media_url = $answer_media_filename = ''; |
|
| 744 | + // Check again that the lesson is complete |
|
| 745 | + $user_lesson_end = Sensei_Utils::user_completed_lesson( Sensei()->quiz->get_lesson_id( $quiz_id), get_current_user_id() ); |
|
| 746 | + $user_lesson_complete = false; |
|
| 747 | + if ( $user_lesson_end ) { |
|
| 748 | + $user_lesson_complete = true; |
|
| 749 | + } |
|
| 804 | 750 | |
| 751 | + //setup the question data |
|
| 752 | + $data[ 'ID' ] = $question_id; |
|
| 753 | + $data[ 'title' ] = get_the_title( $question_id ); |
|
| 754 | + $data[ 'content' ] = get_post( $question_id )->post_content; |
|
| 755 | + $data[ 'quiz_id' ] = $quiz_id; |
|
| 756 | + $data[ 'lesson_id' ] = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
| 757 | + $data[ 'type' ] = Sensei()->question->get_question_type( $question_id ); |
|
| 758 | + $data[ 'question_grade' ] = Sensei()->question->get_question_grade( $question_id ); |
|
| 759 | + $data[ 'user_question_grade' ] = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id , get_current_user_id()); |
|
| 760 | + $data[ 'question_right_answer' ] = get_post_meta( $question_id , '_question_right_answer', true ); |
|
| 761 | + $data[ 'question_wrong_answers' ] = get_post_meta( $question_id , '_question_wrong_answers', true ); |
|
| 762 | + $data[ 'user_answer_entry' ] = Sensei()->quiz->get_user_question_answer( $lesson_id, $question_id , get_current_user_id() ); |
|
| 763 | + $data[ 'lesson_completed' ] = Sensei_Utils::user_completed_course( $lesson_id, get_current_user_id( ) ); |
|
| 764 | + $data[ 'quiz_grade_type' ] = get_post_meta( $quiz_id , '_quiz_grade_type', true ); |
|
| 765 | + $data[ 'reset_quiz_allowed' ] = $reset_allowed; |
|
| 766 | + $data[ 'lesson_complete' ] = $user_lesson_complete; |
|
| 767 | + |
|
| 768 | + /** |
|
| 769 | + * Filter the question template data. This filter fires in |
|
| 770 | + * the get_template_data function |
|
| 771 | + * |
|
| 772 | + * @hooked self::boolean_load_question_data |
|
| 773 | + * |
|
| 774 | + * @since 1.9.0 |
|
| 775 | + * |
|
| 776 | + * @param array $data |
|
| 777 | + * @param string $question_id |
|
| 778 | + * @param string $quiz_id |
|
| 779 | + */ |
|
| 780 | + return apply_filters( 'sensei_get_question_template_data', $data, $question_id, $quiz_id ); |
|
| 805 | 781 | |
| 806 | - $question_helptext = ''; |
|
| 807 | - if( isset( $question_data['question_wrong_answers'][0] ) ) { |
|
| 782 | + } |
|
| 808 | 783 | |
| 809 | - $question_helptext = $question_data['question_wrong_answers'][0]; |
|
| 784 | + /** |
|
| 785 | + * Load multiple choice question data on the sensei_get_question_template_data |
|
| 786 | + * filter. |
|
| 787 | + * |
|
| 788 | + * @since 1.9.0 |
|
| 789 | + * |
|
| 790 | + * @param $question_data |
|
| 791 | + * @param $question_id |
|
| 792 | + * @param $quiz_id |
|
| 793 | + * |
|
| 794 | + * @return array() |
|
| 795 | + */ |
|
| 796 | + public static function file_upload_load_question_data ( $question_data, $question_id, $quiz_id ){ |
|
| 810 | 797 | |
| 811 | - } |
|
| 812 | 798 | |
| 799 | + if( 'file-upload' == Sensei()->question->get_question_type( $question_id ) ) { |
|
| 813 | 800 | |
| 814 | - if( 0 < intval( $attachment_id ) ) { |
|
| 801 | + // Get uploaded file |
|
| 802 | + $attachment_id = $question_data[ 'user_answer_entry' ]; |
|
| 803 | + $answer_media_url = $answer_media_filename = ''; |
|
| 815 | 804 | |
| 816 | - $answer_media_url = wp_get_attachment_url( $attachment_id ); |
|
| 817 | - $answer_media_filename = basename( $answer_media_url ); |
|
| 818 | 805 | |
| 819 | - } |
|
| 806 | + $question_helptext = ''; |
|
| 807 | + if( isset( $question_data['question_wrong_answers'][0] ) ) { |
|
| 820 | 808 | |
| 809 | + $question_helptext = $question_data['question_wrong_answers'][0]; |
|
| 821 | 810 | |
| 822 | - // Get max upload file size, formatted for display |
|
| 823 | - // Code copied from wp-admin/includes/media.php:1515 |
|
| 824 | - $upload_size_unit = $max_upload_size = wp_max_upload_size(); |
|
| 825 | - $sizes = array( 'KB', 'MB', 'GB' ); |
|
| 826 | - for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) { |
|
| 827 | - $upload_size_unit /= 1024; |
|
| 828 | - } |
|
| 829 | - if ( $u < 0 ) { |
|
| 811 | + } |
|
| 830 | 812 | |
| 831 | - $upload_size_unit = 0; |
|
| 832 | - $u = 0; |
|
| 833 | 813 | |
| 834 | - } else { |
|
| 814 | + if( 0 < intval( $attachment_id ) ) { |
|
| 835 | 815 | |
| 836 | - $upload_size_unit = (int) $upload_size_unit; |
|
| 816 | + $answer_media_url = wp_get_attachment_url( $attachment_id ); |
|
| 817 | + $answer_media_filename = basename( $answer_media_url ); |
|
| 837 | 818 | |
| 838 | - } |
|
| 839 | - $max_upload_size = sprintf( __( 'Maximum upload file size: %d%s' ), esc_html( $upload_size_unit ), esc_html( $sizes[ $u ] ) ); |
|
| 819 | + } |
|
| 840 | 820 | |
| 841 | - // Assemble all the data needed by the file upload template |
|
| 842 | - $question_data[ 'answer_media_url' ] = $answer_media_url; |
|
| 843 | - $question_data[ 'answer_media_filename' ] = $answer_media_filename; |
|
| 844 | - $question_data[ 'max_upload_size' ] = $max_upload_size; |
|
| 845 | 821 | |
| 846 | - $question_data[ 'question_helptext' ] = $question_helptext; |
|
| 822 | + // Get max upload file size, formatted for display |
|
| 823 | + // Code copied from wp-admin/includes/media.php:1515 |
|
| 824 | + $upload_size_unit = $max_upload_size = wp_max_upload_size(); |
|
| 825 | + $sizes = array( 'KB', 'MB', 'GB' ); |
|
| 826 | + for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) { |
|
| 827 | + $upload_size_unit /= 1024; |
|
| 828 | + } |
|
| 829 | + if ( $u < 0 ) { |
|
| 847 | 830 | |
| 848 | - }// end if is file upload type |
|
| 831 | + $upload_size_unit = 0; |
|
| 832 | + $u = 0; |
|
| 849 | 833 | |
| 850 | - return $question_data; |
|
| 834 | + } else { |
|
| 851 | 835 | |
| 852 | - }// end file_upload_load_question_data |
|
| 836 | + $upload_size_unit = (int) $upload_size_unit; |
|
| 853 | 837 | |
| 854 | - /** |
|
| 855 | - * Load multiple choice question data on the sensei_get_question_template_data |
|
| 856 | - * filter. |
|
| 857 | - * |
|
| 858 | - * @since 1.9.0 |
|
| 859 | - * |
|
| 860 | - * @param $question_data |
|
| 861 | - * @param $question_id |
|
| 862 | - * @param $quiz_id |
|
| 863 | - * |
|
| 864 | - * @return array() |
|
| 865 | - */ |
|
| 866 | - public static function multiple_choice_load_question_data( $question_data, $question_id, $quiz_id ){ |
|
| 838 | + } |
|
| 839 | + $max_upload_size = sprintf( __( 'Maximum upload file size: %d%s' ), esc_html( $upload_size_unit ), esc_html( $sizes[ $u ] ) ); |
|
| 867 | 840 | |
| 868 | - if( 'multiple-choice' == Sensei()->question->get_question_type( $question_id ) ) { |
|
| 841 | + // Assemble all the data needed by the file upload template |
|
| 842 | + $question_data[ 'answer_media_url' ] = $answer_media_url; |
|
| 843 | + $question_data[ 'answer_media_filename' ] = $answer_media_filename; |
|
| 844 | + $question_data[ 'max_upload_size' ] = $max_upload_size; |
|
| 869 | 845 | |
| 846 | + $question_data[ 'question_helptext' ] = $question_helptext; |
|
| 870 | 847 | |
| 871 | - $answer_type = 'radio'; |
|
| 872 | - if ( is_array( $question_data[ 'question_right_answer' ] ) && ( 1 < count( $question_data[ 'question_right_answer' ] ) ) ) { |
|
| 848 | + }// end if is file upload type |
|
| 873 | 849 | |
| 874 | - $answer_type = 'checkbox'; |
|
| 850 | + return $question_data; |
|
| 875 | 851 | |
| 876 | - } |
|
| 852 | + }// end file_upload_load_question_data |
|
| 877 | 853 | |
| 878 | - // Merge right and wrong answers |
|
| 879 | - if ( is_array( $question_data[ 'question_right_answer' ] ) ) { |
|
| 854 | + /** |
|
| 855 | + * Load multiple choice question data on the sensei_get_question_template_data |
|
| 856 | + * filter. |
|
| 857 | + * |
|
| 858 | + * @since 1.9.0 |
|
| 859 | + * |
|
| 860 | + * @param $question_data |
|
| 861 | + * @param $question_id |
|
| 862 | + * @param $quiz_id |
|
| 863 | + * |
|
| 864 | + * @return array() |
|
| 865 | + */ |
|
| 866 | + public static function multiple_choice_load_question_data( $question_data, $question_id, $quiz_id ){ |
|
| 880 | 867 | |
| 881 | - $merged_options = array_merge( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] ); |
|
| 868 | + if( 'multiple-choice' == Sensei()->question->get_question_type( $question_id ) ) { |
|
| 882 | 869 | |
| 883 | - } else { |
|
| 884 | 870 | |
| 885 | - array_push( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] ); |
|
| 886 | - $merged_options = $question_data[ 'question_wrong_answers' ]; |
|
| 871 | + $answer_type = 'radio'; |
|
| 872 | + if ( is_array( $question_data[ 'question_right_answer' ] ) && ( 1 < count( $question_data[ 'question_right_answer' ] ) ) ) { |
|
| 887 | 873 | |
| 888 | - } |
|
| 874 | + $answer_type = 'checkbox'; |
|
| 889 | 875 | |
| 890 | - // Setup answer options array. |
|
| 891 | - $question_answers_options = array(); |
|
| 892 | - $count = 0; |
|
| 876 | + } |
|
| 893 | 877 | |
| 894 | - foreach( $merged_options as $answer ) { |
|
| 878 | + // Merge right and wrong answers |
|
| 879 | + if ( is_array( $question_data[ 'question_right_answer' ] ) ) { |
|
| 895 | 880 | |
| 896 | - $count++; |
|
| 897 | - $question_option = array(); |
|
| 881 | + $merged_options = array_merge( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] ); |
|
| 898 | 882 | |
| 899 | - if( ( $question_data[ 'lesson_completed' ] && $question_data[ 'user_quiz_grade' ] != '' ) |
|
| 900 | - || ( $question_data[ 'lesson_completed' ] && ! $question_data[ 'reset_quiz_allowed' ] && $question_data[ 'user_quiz_grade' ] != '' ) |
|
| 901 | - || ( 'auto' == $question_data[ 'quiz_grade_type' ] && ! $question_data[ 'reset_quiz_allowed' ] && ! empty( $question_data[ 'user_quiz_grade' ] ) ) ) { |
|
| 883 | + } else { |
|
| 902 | 884 | |
| 903 | - $user_correct = false; |
|
| 885 | + array_push( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] ); |
|
| 886 | + $merged_options = $question_data[ 'question_wrong_answers' ]; |
|
| 904 | 887 | |
| 888 | + } |
|
| 905 | 889 | |
| 906 | - // For zero grade mark as 'correct' but add no classes |
|
| 907 | - if ( 0 == $question_data[ 'question_grade' ] ) { |
|
| 890 | + // Setup answer options array. |
|
| 891 | + $question_answers_options = array(); |
|
| 892 | + $count = 0; |
|
| 908 | 893 | |
| 909 | - $user_correct = true; |
|
| 894 | + foreach( $merged_options as $answer ) { |
|
| 910 | 895 | |
| 911 | - } else if( $question_data[ 'user_question_grade' ] > 0 ) { |
|
| 896 | + $count++; |
|
| 897 | + $question_option = array(); |
|
| 912 | 898 | |
| 913 | - $user_correct = true; |
|
| 899 | + if( ( $question_data[ 'lesson_completed' ] && $question_data[ 'user_quiz_grade' ] != '' ) |
|
| 900 | + || ( $question_data[ 'lesson_completed' ] && ! $question_data[ 'reset_quiz_allowed' ] && $question_data[ 'user_quiz_grade' ] != '' ) |
|
| 901 | + || ( 'auto' == $question_data[ 'quiz_grade_type' ] && ! $question_data[ 'reset_quiz_allowed' ] && ! empty( $question_data[ 'user_quiz_grade' ] ) ) ) { |
|
| 914 | 902 | |
| 915 | - } |
|
| 903 | + $user_correct = false; |
|
| 916 | 904 | |
| 917 | - } |
|
| 918 | 905 | |
| 919 | - // setup the option specific classes |
|
| 920 | - $answer_class = ''; |
|
| 921 | - if( isset( $user_correct ) && 0 < $question_data[ 'question_grade' ] ) { |
|
| 922 | - if ( is_array( $question_data['question_right_answer'] ) && in_array($answer, $question_data['question_right_answer']) ) { |
|
| 906 | + // For zero grade mark as 'correct' but add no classes |
|
| 907 | + if ( 0 == $question_data[ 'question_grade' ] ) { |
|
| 923 | 908 | |
| 924 | - $answer_class .= ' right_answer'; |
|
| 909 | + $user_correct = true; |
|
| 925 | 910 | |
| 926 | - } elseif( !is_array($question_data['question_right_answer']) && $question_data['question_right_answer'] == $answer ) { |
|
| 911 | + } else if( $question_data[ 'user_question_grade' ] > 0 ) { |
|
| 927 | 912 | |
| 928 | - $answer_class .= ' right_answer'; |
|
| 913 | + $user_correct = true; |
|
| 929 | 914 | |
| 930 | - } elseif( ( is_array( $question_data['user_answer_entry'] ) && in_array($answer, $question_data['user_answer_entry'] ) ) |
|
| 931 | - || ( ! $question_data['user_answer_entry'] && $question_data['user_answer_entry'] == $answer ) ) { |
|
| 915 | + } |
|
| 932 | 916 | |
| 933 | - $answer_class = 'user_wrong'; |
|
| 934 | - if( $user_correct ) { |
|
| 917 | + } |
|
| 935 | 918 | |
| 936 | - $answer_class = 'user_right'; |
|
| 919 | + // setup the option specific classes |
|
| 920 | + $answer_class = ''; |
|
| 921 | + if( isset( $user_correct ) && 0 < $question_data[ 'question_grade' ] ) { |
|
| 922 | + if ( is_array( $question_data['question_right_answer'] ) && in_array($answer, $question_data['question_right_answer']) ) { |
|
| 937 | 923 | |
| 938 | - } |
|
| 924 | + $answer_class .= ' right_answer'; |
|
| 939 | 925 | |
| 940 | - } |
|
| 926 | + } elseif( !is_array($question_data['question_right_answer']) && $question_data['question_right_answer'] == $answer ) { |
|
| 941 | 927 | |
| 942 | - } |
|
| 928 | + $answer_class .= ' right_answer'; |
|
| 943 | 929 | |
| 944 | - // determine if the current option must be checked |
|
| 945 | - $checked = ''; |
|
| 946 | - if ( isset( $question_data['user_answer_entry'] ) && 0 < count( $question_data['user_answer_entry'] ) ) { |
|
| 947 | - if ( is_array( $question_data['user_answer_entry'] ) && in_array( $answer, $question_data['user_answer_entry'] ) ) { |
|
| 930 | + } elseif( ( is_array( $question_data['user_answer_entry'] ) && in_array($answer, $question_data['user_answer_entry'] ) ) |
|
| 931 | + || ( ! $question_data['user_answer_entry'] && $question_data['user_answer_entry'] == $answer ) ) { |
|
| 948 | 932 | |
| 949 | - $checked = 'checked="checked"'; |
|
| 933 | + $answer_class = 'user_wrong'; |
|
| 934 | + if( $user_correct ) { |
|
| 950 | 935 | |
| 951 | - } elseif ( !is_array( $question_data['user_answer_entry'] ) ) { |
|
| 936 | + $answer_class = 'user_right'; |
|
| 952 | 937 | |
| 953 | - $checked = checked( $answer, $question_data['user_answer_entry'] , false ); |
|
| 938 | + } |
|
| 954 | 939 | |
| 955 | - } |
|
| 940 | + } |
|
| 956 | 941 | |
| 957 | - } // End If Statement |
|
| 942 | + } |
|
| 958 | 943 | |
| 959 | - //Load the answer option data |
|
| 960 | - $question_option[ 'ID' ] = Sensei()->lesson->get_answer_id( $answer ); |
|
| 961 | - $question_option[ 'answer' ] = $answer; |
|
| 962 | - $question_option[ 'option_class'] = $answer_class; |
|
| 963 | - $question_option[ 'checked'] = $checked; |
|
| 964 | - $question_option[ 'count' ] = $count; |
|
| 965 | - $question_option[ 'type' ] = $answer_type; |
|
| 944 | + // determine if the current option must be checked |
|
| 945 | + $checked = ''; |
|
| 946 | + if ( isset( $question_data['user_answer_entry'] ) && 0 < count( $question_data['user_answer_entry'] ) ) { |
|
| 947 | + if ( is_array( $question_data['user_answer_entry'] ) && in_array( $answer, $question_data['user_answer_entry'] ) ) { |
|
| 966 | 948 | |
| 967 | - // add the speci fic option to the list of options for this question |
|
| 968 | - $question_answers_options[$question_option[ 'ID' ]] = $question_option; |
|
| 949 | + $checked = 'checked="checked"'; |
|
| 969 | 950 | |
| 970 | - } // end for each option |
|
| 951 | + } elseif ( !is_array( $question_data['user_answer_entry'] ) ) { |
|
| 971 | 952 | |
| 953 | + $checked = checked( $answer, $question_data['user_answer_entry'] , false ); |
|
| 972 | 954 | |
| 973 | - // Shuffle the array depending on the settings |
|
| 974 | - $answer_options_sorted = array(); |
|
| 975 | - $random_order = get_post_meta( $question_data['ID'], '_random_order', true ); |
|
| 976 | - if( $random_order && $random_order == 'yes' ) { |
|
| 955 | + } |
|
| 977 | 956 | |
| 978 | - $answer_options_sorted = $question_answers_options; |
|
| 979 | - shuffle( $answer_options_sorted ); |
|
| 957 | + } // End If Statement |
|
| 980 | 958 | |
| 981 | - } else { |
|
| 959 | + //Load the answer option data |
|
| 960 | + $question_option[ 'ID' ] = Sensei()->lesson->get_answer_id( $answer ); |
|
| 961 | + $question_option[ 'answer' ] = $answer; |
|
| 962 | + $question_option[ 'option_class'] = $answer_class; |
|
| 963 | + $question_option[ 'checked'] = $checked; |
|
| 964 | + $question_option[ 'count' ] = $count; |
|
| 965 | + $question_option[ 'type' ] = $answer_type; |
|
| 982 | 966 | |
| 983 | - $answer_order = array(); |
|
| 984 | - $answer_order_string = get_post_meta( $question_data['ID'], '_answer_order', true ); |
|
| 985 | - if( $answer_order_string ) { |
|
| 967 | + // add the speci fic option to the list of options for this question |
|
| 968 | + $question_answers_options[$question_option[ 'ID' ]] = $question_option; |
|
| 986 | 969 | |
| 987 | - $answer_order = array_filter( explode( ',', $answer_order_string ) ); |
|
| 988 | - if( count( $answer_order ) > 0 ) { |
|
| 970 | + } // end for each option |
|
| 989 | 971 | |
| 990 | - foreach( $answer_order as $answer_id ) { |
|
| 991 | 972 | |
| 992 | - if( isset( $question_answers_options[ $answer_id ] ) ) { |
|
| 973 | + // Shuffle the array depending on the settings |
|
| 974 | + $answer_options_sorted = array(); |
|
| 975 | + $random_order = get_post_meta( $question_data['ID'], '_random_order', true ); |
|
| 976 | + if( $random_order && $random_order == 'yes' ) { |
|
| 993 | 977 | |
| 994 | - $answer_options_sorted[ $answer_id ] = $question_answers_options[ $answer_id ]; |
|
| 995 | - unset( $question_answers_options[ $answer_id ] ); |
|
| 978 | + $answer_options_sorted = $question_answers_options; |
|
| 979 | + shuffle( $answer_options_sorted ); |
|
| 996 | 980 | |
| 997 | - } |
|
| 981 | + } else { |
|
| 998 | 982 | |
| 999 | - } |
|
| 983 | + $answer_order = array(); |
|
| 984 | + $answer_order_string = get_post_meta( $question_data['ID'], '_answer_order', true ); |
|
| 985 | + if( $answer_order_string ) { |
|
| 1000 | 986 | |
| 1001 | - if( count( $question_answers_options ) > 0 ) { |
|
| 1002 | - foreach( $question_answers_options as $id => $answer ) { |
|
| 987 | + $answer_order = array_filter( explode( ',', $answer_order_string ) ); |
|
| 988 | + if( count( $answer_order ) > 0 ) { |
|
| 1003 | 989 | |
| 1004 | - $answer_options_sorted[ $id ] = $answer; |
|
| 990 | + foreach( $answer_order as $answer_id ) { |
|
| 1005 | 991 | |
| 1006 | - } |
|
| 1007 | - } |
|
| 992 | + if( isset( $question_answers_options[ $answer_id ] ) ) { |
|
| 1008 | 993 | |
| 1009 | - }else{ |
|
| 994 | + $answer_options_sorted[ $answer_id ] = $question_answers_options[ $answer_id ]; |
|
| 995 | + unset( $question_answers_options[ $answer_id ] ); |
|
| 1010 | 996 | |
| 1011 | - $answer_options_sorted = $question_answers_options; |
|
| 997 | + } |
|
| 1012 | 998 | |
| 1013 | - } |
|
| 999 | + } |
|
| 1014 | 1000 | |
| 1015 | - }else{ |
|
| 1001 | + if( count( $question_answers_options ) > 0 ) { |
|
| 1002 | + foreach( $question_answers_options as $id => $answer ) { |
|
| 1016 | 1003 | |
| 1017 | - $answer_options_sorted = $question_answers_options; |
|
| 1004 | + $answer_options_sorted[ $id ] = $answer; |
|
| 1018 | 1005 | |
| 1019 | - } // end if $answer_order_string |
|
| 1006 | + } |
|
| 1007 | + } |
|
| 1020 | 1008 | |
| 1021 | - } // end if random order |
|
| 1009 | + }else{ |
|
| 1022 | 1010 | |
| 1011 | + $answer_options_sorted = $question_answers_options; |
|
| 1023 | 1012 | |
| 1024 | - // assemble and setup the data for the templates data array |
|
| 1025 | - $question_data[ 'answer_options' ] = $answer_options_sorted; |
|
| 1013 | + } |
|
| 1026 | 1014 | |
| 1027 | - } |
|
| 1015 | + }else{ |
|
| 1028 | 1016 | |
| 1029 | - return $question_data; |
|
| 1017 | + $answer_options_sorted = $question_answers_options; |
|
| 1030 | 1018 | |
| 1031 | - }// end multiple_choice_load_question_data |
|
| 1019 | + } // end if $answer_order_string |
|
| 1032 | 1020 | |
| 1033 | - /** |
|
| 1034 | - * Load the gap fill question data on the sensei_get_question_template_data |
|
| 1035 | - * filter. |
|
| 1036 | - * |
|
| 1037 | - * @since 1.9.0 |
|
| 1038 | - * |
|
| 1039 | - * @param $question_data |
|
| 1040 | - * @param $question_id |
|
| 1041 | - * @param $quiz_id |
|
| 1042 | - * |
|
| 1043 | - * @return array() |
|
| 1044 | - */ |
|
| 1045 | - public static function gap_fill_load_question_data( $question_data, $question_id, $quiz_id ){ |
|
| 1021 | + } // end if random order |
|
| 1046 | 1022 | |
| 1047 | - if( 'gap-fill' == Sensei()->question->get_question_type( $question_id ) ) { |
|
| 1048 | 1023 | |
| 1049 | - $gapfill_array = explode( '||', $question_data[ 'question_right_answer' ] ); |
|
| 1050 | - $question_data[ 'gapfill_pre' ] = isset( $gapfill_array[0] ) ? $gapfill_array[0] : ''; |
|
| 1051 | - $question_data[ 'gapfill_gap' ] = isset( $gapfill_array[1] ) ? $gapfill_array[1] : ''; |
|
| 1052 | - $question_data[ 'gapfill_post' ] = isset( $gapfill_array[2] ) ? $gapfill_array[2] : ''; |
|
| 1024 | + // assemble and setup the data for the templates data array |
|
| 1025 | + $question_data[ 'answer_options' ] = $answer_options_sorted; |
|
| 1053 | 1026 | |
| 1054 | - } |
|
| 1027 | + } |
|
| 1055 | 1028 | |
| 1056 | - return $question_data; |
|
| 1029 | + return $question_data; |
|
| 1057 | 1030 | |
| 1058 | - }// end gap_fill_load_question_data |
|
| 1031 | + }// end multiple_choice_load_question_data |
|
| 1032 | + |
|
| 1033 | + /** |
|
| 1034 | + * Load the gap fill question data on the sensei_get_question_template_data |
|
| 1035 | + * filter. |
|
| 1036 | + * |
|
| 1037 | + * @since 1.9.0 |
|
| 1038 | + * |
|
| 1039 | + * @param $question_data |
|
| 1040 | + * @param $question_id |
|
| 1041 | + * @param $quiz_id |
|
| 1042 | + * |
|
| 1043 | + * @return array() |
|
| 1044 | + */ |
|
| 1045 | + public static function gap_fill_load_question_data( $question_data, $question_id, $quiz_id ){ |
|
| 1046 | + |
|
| 1047 | + if( 'gap-fill' == Sensei()->question->get_question_type( $question_id ) ) { |
|
| 1048 | + |
|
| 1049 | + $gapfill_array = explode( '||', $question_data[ 'question_right_answer' ] ); |
|
| 1050 | + $question_data[ 'gapfill_pre' ] = isset( $gapfill_array[0] ) ? $gapfill_array[0] : ''; |
|
| 1051 | + $question_data[ 'gapfill_gap' ] = isset( $gapfill_array[1] ) ? $gapfill_array[1] : ''; |
|
| 1052 | + $question_data[ 'gapfill_post' ] = isset( $gapfill_array[2] ) ? $gapfill_array[2] : ''; |
|
| 1053 | + |
|
| 1054 | + } |
|
| 1055 | + |
|
| 1056 | + return $question_data; |
|
| 1057 | + |
|
| 1058 | + }// end gap_fill_load_question_data |
|
| 1059 | 1059 | |
| 1060 | 1060 | |
| 1061 | - /** |
|
| 1062 | - * Get the correct answer for a question |
|
| 1063 | - * |
|
| 1064 | - * @param $question_id |
|
| 1065 | - * @return string $correct_answer or empty |
|
| 1066 | - */ |
|
| 1067 | - public static function get_correct_answer( $question_id ){ |
|
| 1061 | + /** |
|
| 1062 | + * Get the correct answer for a question |
|
| 1063 | + * |
|
| 1064 | + * @param $question_id |
|
| 1065 | + * @return string $correct_answer or empty |
|
| 1066 | + */ |
|
| 1067 | + public static function get_correct_answer( $question_id ){ |
|
| 1068 | 1068 | |
| 1069 | - $right_answer = get_post_meta( $question_id, '_question_right_answer', true ); |
|
| 1070 | - $type = Sensei()->question->get_question_type( $question_id ); |
|
| 1071 | - $type_name = __( 'Multiple Choice', 'woothemes-sensei' ); |
|
| 1072 | - $grade_type = 'manual-grade'; |
|
| 1069 | + $right_answer = get_post_meta( $question_id, '_question_right_answer', true ); |
|
| 1070 | + $type = Sensei()->question->get_question_type( $question_id ); |
|
| 1071 | + $type_name = __( 'Multiple Choice', 'woothemes-sensei' ); |
|
| 1072 | + $grade_type = 'manual-grade'; |
|
| 1073 | 1073 | |
| 1074 | - if ('boolean'== $type ) { |
|
| 1074 | + if ('boolean'== $type ) { |
|
| 1075 | 1075 | |
| 1076 | - $right_answer = ucfirst($right_answer); |
|
| 1076 | + $right_answer = ucfirst($right_answer); |
|
| 1077 | 1077 | |
| 1078 | - }elseif( 'multiple-choice' == $type ) { |
|
| 1078 | + }elseif( 'multiple-choice' == $type ) { |
|
| 1079 | 1079 | |
| 1080 | - $right_answer = (array) $right_answer; |
|
| 1081 | - $right_answer = implode( ', ', $right_answer ); |
|
| 1080 | + $right_answer = (array) $right_answer; |
|
| 1081 | + $right_answer = implode( ', ', $right_answer ); |
|
| 1082 | 1082 | |
| 1083 | - }elseif( 'gap-fill' == $type ) { |
|
| 1083 | + }elseif( 'gap-fill' == $type ) { |
|
| 1084 | 1084 | |
| 1085 | - $right_answer_array = explode( '||', $right_answer ); |
|
| 1086 | - if ( isset( $right_answer_array[0] ) ) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; } |
|
| 1087 | - if ( isset( $right_answer_array[1] ) ) { $gapfill_gap = $right_answer_array[1]; } else { $gapfill_gap = ''; } |
|
| 1088 | - if ( isset( $right_answer_array[2] ) ) { $gapfill_post = $right_answer_array[2]; } else { $gapfill_post = ''; } |
|
| 1085 | + $right_answer_array = explode( '||', $right_answer ); |
|
| 1086 | + if ( isset( $right_answer_array[0] ) ) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; } |
|
| 1087 | + if ( isset( $right_answer_array[1] ) ) { $gapfill_gap = $right_answer_array[1]; } else { $gapfill_gap = ''; } |
|
| 1088 | + if ( isset( $right_answer_array[2] ) ) { $gapfill_post = $right_answer_array[2]; } else { $gapfill_post = ''; } |
|
| 1089 | 1089 | |
| 1090 | - $right_answer = $gapfill_pre . ' <span class="highlight">' . $gapfill_gap . '</span> ' . $gapfill_post; |
|
| 1090 | + $right_answer = $gapfill_pre . ' <span class="highlight">' . $gapfill_gap . '</span> ' . $gapfill_post; |
|
| 1091 | 1091 | |
| 1092 | - }else{ |
|
| 1092 | + }else{ |
|
| 1093 | 1093 | |
| 1094 | - // for non auto gradable question types no answer should be returned. |
|
| 1095 | - $right_answer = ''; |
|
| 1094 | + // for non auto gradable question types no answer should be returned. |
|
| 1095 | + $right_answer = ''; |
|
| 1096 | 1096 | |
| 1097 | - } |
|
| 1097 | + } |
|
| 1098 | 1098 | |
| 1099 | - return $right_answer; |
|
| 1099 | + return $right_answer; |
|
| 1100 | 1100 | |
| 1101 | - } // get_correct_answer |
|
| 1101 | + } // get_correct_answer |
|
| 1102 | 1102 | |
| 1103 | 1103 | } // End Class |
| 1104 | 1104 | |