/** * 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()); }
protected function renderContent() { $this->render('currentContestsWidget', array('contests' => Contests::model()->findAll(array('order' => 'start_date DESC', 'condition' => "status = 'active'")))); }
/** * Enforces rules to avoid having invalid/unactionable public contests * * @param Contests $contest */ private static function validateContestCanBePublic(Contests $contest) { // Check that contest has some problems at least 1 problem $problemsInContest = ContestProblemsDAO::GetRelevantProblems($contest->getContestId()); if (count($problemsInContest) < 1) { throw new InvalidParameterException("contestPublicRequiresProblem"); } }
/** * Получение последних конкурсов * @param $param * @param $smarty */ function smarty_function_getContest($param, &$smarty) { // Глобальные переменные global $current_lang, $__lang; // Подключаем класс публикаций require_once DOC . 'modules/contests/class.contests.php'; // Объекст класса для работы с деревьями $base = new SimpleTable(DOC, $current_lang, PREF); $data = array(); if (class_exists('Contests')) { $object = new Contests($base, $__lang); // Переменная, в которую все вернется. $assign = getParam($param, 'assign', 'data', 'assign'); // Лимит записей. $limit = getParam($param, 'limit', 10); $data = $object->getAllRows('contests', 'date_start', 'DESC', 1, $limit, 1); // Вывод в шаблон. $smarty->assign($assign, $data); } }