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.
Parameters Parameters
- $use_cache
-
(boolean) (Optional) If
false, calculates the grade, otherwise utilizes cached data (if available)Default value: true
Return Return
(float|string) Grade as float or "N/A"
Source Source
File: includes/models/model.llms.student.php
* @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.
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.2.0 | Introduced. |