Exercice.php: is_unlocked done

This commit is contained in:
Li Chen 2013-11-08 18:41:57 +01:00
parent 257803cb85
commit c10fc68a35

View File

@ -1,7 +1,5 @@
<?php
//TODO: get the exercice number
if(!defined('ONYX')) exit;
class Exercice
@ -22,7 +20,8 @@ class Exercice
{
$db = new BDD();
// TODO escape id ?
$res = $db->unique_query("SELECT id, id_theme, `require`, level, points, statement FROM exercices WHERE id = '$id'");
$res = $db->unique_query("SELECT id, id_theme, `require`, level, points, statement
FROM exercices WHERE id = '$id'");
if (!empty($res))
{
@ -94,15 +93,23 @@ class Exercice
function is_unlocked($team)
{
//TODO
return mt_rand(0,1);
$db = new BDD();
$res = $db->unique_query("SELECT `id` FROM solved
WHERE id_team = '".intval($team->id)."'
AND id_exercice = '$this->require'");
$db->deconnexion();
if (empty($res))
return 0;
return 1;
}
function has_solved($team)
{
$db = new BDD();
$res = $db->unique_query("SELECT `time` FROM solved WHERE id_exercice = '$this->id' AND id_team = ".intval($team->get_id()));
$res = $db->unique_query("SELECT `time` FROM solved WHERE id_exercice = '$this->id'
AND id_team = ".intval($team->get_id()));
$db->deconnexion();