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

@ -60,6 +60,22 @@ class Team
}
}
static function __set_state(array $array)
{
$tmp = new Team();
$tmp->id = $array["id"];
$tmp->team_name = $array["team_name"];
$tmp->key_hash = $array["key_hash"];
$tmp->auth_level = $array["auth_level"];
$tmp->slogan = $array["slogan"];
$tmp->members = $array["members"];
$tmp->points = $array["points"];
$tmp->revoked = $array["revoked"];
return $tmp;
}
// Class methods
function update()
{
@ -274,14 +290,20 @@ class Team
public static function get_top($nb=0)
{
$teams = Team::get_teams();
$top = Cache::read("top");
if (empty($top))
{
$top = Team::get_teams();
usort($teams, "cmp_team_pts");
usort($top, "cmp_team_pts");
Cache::set("top", $top);
}
if ($nb != 0)
$teams = array_slice($teams, 0, $nb);
$top = array_slice($top, 0, $nb);
return $teams;
return $top;
}
public static function get_nb_teams()
@ -292,21 +314,4 @@ class Team
return $res['count_teams'];
}
public static function first_to_solve_exercice($id_exercice)
{
$db = new BDD();
$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_exercice."
) AS t2
INNER JOIN teams AS t3 ON t1.id_team = t3.id
WHERE t1.time = t2.minTime");
$db->deconnexion();
return $res['result'];
}
}