private function matchSubmissionsAndUsers($users, $scores) { $allStudents = array(); $standards = $this->roots->getGradingStandards(); $grading_scheme = $standards[0]->grading_scheme; //get experience total points $instance = ExperienceModel::find($this->property('experienceInstance')); $maxExperiencePts = $instance->total_points; foreach ($users as $user) { $submissionsArr = $this->findScoreByUserId($user->id, $scores); //this will weed out any TA's and other people in the course who aren't necessarily students try { $bonusPenalties = $this->getBonusPenalties($user->id); } catch (\GuzzleHttp\Exception\ClientException $e) { continue; } $bonus = $bonusPenalties->bonus; $penalty = $bonusPenalties->penalties; $totalPoints = 0; $userObj = new \stdClass(); $userObj->name = $user->name; $userObj->id = $user->login_id; //add link to user profile if (!isset($_SESSION)) { session_start(); } $domain = $_SESSION['domain']; $courseId = $_SESSION['courseID']; $userObj->profile_url = "https://{$domain}/courses/{$courseId}/users/{$user->id}"; $userObj->bonuses = round($bonus, 2); $userObj->penalties = round($penalty, 2); $userObj->totalBP = round(round($bonus, 2) + round($penalty, 2), 2); if (count($submissionsArr) >= 1) { $score = $submissionsArr[0]; $userObj->score = round($score->score, 2); $totalPoints = $score->score + $bonus + $penalty; $userObj->total = round($totalPoints, 2); } else { //no scores found for user $userObj->score = 0; $totalPoints = $bonus + $penalty; $userObj->total = round($totalPoints, 2); } //get letter grade $grade = new GradeComponent(); $userObj->grade = $grade->getLetterGrade($totalPoints, $maxExperiencePts, $grading_scheme); $allStudents[] = $userObj; } return $allStudents; }
public function matchSubmissionsAndUsers($users, $scores) { $allStudents = array(); $standards = $this->roots->getGradingStandards(); $grading_scheme = $standards[0]->grading_scheme; //get experience total points $experienceInstance = ExperienceModel::find($this->property('experienceInstance')); $maxExperiencePts = $experienceInstance->total_points; $utcTimeZone = new DateTimeZone('UTC'); $stDate = $experienceInstance->start_date->setTimezone($utcTimeZone); $endDate = $experienceInstance->end_date->setTimezone($utcTimeZone); $expComponent = new ExperienceComponent(); $ptsPerSecond = $expComponent->getPtsPerSecond($stDate, $endDate, $experienceInstance->total_points); $bonusPerSecond = $experienceInstance->bonus_per_day / 24 / 60 / 60; $bonusSeconds = $experienceInstance->bonus_days * 24 * 60 * 60; $penaltyPerSecond = $experienceInstance->penalty_per_day / 24 / 60 / 60; $penaltySeconds = $experienceInstance->penalty_days * 24 * 60 * 60; foreach ($users as $user) { $submissionsArr = $this->findScoreByUserId($user->user_id, $scores); //this will weed out any TA's and other people in the course who aren't necessarily students try { $userSubmissions = $expComponent->getSubmissions($user->user_id); $bonusPenalties = $this->getBonusPenaltiesNew($this->property('experienceInstance'), $userSubmissions, $ptsPerSecond, $stDate, $bonusPerSecond, $bonusSeconds, $penaltyPerSecond, $penaltySeconds); // $bonusPenalties = $this->getBonusPenalties($user->user_id); } catch (\GuzzleHttp\Exception\ClientException $e) { continue; } $bonus = $bonusPenalties->bonus; $penalty = $bonusPenalties->penalties; $totalPoints = 0; $userObj = new \stdClass(); $userObj->name = $user->user->name; $userObj->id = $user->user_id; //add link to user profile if (!isset($_SESSION)) { session_start(); } $domain = $_SESSION['domain']; $courseId = $_SESSION['courseID']; $userObj->profile_url = "https://{$domain}/courses/{$courseId}/users/{$user->id}"; $userObj->bonuses = $bonus; $userObj->penalties = $penalty; $userObj->totalBP = $bonus - $penalty; if (count($submissionsArr) >= 1) { $score = $submissionsArr[0]; if (isset($score->score)) { $userObj->score = $score->score; $totalPoints = $score->score + $bonus + $penalty; $userObj->total = $totalPoints; } else { $userObj->score = 0; $totalPoints = $bonus + $penalty; $userObj->total = $totalPoints; } } else { //no scores found for user $userObj->score = 0; $totalPoints = $bonus + $penalty; $userObj->total = $totalPoints; } //get letter grade $grade = new GradeComponent(); $userObj->grade = $grade->getLetterGrade($totalPoints, $maxExperiencePts, $grading_scheme); $allStudents[] = $userObj; } return $allStudents; }