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
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(); // Get courses. $courses = $this->get_courses( array( 'limit' => 9999, ) ); // Loop through courses. foreach ( $courses['results'] as $course_id ) { array_push( $progresses, $this->get_progress( $course_id, 'course' ) ); } $count = count( $progresses ); if ( $count ) { $progress = round( array_sum( $progresses ) / $count, 2 ); } else { $progress = 0; } // Cache the grade. $this->set( 'overall_progress', $progress ); } return apply_filters( 'llms_student_get_overall_progress', $progress, $this ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.2.0 | Introduced. |