Browse Source

Not exactly

Brendan Abolivier 9 years ago
parent
commit
7d5b2964e2
2 changed files with 17 additions and 4 deletions
  1. 9
    1
      web/model/class.categorie.php
  2. 8
    3
      web/model/class.questset.php

+ 9
- 1
web/model/class.categorie.php View File

44
 		$arrayCat = $bdd->Select("*", "categorie");
44
 		$arrayCat = $bdd->Select("*", "categorie");
45
 		$return = array();
45
 		$return = array();
46
 		for($i = 0; $i < 2; $i++) {
46
 		for($i = 0; $i < 2; $i++) {
47
-			$catIndex = rand(0, sizeof($arrayCat));
47
+			$catIndex = rand(0, sizeof($arrayCat)-1);
48
 			array_push($return, new Categorie($arrayCat[$catIndex]['nom_cat']));
48
 			array_push($return, new Categorie($arrayCat[$catIndex]['nom_cat']));
49
 		}
49
 		}
50
 		return $return;
50
 		return $return;
51
 	}
51
 	}
52
+
53
+	public function getArray() {
54
+		$return = array();
55
+		foreach($this->questsets as $questset) {
56
+			array_push($return, $questset->getArray());
57
+		}
58
+		return $return;
59
+	}
52
 }
60
 }

+ 8
- 3
web/model/class.questset.php View File

1
 <?php
1
 <?php
2
 
2
 
3
 class Questset {
3
 class Questset {
4
-	private $categorie;
5
 	private $reponse1;
4
 	private $reponse1;
6
 	private $reponse2;
5
 	private $reponse2;
7
 	private $questions;
6
 	private $questions;
27
 					array_push($this->questions, new Question($question['intitule']));
26
 					array_push($this->questions, new Question($question['intitule']));
28
 				}
27
 				}
29
 
28
 
30
-				$this->categorie = $bdd->Select('*', 'reponses', $options)[0]['nom_cat'];
31
 			} catch(Exception $e) {
29
 			} catch(Exception $e) {
32
 				throw $e;
30
 				throw $e;
33
 			}
31
 			}
34
-			echo "Initialized\n";
35
 		} else {
32
 		} else {
36
 			throw new Exception('Un tableau de réponses est attendu dans le constructeur.');
33
 			throw new Exception('Un tableau de réponses est attendu dans le constructeur.');
37
 		}
34
 		}
44
 	function getLength() {
41
 	function getLength() {
45
 		return sizeof($this->questions);
42
 		return sizeof($this->questions);
46
 	}
43
 	}
44
+
45
+	function getArray() {
46
+		$return = array();
47
+		foreach($this->questions as $question) {
48
+			array_push($return, $question->getArray())
49
+		}
50
+		return $return;
51
+	}
47
 }
52
 }