diff --git a/main/inc/lib/GamificationUtils.php b/main/inc/lib/GamificationUtils.php new file mode 100644 index 0000000000..f13fb57274 --- /dev/null +++ b/main/inc/lib/GamificationUtils.php @@ -0,0 +1,40 @@ + + */ +class GamificationUtils +{ + + /** + * Get the calculated points on session with gamification mode + * @param int $userId The user ID + * @param int $userStatus The user Status + * @return int + */ + public static function getTotalUserPoints($userId, $userStatus) + { + $points = 0; + + $sessions = SessionManager::getSessionsFollowedByUser( + $userId, + $userStatus + ); + + if (empty($sessions)) { + return 0; + } + + foreach ($sessions as $session) { + $points += SessionManager::getPointsFromGamification( + $session['id'] + ); + } + + return $points; + } + +}