public function testWithinGpAsgAvailable($asg) { $withinTime = function ($asg) { $currentTime = new \DateTime(); $startTime = new \DateTime($asg->start_date); $endTime = new \DateTime($asg->end_date); return $currentTime >= $startTime && $currentTime < $endTime; }; $finished = function ($asg) { $answeredAsgs = WithinGpAsgAns::where("asg_id", $asg->id)->where("user_id", $this->currentUser->id)->take(1)->get(); return count($answeredAsgs) > 0; }; return $withinTime($asg) && !$finished($asg); }
public function getStudentAnswers($asgId) { $withinGpAsgsController = new WithinGpAsgsController(); $result = array(); $studentAnswers = WithinGpAsgAns::where("asg_id", $asgId)->get(); foreach ($studentAnswers as $answer) { if (!array_key_exists($answer->target_user_id, $result)) { $result[$answer->target_user_id] = array(); } if (!array_key_exists($answer->user_id, $result[$answer->target_user_id])) { $result[$answer->target_user_id][$answer->user_id] = array(); } array_push($result[$answer->target_user_id][$answer->user_id], $answer); } return $result; }