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 == "") if ($this->require == "")
$this->number = 1; $this->number = 1;
$exo = $this; $db = new BDD();
$ret = 1;
$exo = $this->id;
$ret = 0;
$checked = array();
do 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++; $ret++;
} while ($exo->require != ""); } while ($exo != "" && !in_array($exo, $checked));
$this->number = $ret; $this->number = $ret;
} }