public function testNuevaEjecucion() { // Crear un usuario e iniciar sesion $nick = "p" . time(); $uarg = array("nombre" => "problem tester", "email" => $nick . "@example.net", "password" => "foobar23123", "nick" => $nick, "user" => $nick, "ubicacion" => "celaya"); $result = c_usuario::nuevo($uarg); $result = c_sesion::login($uarg); // Crear un nuevo problema $contents = $titulo = "prob" . time(); for ($i = 0; $i < 100; $i++) { $contents .= "lorem ipsum"; } $arg = array("titulo" => $titulo, "problema" => $contents, "tiempoLimite" => 3456, "entrada" => "1 1\n1 2\n100 100\n", "salida" => "2\n3\n200\n"); $result = c_problema::nuevo($arg); // Crear un nuevo envio $arg = array("id_problema" => $result["probID"], "lang" => "java", "plain_source" => "import java.io.*;\n\t\t\t\t\tclass Main{ public static void main(String []a) throws Exception{\n\t\t\t\t\tBufferedReader br = new BufferedReader(new FileReader(\"data.in\"));\n\t\t\t\t\tPrintWriter pw = new PrintWriter((\"data.out\"));\n\t\t\t\t\tString s;\n\t\t\t\t\twhile((s=br.readLine()) != null){\n\t\t\t\t\t\t\tpw.println(Integer.parseInt(s.split(\" \")[0]) + Integer.parseInt(s.split(\" \")[1]) );\n\t\t\t\t\t}\n\t\t\t\t\tpw.flush(); pw.close();\n\t\t\t\t\t} }"); $result = c_ejecucion::nuevo($arg); //Revisar el estado del run hasta que no sea waiting... $detalles = c_ejecucion::details($result); $retry = 0; while ($retry < 5 && ($detalles["run"]["status"] == "WAITING" || $detalles["run"]["status"] == "JUDGING")) { $retry++; sleep(1); $detalles = c_ejecucion::details($result); } $this->assertEquals($detalles["run"]["status"], "OK"); }
public function testNuevoProblemaCorrecto() { $titulo = "a" . time(); $rlistaprobs = array("public" => "NO"); $res = c_problema::lista($rlistaprobs); $probs = $res["problemas"]; $found = false; for ($i = 0; $i < sizeof($probs); $i++) { if ($probs[$i]["titulo"] == $titulo) { $found = true; break; } } $this->assertTrue(!$found); $contents = ""; for ($i = 0; $i < 100; $i++) { $contents .= "a"; } $arg = array("titulo" => $titulo, "problema" => $contents, "tiempoLimite" => 3456, "entrada" => "1 1\n1 2\n100 100\n", "salida" => "2\n3\n200\n"); // crear un usuario e iniciar sesion $nick = "p" . time(); $uarg = array("nombre" => "problem tester", "email" => $nick . "@example.net", "password" => "foobar23123", "nick" => $nick, "user" => $nick, "ubicacion" => "celaya"); $result = c_usuario::nuevo($uarg); $result = c_sesion::login($uarg); $result = c_problema::nuevo($arg); $this->assertTrue(SUCCESS($result)); $this->assertTrue(SUCCESS($result), "Crear un nuevo problema correctamente"); $rlistaprobs = array("public" => "NO"); $res = c_problema::lista($rlistaprobs); $probs = $res["problemas"]; $found = false; $found_prob = null; for ($i = 0; $i < sizeof($probs); $i++) { if ($probs[$i]["titulo"] == $titulo) { $found = true; $found_prob = $probs[$i]; break; } } $this->assertTrue($found); $this->assertEquals($found_prob["titulo"], $arg["titulo"]); $this->assertEquals($found_prob["problema"], $arg["problema"]); $this->assertEquals($found_prob["tiempoLimite"], $arg["tiempoLimite"]); $this->assertEquals($found_prob["usuario_redactor"], $argu["user"]); }
<a href="#casos" onclick="ShowTab( 'tab-verproblema-casos', this);"> <span>Casos</span> </a> </li> <li class="subtab rightmost-tab"> <a href="#stats" onclick="ShowTab( 'tab-verproblema-stats', this);"> <span>Estadisticas</span> </a> </li> </ul> </div> <div class="post_blanco tab" id="tab-verproblema-codigos"> <h2>Mejores tiempos para este problema</h2> <?php if (!isset($_REQUEST['cid'])) { $res = c_problema::mejoresTiempos($prob); if (SUCCESS($res)) { $runs = $res["tiempos"]; echo "<div style='padding:15px'>"; include "parcial_listadeejecucionesconcodigo.php"; echo "</div>"; } } ?> </div> <div class="post_blanco tab" id="tab-verproblema-stats"> </div> <script> // Mostrar el tab de rank ShowTab("tab-verproblema-codigos", $("li.subtab a")[0]); </script>
?> <th width='5%'>ID</th> <th >Titulo</th> <th width='12%'><a href="problemas.php?orden=vistas">Vistas</a></th> <th width='12%'><a href="problemas.php?orden=aceptados">Aceptados</a></th> <th width='12%'><a href="problemas.php?orden=intentos">Intentos</a></th> <th width='12%'>Radio</th> </tr> </thead> <tbody> <?php $params = array("public" => "SI"); if (isset($_GET["orden"])) { $params["orden"] = $_GET["orden"]; } $result = c_problema::lista($params); $resueltos = null; $intentados = null; if (isset($_GET["userID"]) || c_sesion::isLoggedIn()) { if (isset($_GET["userID"])) { $user = $_GET; } else { $user = c_sesion::usuarioActual(); } $res = c_usuario::problemasResueltos($user); if (SUCCESS($res)) { $resueltos = $res["problemas"]; } $res = c_usuario::problemasIntentados($user); if (SUCCESS($res)) { $intentados = $res["problemas"];
<?php require_once "../serverside/bootstrap.php"; define("PAGE_TITLE", "Nuevo problema"); require_once "head.php"; $editarproblema = null; if (isset($_GET["probID"])) { $result = c_problema::problema($_GET); if (SUCCESS($result)) { $editarproblema = $result["problema"]; include "post_nuevoproblema.php"; } else { ?> <div>Este problema no existe.</div><?php } } else { include "post_nuevoproblema.php"; } include "post_footer.php";