Beispiel #1
0
 public function addEnvio(Request $request)
 {
     $codigo = $request->file('codigo');
     $random = rand(1, 100000);
     $codigo->move('files/codigos', $random . $codigo->getClientOriginalName());
     $idProblema = $request->input('id_problema');
     $problema = Problem::find($idProblema);
     $nombrePrograma = $random . $codigo->getClientOriginalName();
     $lenguaje = $request->input('lenguaje');
     if ($lenguaje == 2) {
         //c++
         $suite_path = '/Users/alejandro/Sites/moj';
         $outans_path = $suite_path . '/public/files/' . $problema->out;
         $judge_path = $suite_path . '/judge/';
         $userProblemPath = $suite_path . '/public/files/codigos/' . $nombrePrograma;
         shell_exec('cp ' . $outans_path . ' ' . $judge_path . 'ans.out');
         shell_exec('cp ' . $userProblemPath . ' ' . $judge_path . 'user.cpp');
         $respuesta = shell_exec('python ' . $judge_path . 'script.py');
     } else {
         if ($lenguaje == 1) {
             // c
             $suite_path = '/Users/alejandro/Sites/moj';
             $outans_path = $suite_path . '/public/files/' . $problema->out;
             $judge_path = $suite_path . '/judge/';
             $userProblemPath = $suite_path . '/public/files/codigos/' . $nombrePrograma;
             shell_exec('cp ' . $outans_path . ' ' . $judge_path . 'ans.out');
             shell_exec('cp ' . $userProblemPath . ' ' . $judge_path . 'user.cpp');
             $respuesta = shell_exec('python ' . $judge_path . 'scriptc.py');
         } else {
             $respuesta = 10;
         }
     }
     $envio = new Envios(array('id_usuario' => Auth::user()->id, 'id_concurso' => $request->input('id_concurso'), 'estado' => 1, 'veredicto' => intval($respuesta), 'id_juez' => -1, 'codigo' => $nombrePrograma, 'id_problema' => $idProblema, 'lenguaje' => $request->input('lenguaje')));
     $envio->save();
     return redirect('/contest/envios/' . $request->input('id_concurso'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $issubmit = false;
     $isac = false;
     if (Auth::check()) {
         $user_id = Auth::user()->user_id;
         $issubmit = DB::table('solution')->where('problem_id', $id)->where('user_id', $user_id)->count() > 0;
         $isac = DB::table('solution')->where('problem_id', $id)->where('user_id', $user_id)->where('result', 4)->count() > 0;
         if ($isac) {
             $issubmit = false;
         }
     }
     return view('problems.show')->with(["data" => Problem::find($id), "accepted" => $isac, "submited" => $issubmit, "extendsJS" => true]);
 }
 public function p($id)
 {
     return view('contests.contest.pshow')->with(["data" => Problem::find($id), "contest" => Contest::find(session('cid')), "extendsJS" => true]);
 }
Beispiel #4
0
 public function deleteProblem(Request $request)
 {
     $problema = Problem::find($request->input('id'));
     $problema->delete();
     return redirect('admin/problem');
 }