LLMS_Admin_Reporting_Tab_Quizzes

LLMS_Admin_Reporting_Tab_Quizzes


Source Source

File: includes/admin/reporting/tabs/class.llms.admin.reporting.tab.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class LLMS_Admin_Reporting_Tab_Quizzes {
 
    /**
     * Constructor
     *
     * @return   void
     * @since    3.16.0
     * @version  3.16.0
     */
    public function __construct() {
 
        add_action( 'llms_reporting_content_quizzes', array( $this, 'output' ) );
        add_action( 'llms_reporting_quiz_tab_breadcrumbs', array( $this, 'breadcrumbs' ) );
 
    }
 
    /**
     * Add breadcrumb links to the tab depending on current view
     *
     * @return   void
     * @since    3.16.0
     * @version  3.16.0
     */
    public function breadcrumbs() {
 
        $links = array();
 
        // Single quiz.
        if ( isset( $_GET['quiz_id'] ) ) {
            $quiz = llms_get_post( absint( $_GET['quiz_id'] ) );
            $links[ LLMS_Admin_Reporting::get_stab_url( 'overview' ) ] = $quiz->get( 'title' );
        }
 
        if ( isset( $_GET['attempt_id'] ) ) {
 
            $attempt = new LLMS_Quiz_Attempt( absint( $_GET['attempt_id'] ) );
            $links[ LLMS_Admin_Reporting::get_stab_url( 'attempts' ) ] = $attempt->get_title();
 
        }
 
        foreach ( $links as $url => $title ) {
 
            echo '<a href="' . esc_url( $url ) . '">' . $title . '</a>';
 
        }
 
    }
 
    /**
     * Output tab content
     *
     * @since 3.16.0
     * @since 3.35.0 Sanitize input data.
     * @since 5.9.0 Stop using deprecated `FILTER_SANITIZE_STRING`.
     *
     * @return void
     */
    public function output() {
 
        // Single quiz.
        if ( isset( $_GET['quiz_id'] ) ) {
 
            if ( ! current_user_can( 'edit_post', llms_filter_input( INPUT_GET, 'quiz_id', FILTER_SANITIZE_NUMBER_INT ) ) ) {
                wp_die( __( 'You do not have permission to access this content.', 'lifterlms' ) );
            }
 
            $tabs = apply_filters(
                'llms_reporting_tab_quiz_tabs',
                array(
                    'overview' => __( 'Overview', 'lifterlms' ),
                    'attempts' => __( 'Attempts', 'lifterlms' ),
                )
            );
 
            llms_get_template(
                'admin/reporting/tabs/quizzes/quiz.php',
                array(
                    'current_tab' => isset( $_GET['stab'] ) ? esc_attr( llms_filter_input_sanitize_string( INPUT_GET, 'stab' ) ) : 'overview',
                    'tabs'        => $tabs,
                    'quiz'        => llms_get_post( intval( $_GET['quiz_id'] ) ),
                )
            );
 
            // Quiz table.
        } else {
 
            $table = new LLMS_Table_Quizzes();
            $table->get_results();
            echo $table->get_table_html();
 
        }
 
    }
 
}

Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
3.35.0 Sanitize input data.
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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