LLMS_Student::get_overall_progress( boolean $use_cache = true )
Retrieve a student’s overall progress Overall progress is the total percentage completed based on all courses the student is enrolled in Cached data is cleared every time the student completes a lesson
Parameters Parameters
- $use_cache
-
(boolean) (Optional) if false, calculates the progress, otherwise utilizes cached data (if available)
Default value: true
Return Return
(float)
Source Source
File: includes/models/model.llms.student.php
// If we have at least one grade.
$count = count( $grades );
if ( $count ) {
$grade = round( array_sum( $grades ) / $count, 2 );
} else {
$grade = _x( 'N/A', 'overall grade when no quizzes', 'lifterlms' );
}
// Cache the grade.
$this->set( 'overall_grade', $grade );
}
return apply_filters( 'llms_student_get_overall_grade', $grade, $this );
}
/**
* Retrieve a student's overall progress
* Overall progress is the total percentage completed based on all courses the student is enrolled in
* Cached data is cleared every time the student completes a lesson
*
* @param boolean $use_cache if false, calculates the progress, otherwise utilizes cached data (if available)
* @return float
* @since 3.2.0
* @version 3.2.0
*/
public function get_overall_progress( $use_cache = true ) {
$progress = null;
// Attempt to pull from the cache first.
if ( $use_cache ) {
$progress = $this->get( $this->meta_prefix . 'overall_progress' );
if ( is_numeric( $progress ) ) {
$progress = floatval( $progress );
}
}
// Cache disabled or no cached data available.
if ( ! $use_cache || null === $progress || '' === $progress ) {
$progresses = array();
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.2.0 | Introduced. |