/** * Assert that contest in the request actually exists in the DB * * @param Request $r */ public function assertContest(Request $r) { // Validate that data was written to DB by getting the contest by title $contest = new Contests(); $contest->setTitle($r["title"]); $contests = ContestsDAO::search($contest); $contest = $contests[0]; // Assert that we found our contest $this->assertNotNull($contest); $this->assertNotNull($contest->getContestId()); // Assert data was correctly saved $this->assertEquals($r["description"], $contest->getDescription()); $this->assertGreaterThanOrEqual($r["start_time"] - 1, Utils::GetPhpUnixTimestamp($contest->getStartTime())); $this->assertGreaterThanOrEqual($r["start_time"], Utils::GetPhpUnixTimestamp($contest->getStartTime()) + 1); $this->assertGreaterThanOrEqual($r["finish_time"] - 1, Utils::GetPhpUnixTimestamp($contest->getFinishTime())); $this->assertGreaterThanOrEqual($r["finish_time"], Utils::GetPhpUnixTimestamp($contest->getFinishTime()) + 1); $this->assertEquals($r["window_length"], $contest->getWindowLength()); $this->assertEquals($r["public"], $contest->getPublic()); $this->assertEquals($r["alias"], $contest->getAlias()); $this->assertEquals($r["points_decay_factor"], $contest->getPointsDecayFactor()); $this->assertEquals($r["partial_score"], $contest->getPartialScore()); $this->assertEquals($r["submissions_gap"], $contest->getSubmissionsGap()); $this->assertEquals($r["feedback"], $contest->getFeedback()); $this->assertEquals($r["penalty"], $contest->getPenalty()); $this->assertEquals($r["scoreboard"], $contest->getScoreboard()); $this->assertEquals($r["penalty_type"], $contest->penalty_type); $this->assertEquals($r["penalty_calc_policy"], $contest->getPenaltyCalcPolicy()); }
/** * Assert that contest in the request actually exists in the DB * * @param Request $r */ public function assertContest(Request $r) { // Validate that data was written to DB by getting the contest by title $contest = new Contests(); $contest->setTitle($r['title']); $contests = ContestsDAO::search($contest); $contest = $contests[0]; // Assert that we found our contest $this->assertNotNull($contest); $this->assertNotNull($contest->getContestId()); // Assert data was correctly saved $this->assertEquals($r['description'], $contest->getDescription()); $this->assertGreaterThanOrEqual($r['start_time'] - 1, Utils::GetPhpUnixTimestamp($contest->getStartTime())); $this->assertGreaterThanOrEqual($r['start_time'], Utils::GetPhpUnixTimestamp($contest->getStartTime()) + 1); $this->assertGreaterThanOrEqual($r['finish_time'] - 1, Utils::GetPhpUnixTimestamp($contest->getFinishTime())); $this->assertGreaterThanOrEqual($r['finish_time'], Utils::GetPhpUnixTimestamp($contest->getFinishTime()) + 1); $this->assertEquals($r['window_length'], $contest->getWindowLength()); $this->assertEquals($r['public'], $contest->getPublic()); $this->assertEquals($r['alias'], $contest->getAlias()); $this->assertEquals($r['points_decay_factor'], $contest->getPointsDecayFactor()); $this->assertEquals($r['partial_score'], $contest->getPartialScore()); $this->assertEquals($r['submissions_gap'], $contest->getSubmissionsGap()); $this->assertEquals($r['feedback'], $contest->getFeedback()); $this->assertEquals($r['penalty'], $contest->getPenalty()); $this->assertEquals($r['scoreboard'], $contest->getScoreboard()); $this->assertEquals($r['penalty_type'], $contest->penalty_type); $this->assertEquals($r['penalty_calc_policy'], $contest->getPenaltyCalcPolicy()); $this->assertEquals($r['recommended'], $contest->getRecommended()); }
/** * Get list of contests where the user has admin priviledges * * @param Request $r * @return string * @throws InvalidDatabaseOperationException */ public static function apiContests(Request $r) { self::authenticateRequest($r); $response = array(); $response['contests'] = array(); try { $contest_director_key = new Contests(array('director_id' => $r['current_user_id'])); $contests_director = ContestsDAO::search($contest_director_key); foreach ($contests_director as $contest) { $response['contests'][] = $contest->asArray(); } $contest_admin_key = new UserRoles(array('user_id' => $r['current_user_id'], 'role_id' => CONTEST_ADMIN_ROLE)); $contests_admin = UserRolesDAO::search($contest_admin_key); foreach ($contests_admin as $contest_key) { $contest = ContestsDAO::getByPK($contest_key->getContestId()); if (is_null($contest)) { self::$log->error("UserRoles has a invalid contest: {$contest->getContestId()}"); continue; } $response['contests'][] = $contest->asArray(); } usort($response['contests'], function ($a, $b) { return $a['contest_id'] > $b['contest_id'] ? -1 : 1; }); } catch (Exception $e) { throw new InvalidDatabaseOperationException($e); } $response['status'] = 'ok'; return $response; }
* to continue. This is by design, in order to prevent * leaving open holes for new pages. * * */ define("LEVEL_NEEDED", false); require_once "../../server/inc/bootstrap.php"; require_once "api/ShowProblemInContest.php"; require_once "api/OmiReport.php"; $page = new OmegaupAdminTabPage(); $page->addComponent(new TitleComponent("Concurso " . $_GET["alias"] . "")); if (!isset($_GET["alias"])) { $page->addComponent(new TitleComponent("Este concurso no existe", 2)); $page->render(); exit; } $this_contests = ContestsDAO::search(new Contests(array("alias" => $_GET["alias"]))); if (count($this_contests) == 0) { $page->addComponent(new TitleComponent("Este concurso no existe", 2)); $page->render(); exit; } $this_contest = $this_contests[0]; if (is_null($this_contest)) { $page->addComponent(new TitleComponent("Este concurso no existe", 2)); $page->render(); exit; } $page->nextTab("Detalles"); //$page->addComponent( "<a href='../arena/{$_GET['alias']}/'>Ir al concurso</a>" ); RequestContext::set('contest_alias', $_GET['alias']); $omiReport = new OmiReport();