LLMS_Quiz_Data::get_average_grade( string $period = 'current' )

Retrieve avg grade of quiz attempts within the period


Parameters Parameters

$period

(string) (Optional) date period [current|previous]

Default value: 'current'


Top ↑

Return Return

(int)


Top ↑

Source Source

File: includes/class.llms.quiz.data.php

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
public function get_average_grade( $period = 'current' ) {
 
    global $wpdb;
 
    $grade = $wpdb->get_var(
        $wpdb->prepare(
            "
        SELECT ROUND( AVG( grade ), 3 )
        FROM {$wpdb->prefix}lifterlms_quiz_attempts
        WHERE quiz_id = %d
          AND update_date BETWEEN %s AND %s
        ",
            $this->post_id,
            $this->get_date( $period, 'start' ),
            $this->get_date( $period, 'end' )
        )
    );
 
    return $grade ? $grade : 0;
 
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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