Exercice.php: is_unlocked done
This commit is contained in:
parent
257803cb85
commit
c10fc68a35
@ -1,7 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
//TODO: get the exercice number
|
|
||||||
|
|
||||||
if(!defined('ONYX')) exit;
|
if(!defined('ONYX')) exit;
|
||||||
|
|
||||||
class Exercice
|
class Exercice
|
||||||
@ -22,7 +20,8 @@ class Exercice
|
|||||||
{
|
{
|
||||||
$db = new BDD();
|
$db = new BDD();
|
||||||
// TODO escape id ?
|
// 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))
|
if (!empty($res))
|
||||||
{
|
{
|
||||||
@ -94,15 +93,23 @@ class Exercice
|
|||||||
|
|
||||||
function is_unlocked($team)
|
function is_unlocked($team)
|
||||||
{
|
{
|
||||||
//TODO
|
$db = new BDD();
|
||||||
return mt_rand(0,1);
|
|
||||||
|
$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)
|
function has_solved($team)
|
||||||
{
|
{
|
||||||
$db = new BDD();
|
$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();
|
$db->deconnexion();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user