From 08e15a94dd249e8a4903a9efee708312e5dfd45b Mon Sep 17 00:00:00 2001 From: Antonio Carlos Mariani Date: Tue, 10 May 2016 14:47:17 -0300 Subject: [PATCH] Adding function get_user_taken_sessions_percentages to summary class --- classes/summary.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 *