/** * @param $studentId * @param $eventTypeId * @param $eventType * @param $eventGender * @return array|null */ private function getAthleteEventRecords($studentId, $eventTypeId, $eventType, $eventGender) { $schoolRecord = $this->TrackSQL->getTopEventRecords($eventTypeId, $eventGender, 1); $records = $this->TrackSQL->getStudentEventRecords($studentId, $eventTypeId); $pr = null; $prKey = 0; if (!is_array($records)) { return array(); } foreach ($records as $key => &$record) { $result = $eventType === 'track' ? $record['resultInSeconds'] : $record['resultInInches']; $record['isPersonalRecord'] = false; $record['isSchoolRecord'] = $this->isSchoolRecord($eventType, $schoolRecord[0], $result); if ($this->isNewPersonalRecord($eventType, $pr, $result)) { $pr = $result; $prKey = $key; } $ResultTime = $eventType === 'track' ? new ResultTime($record['resultInSeconds']) : new ResultMeasurement($record['resultInInches']); $record['result'] = $ResultTime->getResult(); } $records[$prKey]['isPersonalRecord'] = true; return $records; }