Exercice.class: fixed set_number

This commit is contained in:
Li Chen 2013-11-05 04:41:50 +01:00
parent 744a674f74
commit 3c4b6296ba

View File

@ -74,14 +74,20 @@ class Exercice
if ($this->require == "")
$this->number = 1;
$exo = $this;
$ret = 1;
$db = new BDD();
$exo = $this->id;
$ret = 0;
$checked = array();
do
{
$exo = new Exercice($exo->require);
array_push($checked, $exo);
$res = $db->unique_query("SELECT `require` FROM exercices WHERE id = ".intval($exo));
$exo = $res['require'];
$ret++;
} while ($exo->require != "");
} while ($exo != "" && !in_array($exo, $checked));
$this->number = $ret;
}