Brendan Abolivier 9 gadus atpakaļ
vecāks
revīzija
da717571d2

+ 6
- 3
web/model/class.categorie.php Parādīt failu

@@ -51,10 +51,13 @@ class Categorie {
51 51
 	}
52 52
 
53 53
 	public function getArray() {
54
-		$return = array();
54
+		$questsets = array();
55 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 Parādīt failu

@@ -42,4 +42,11 @@ class Question {
42 42
 	function getBonneReponse() {
43 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 Parādīt failu

@@ -43,10 +43,15 @@ class Questset {
43 43
 	}
44 44
 
45 45
 	function getArray() {
46
-		$return = array();
46
+		$questions = array();
47 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 Parādīt failu

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