Exemplo n.º 1
0
 public static function createFromRequest(SubmitSolutionRequest $request, Problem $problem, Contest $contest = null)
 {
     assert(Auth::check());
     assert($request->isFileFieldOK('source'));
     $source = $request->popSourceInfo();
     $verdict = $problem->getSubmissionVerdict($source['content'], $source['ext']);
     $data = ['user_id' => Auth::user()->id, 'contest_id' => !is_null($contest) ? $contest->id : null, 'problem_id' => $problem->id, 'source' => $source['content'], 'source_kind' => $source['ext'], 'verdict' => $verdict];
     return Submission::create($data);
 }
Exemplo n.º 2
0
 public function submit($problem_id, Requests\SubmitSolutionRequest $request)
 {
     if (!$request->isFileFieldOK('source')) {
         abort(409, 'No se completó el envío del archivo al servidor.');
     }
     $problem = Problem::findOrFail($problem_id);
     Submission::createFromRequest($request, $problem);
     return redirect(action('UsersController@submissions', Auth::user()->id));
 }