Beispiel #1
0
 public function testGpAsgAvailable($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 = GpAsgAnsRank::where("asg_id", $asg->id)->where("user_id", $this->currentUser->id)->take(1)->get();
         return count($answeredAsgs) > 0;
     };
     return $withinTime($asg) && !$finished($asg);
 }
Beispiel #2
0
 public function removeGp($gpId)
 {
     $gp = Group::find($gpId);
     if ($gp != null) {
         if (count($gp->members) <= 0) {
             if (count(GpAsgAnsRank::where('gp_id', $gpId)->get()) <= 0) {
                 $gp->delete();
                 return 0;
             }
             return -3;
             //some members have already ranked the group
         } else {
             return -2;
         }
         //has members in group
     }
     return -1;
     //there is no such group
 }
Beispiel #3
0
 public function getAnswersGroupByUser($asgId)
 {
     return GpAsgAnsRank::where("asg_id", $asgId)->get()->groupBy("user_id");
 }