bonjour, j'ai une méthode qui sert à inscrire chaque étudiant dans une groupe, on peut
imaginer que ces groupe s'appelle des cohortes.
j'aimerais savoir si je peux réduire facilement ma méthode la voici

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
while ($donnee = $query->fetch()) {
    //echo $donnee['lastname']."<br/>"; 
    //$this->promo[$increment][] = $donnee['id'];
    /*
     * ON ENREGISTRE CHAQUE ETUDIANT DANS LEURS COHORTES
    */
    switch ($annee) {
        case 1:
            $enrol_cohort = "INSERT INTO cohort_members (cohortid,userid,timeadded) 
            VALUES(" . $this->cohorte_1a . "," . $donnee['id'] . "," . $this->timestamp_now . ")";
            $this->promo_1[] = $donnee['id'];
            $this->bdd->exec($enrol_cohort);
            break;
        case 2:
            $enrol_cohort = "INSERT INTO cohort_members (cohortid,userid,timeadded) 
            VALUES(" . $this->cohorte_2a . "," . $donnee['id'] . "," . $this->timestamp_now . ")";
            $this->promo_2[] = $donnee['id'];
            $this->bdd->exec($enrol_cohort);
            break;
        case 3:
            $enrol_cohort = "INSERT INTO cohort_members (cohortid,userid,timeadded) 
            VALUES(" . $this->cohorte_3a . "," . $donnee['id'] . "," . $this->timestamp_now . ")";
            $this->promo_3[] = $donnee['id'];
            $this->bdd->exec($enrol_cohort);
            break;
        case 4:
            $enrol_cohort = "INSERT INTO cohort_members (cohortid,userid,timeadded) 
            VALUES(" . $this->cohorte_4a . "," . $donnee['id'] . "," . $this->timestamp_now . ")";
            $this->promo_4[] = $donnee['id'];
            $this->bdd->exec($enrol_cohort);
            break;
        case 5:
            $enrol_cohort = "INSERT INTO cohort_members (cohortid,userid,timeadded) 
            VALUES(" . $this->cohorte_5a . "," . $donnee['id'] . "," . $this->timestamp_now . ")";
            $this->promo_5[] = $donnee['id'];
            $this->bdd->exec($enrol_cohort);
            break;
    }
}
l'attribut cohorte_1a est un nombre, entre cohorte_1a et cohorte_2a, il n'y a pas de
suite logique quelconque.


je vous remercie de votre réponse si vous avez une idée.