示例#1
0
 public function getHtmlView($data, \Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Bad command');
     }
     $command = $request->getVar('command');
     switch ($command) {
         case 'pickup':
             $content = Factory::pickup(GameFactory::getCurrentId());
             break;
         case 'winners':
             $content = Factory::winners(GameFactory::getCurrentId());
             break;
         case 'spotReport':
             $content = Factory::spotReport(GameFactory::getCurrentId());
             break;
         default:
             throw new \Exception('Unknown report command');
     }
     $view = new \View\HtmlView($content);
     return $view;
 }
示例#2
0
 public static function assignStudent($student_id, $spot_id)
 {
     $game_id = Game::getCurrentId();
     $lot_id = Spot::getLotIdFromId($spot_id);
     self::removeUnclaimedSpot($spot_id);
     $lottery = self::getLotteryByStudentId($student_id);
     if (!$lottery) {
         $lottery = new Resource();
         $lottery->setGameId($game_id);
         $lottery->setStudentId($student_id);
     }
     $lottery->setLotId($lot_id);
     $lottery->setSpotId($spot_id);
     $lottery->setPickedUp(true);
     $lottery->setWinner(true);
     self::saveResource($lottery);
     return true;
 }
示例#3
0
 /**
  * Number of student submissions to this lottery
  * @return integer
  */
 private function getTotalSubmissions()
 {
     $factory = new Factory();
     $current_game = \tailgate\Factory\Game::getCurrentId();
     if (empty($current_game)) {
         $submissions = 0;
     } else {
         $submissions = $factory->getTotalSubmissions($current_game);
     }
     return (int) $submissions;
 }
示例#4
0
 public static function spotPickedUp($spot_id)
 {
     $game_id = \tailgate\Factory\Game::getCurrentId();
     $db = \Database::getDB();
     $tbl = $db->addTable('tg_lottery');
     $tbl->addFieldConditional('game_id', $game_id);
     $tbl->addFieldConditional('spot_id', $spot_id);
     $tbl->addFieldConditional('picked_up', 1);
     $result = $db->selectOneRow();
     return (bool) $result;
 }
示例#5
0
 public function ban($student_id, $reason)
 {
     $student = new Resource();
     self::loadByID($student, $student_id);
     $student->setBanned(true);
     $student->setBannedReason(filter_var($reason, FILTER_SANITIZE_STRING));
     $student->setIneligibleReason('Banned');
     $student->stampBanned();
     $student->setEligible(false);
     self::saveResource($student);
     Lottery::removeStudentWin($student_id, Game::getCurrentId());
 }