Friday release

This commit is contained in:
nemunaire 2013-12-14 06:11:14 +01:00
commit c349769425
16 changed files with 319 additions and 89 deletions

View file

@ -75,6 +75,23 @@ class Exercice
}
}
static function __set_state(array $array)
{
$tmp = new Exercice();
$tmp->id = $array["id"];
$tmp->number = $array["number"];
$tmp->theme = $array["theme"];
$tmp->require = $array["require"];
$tmp->level = $array["level"];
$tmp->points = $array["points"];
$tmp->statement = $array["statement"];
$tmp->files = $array["files"];
$tmp->keys = $array["keys"];
return $tmp;
}
function get_id()
{
return $this->id;
@ -89,10 +106,12 @@ class Exercice
// trié par date
function get_solved()
{
$db = new BDD();
$id = $this->id;
$db = new BDD();
$db->escape($id);
$res = $db->query("SELECT `id_team`, `time` FROM solved
WHERE id_exercice = '$this->id'
WHERE id_exercice = '$id'
ORDER BY time");
$db->deconnexion();
@ -105,11 +124,13 @@ class Exercice
if ($this->require == "")
return 1;
$db = new BDD();
$req = $this->require;
$db = new BDD();
$db->escape($req);
$res = $db->unique_query("SELECT `id` FROM solved
WHERE id_team = '".intval($team->id)."'
AND id_exercice = '$this->require'");
AND id_exercice = '$req'");
$db->deconnexion();
if (empty($res))
return 0;
@ -118,9 +139,11 @@ class Exercice
function has_solved($team)
{
$db = new BDD();
$id = $this->id;
$res = $db->unique_query("SELECT `time` FROM solved WHERE id_exercice = '$this->id'
$db = new BDD();
$db->escape($id);
$res = $db->unique_query("SELECT `time` FROM solved WHERE id_exercice = '$id'
AND id_team = ".intval($team->get_id()));
$db->deconnexion();
@ -143,6 +166,7 @@ class Exercice
do
{
array_push($checked, $exo);
$db->escape($exo);
$res = $db->unique_query("SELECT `require` FROM exercices WHERE id = '".$exo."'");
$exo = $res['require'];
$ret++;
@ -278,6 +302,28 @@ class Exercice
return $res['max'];
}
public function first_to_solve_exercice()
{
$db = new BDD();
$id = $this->id;
$db->escape($id);
$res = $db->unique_query("SELECT t3.team_name as result
FROM solved AS t1
INNER JOIN (
SELECT MIN(s.time) AS minTime
FROM solved AS s
WHERE s.id_exercice = '".$id."'
) AS t2
INNER JOIN teams AS t3 ON t1.id_team = t3.id
WHERE t1.time = t2.minTime");
$db->deconnexion();
return $res['result'];
}
}
class ExerciceNotFoundException extends Exception