LLMS_Controller_Quizzes

Quiz related form controller


Source Source

File: includes/controllers/class.llms.controller.quizzes.php

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class LLMS_Controller_Quizzes {
 
    /**
     * Constructor
     *
     * @since 3.9.0
     * @since 3.37.8 Add reporting actions handler action.
     * @since 4.14.0 Remove `add_action()` for deprecated `take_quiz()` method.
     *
     * @return void
     */
    public function __construct() {
 
        add_action( 'admin_init', array( $this, 'maybe_handle_reporting_actions' ) );
 
    }
 
    /**
     * Handle quiz reporting screen actions buttons
     *
     * On the quiz reporting screen this allows orphaned quizzes to be deleted.
     *
     * @since 3.37.8
     * @since 5.1.0 Use a deep orphan check to determine if the quiz can be deleted.
     *
     * @return null|false|WP_Post `null` if the form wasn't submitted or the nonce couldn't be verified.
     *                            `false` if an error was encountered.
     *                            `WP_Post` of the deleted quiz on success.
     */
    public function maybe_handle_reporting_actions() {
 
        if ( ! llms_verify_nonce( '_llms_quiz_actions_nonce', 'llms-quiz-actions' ) ) {
            return null;
        }
 
        $id = llms_filter_input( INPUT_POST, 'llms_del_quiz', FILTER_SANITIZE_NUMBER_INT );
        if ( $id && 'llms_quiz' === get_post_type( $id ) ) {
            $quiz = llms_get_post( $id );
            if ( $quiz && ( $quiz->is_orphan( true ) || ! $quiz->get_course() ) ) {
                return wp_delete_post( $id, true );
            }
        }
 
        return false;
 
    }
 
}

Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Removed previously deprecated method LLMS_Controller_Quizzes::take_quiz().
3.9.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.