Пример #1
0
 /**
  * Creates a run
  *
  * @param type $problemData
  * @param type $contestData
  * @param Users $contestant
  * @return array
  */
 public static function createRun($problemData, $contestData, $contestant)
 {
     // Our contestant has to open the contest before sending a run
     ContestsFactory::openContest($contestData, $contestant);
     // Then we need to open the problem
     ContestsFactory::openProblemInContest($contestData, $problemData, $contestant);
     $r = self::createRequestCommon($problemData, $contestData, $contestant);
     // Call API
     RunController::$grader = new GraderMock();
     $response = RunController::apiCreate($r);
     // Clean up
     unset($_REQUEST);
     return array('request' => $r, 'contestant' => $contestant, 'response' => $response);
 }
Пример #2
0
 /**
  * Creates a clarification in a problem inside a contest
  * 
  * @param type $problemData
  * @param type $contestData
  * @param type $contestant
  */
 public static function createClarification($problemData, $contestData, $contestant)
 {
     // Our contestant has to open the contest before sending a clarification
     ContestsFactory::openContest($contestData, $contestant);
     // Then we need to open the problem
     ContestsFactory::openProblemInContest($contestData, $problemData, $contestant);
     // Create the request for our api
     $r = new Request();
     $r["message"] = Utils::CreateRandomString();
     $r["contest_alias"] = $contestData["request"]["alias"];
     $r["problem_alias"] = $problemData["request"]["alias"];
     $r["public"] = '0';
     // Log in our user and set the auth_token properly
     $r["auth_token"] = OmegaupTestCase::login($contestant);
     // Call the API
     $response = ClarificationController::apiCreate($r);
     // Clean up stuff
     unset($_REQUEST);
     return array("request" => $r, "response" => $response);
 }
Пример #3
0
 /**
  * Languages must be validated against the problem's allowed languages.
  *
  * @expectedException InvalidParameterException
  */
 public function testRunInvalidContestLanguage()
 {
     $problemData = ProblemsFactory::createProblem();
     // Get a contest
     $contestData = ContestsFactory::createContest(null, 1, null, 'cpp');
     // Add the problem to the contest
     ContestsFactory::addProblemToContest($problemData, $contestData);
     // Create our contestant
     $contestant = UserFactory::createUser();
     // Our contestant has to open the contest before sending a run
     ContestsFactory::openContest($contestData, $contestant);
     // Then we need to open the problem
     ContestsFactory::openProblemInContest($contestData, $problemData, $contestant);
     // Create an empty request
     $r = new Request();
     // Log in as contest director
     $r["auth_token"] = $this->login($contestant);
     // Build request
     $r["contest_alias"] = $contestData["request"]["alias"];
     $r["problem_alias"] = $problemData["request"]["alias"];
     $r["language"] = "c";
     $r["source"] = "#include <stdio.h>\nint main() { printf(\"3\"); return 0; }";
     //PHPUnit does not set IP address, doing it manually
     $_SERVER["REMOTE_ADDR"] = "127.0.0.1";
     // Call API
     $response = RunController::apiCreate($r);
 }
Пример #4
0
 /**
  * Languages must be validated against the problem's allowed languages.
  *
  * @expectedException InvalidParameterException
  */
 public function testRunInvalidContestLanguage()
 {
     $problemData = ProblemsFactory::createProblem();
     // Get a contest
     $contestData = ContestsFactory::createContest(null, 1, null, 'cpp');
     // Add the problem to the contest
     ContestsFactory::addProblemToContest($problemData, $contestData);
     // Create our contestant
     $contestant = UserFactory::createUser();
     // Our contestant has to open the contest before sending a run
     ContestsFactory::openContest($contestData, $contestant);
     // Then we need to open the problem
     ContestsFactory::openProblemInContest($contestData, $problemData, $contestant);
     // Create an empty request
     $r = new Request();
     // Log in as contest director
     $r['auth_token'] = $this->login($contestant);
     // Build request
     $r['contest_alias'] = $contestData['request']['alias'];
     $r['problem_alias'] = $problemData['request']['alias'];
     $r['language'] = 'c';
     $r['source'] = "#include <stdio.h>\nint main() { printf(\"3\"); return 0; }";
     // Call API
     $response = RunController::apiCreate($r);
 }