diff --git a/classes/summary.php b/classes/summary.php index 917b786..d83bfb8 100644 --- a/classes/summary.php +++ b/classes/summary.php @@ -22,6 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +include_once($CFG->dirroot . '/mod/attendance/locallib.php'); + class mod_attendance_summary { /** @var int attendance instance identifier */ @@ -82,6 +84,21 @@ class mod_attendance_summary { return $this->groupmode; } + /** + * Returns the percentages of each user related to the taken sessions + * + * @return array + */ + public function get_user_taken_sessions_percentages() { + $percentages = array(); + + foreach ($this->userspoints as $userid => $userpoints) { + $percentages[$userid] = attendance_calc_fraction($userpoints->points, $userpoints->maxpoints); + } + + return $percentages; + } + /** * Returns a summary of the points assigned to the user related to the taken sessions *