LLMS_AJAX_Handler::quiz_end( array $request, LLMS_Quiz_Attempt|null $attempt = null )
End a quiz attempt
Parameters Parameters
- $request
-
(array) (Required) $_POST data.
- $attempt
-
(LLMS_Quiz_Attempt|null) (Optional) The quiz attempt. Default
null
.Default value: null
Return Return
(array)
Source Source
File: includes/class.llms.ajax.handler.php
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 | * @param LLMS_Quiz_Attempt|null $attempt The quiz attempt. * @ return array */ public static function quiz_end( $request , $attempt = null ) { $err = new WP_Error(); if ( ! $attempt ) { $student = llms_get_student(); if ( ! $student ) { $err ->add( 400, __( 'You must be logged in to take quizzes.' , 'lifterlms' ) ); return $err ; } if ( ! isset( $request [ 'attempt_key' ] ) ) { $err ->add( 400, __( 'Missing required parameters. Could not proceed.' , 'lifterlms' ) ); return $err ; } $attempt = $student ->quizzes()->get_attempt_by_key( sanitize_text_field( $request [ 'attempt_key' ] ) ); } // Record the attempt's completion. $attempt -> end (); // Setup a redirect. $url = add_query_arg( array ( 'attempt_key' => $attempt ->get_key(), ), get_permalink( $attempt ->get( 'quiz_id' ) ) ); return array ( /** * Filter the quiz redirect URL on completion. * * @since Unknown * * @param string $url The quiz redirect URL on completion. * @param LLMS_Quiz_Attempt $attempt The quiz attempt. */ 'redirect' => apply_filters( 'llms_quiz_complete_redirect' , $url , $attempt ), ); } /** * Remove a coupon from an order during checkout * * @since 3.0.0 |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.9.0 | |
3.16.0 | Introduced. |