Browse Source

blblafqskjldfh

Brendan Abolivier 9 years ago
parent
commit
da717571d2
4 changed files with 24 additions and 7 deletions
  1. 6
    3
      web/model/class.categorie.php
  2. 7
    0
      web/model/class.question.php
  3. 8
    3
      web/model/class.questset.php
  4. 3
    1
      web/test.php

+ 6
- 3
web/model/class.categorie.php View File

51
 	}
51
 	}
52
 
52
 
53
 	public function getArray() {
53
 	public function getArray() {
54
-		$return = array();
54
+		$questsets = array();
55
 		foreach($this->questsets as $questset) {
55
 		foreach($this->questsets as $questset) {
56
-			array_push($return, $questset->getArray());
56
+			array_push($questsets, $questset->getArray());
57
 		}
57
 		}
58
-		return $return;
58
+		return array(
59
+			"nom_cat" => $this->nomCat,
60
+			"themes" => $questsets
61
+		);
59
 	}
62
 	}
60
 }
63
 }

+ 7
- 0
web/model/class.question.php View File

42
 	function getBonneReponse() {
42
 	function getBonneReponse() {
43
 		return $this->bonneReponse;
43
 		return $this->bonneReponse;
44
 	}
44
 	}
45
+
46
+	function getArray() {
47
+		return array(
48
+			"intitule" => $this->intitule,
49
+			"bonneReponse" => $this->bonneReponse
50
+		);
51
+	}
45
 }
52
 }

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

43
 	}
43
 	}
44
 
44
 
45
 	function getArray() {
45
 	function getArray() {
46
-		$return = array();
46
+		$questions = array();
47
 		foreach($this->questions as $question) {
47
 		foreach($this->questions as $question) {
48
-			array_push($return, $question->getArray())
48
+			array_push($questions, $question->getArray())
49
 		}
49
 		}
50
-		return $return;
50
+
51
+		return array(
52
+			"reponse1" => $this->reponse1,
53
+			"reponse2" => $this->reponse2,
54
+			"questions" => $questions
55
+		);
51
 	}
56
 	}
52
 }
57
 }

+ 3
- 1
web/test.php View File

6
 
6
 
7
 try{
7
 try{
8
 	$categories = Categorie::randSelect();
8
 	$categories = Categorie::randSelect();
9
-	var_dump($categories);
9
+	foreach($categories as $categorie) {
10
+		json_encode($categorie->getArray());
11
+	}
10
 }catch(Exception $e) {
12
 }catch(Exception $e) {
11
 	echo("<strong>Erreur : </strong>".$e->getMessage());
13
 	echo("<strong>Erreur : </strong>".$e->getMessage());
12
 }
14
 }