LLMS_Controller_Quizzes::take_quiz()
Handle form submission of the “take quiz” button attached to lessons with quizzes
Description Description
Return Return
(void)
Source Source
File: includes/controllers/class.llms.controller.quizzes.php
public function take_quiz() { // invalid nonce or the form wasn't submitted if ( ! llms_verify_nonce( '_llms_take_quiz_nonce', 'take_quiz', 'POST' ) ) { return; } // check required fields if ( ! isset( $_POST['quiz_id'] ) || ! isset( $_POST['associated_lesson'] ) ) { return llms_add_notice( __( 'Could not proceed to the quiz because required information was missing.', 'lifterlms' ), 'error' ); } $quiz = absint( $_POST['quiz_id'] ); $lesson = absint( $_POST['associated_lesson'] ); try { $attempt = LLMS_Quiz_Attempt::init( $quiz, $lesson, get_current_user_id() )->save(); } catch ( Exception $exception ) { return llms_add_notice( $exception->getMessage(), 'error' ); } //redirect user to quiz page $redirect = add_query_arg( array( 'attempt_key' => $attempt->get_key(), ), get_permalink( $quiz ) ); wp_redirect( apply_filters( 'lifterlms_lesson_start_quiz_redirect', $redirect ) ); exit; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: