LLMS_Student::get_overall_grade( boolean $use_cache = true )

Retrieve the student’s overall grade


Description Description

Grade = sum of grades for all courses divided by number of enrolled courses if a course has no quizzes in it, it cannot be graded and is therefore excluded from the calculation.

Cached data is automatically cleared when a student completes a quiz.


Top ↑

Parameters Parameters

$use_cache

(boolean) (Optional) If false, calculates the grade, otherwise utilizes cached data (if available)

Default value: true


Top ↑

Return Return

(float|string) Grade as float or "N/A"


Top ↑

Source Source

File: includes/models/model.llms.student.php

739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
* @since    3.10.0
 * @version  3.10.0
 */
public function get_notification_subscription( $type, $trigger, $default = 'no' ) {
 
    $prefs = $this->get( 'notification_subscriptions' );
    if ( ! $prefs ) {
        $prefs = array();
    }
 
    if ( isset( $prefs[ $type ] ) && isset( $prefs[ $type ][ $trigger ] ) ) {
        return $prefs[ $type ][ $trigger ];
    }
 
    return $default;
 
}
 
/**
 * Retrieve the student's overall grade
 *
 * Grade = sum of grades for all courses divided by number of enrolled courses
 * if a course has no quizzes in it, it cannot be graded and is therefore excluded from the calculation.
 *
 * Cached data is automatically cleared when a student completes a quiz.
 *
 * @since 3.2.0
 *
 * @param boolean $use_cache If `false`, calculates the grade, otherwise utilizes cached data (if available)
 * @return float|string Grade as float or "N/A"
 */
public function get_overall_grade( $use_cache = true ) {
 
    $grade = null;
 
    // Attempt to pull from the cache first.
    if ( $use_cache ) {
 
        $grade = $this->get( $this->meta_prefix . 'overall_grade' );
 
        if ( is_numeric( $grade ) ) {
            $grade = floatval( $grade );
        }
    }
 
    // Cache disabled or no cached data available.
    if ( ! $use_cache || null === $grade || '' === $grade ) {
 
        $grades = array();
 
        // Get courses.
        $courses = $this->get_courses(
            array(
                'limit' => 9999,
            )
        );
 
        // Loop through courses.


Top ↑

Changelog Changelog

Changelog
Version Description
3.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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