Browse Source

Questions over

Brendan Abolivier 9 years ago
parent
commit
2f9d2bd6a7

+ 4
- 2
web/model/class.categorie.php View File

@@ -30,7 +30,9 @@ class Categorie {
30 30
 		$options = array(
31 31
 			"where" => array(
32 32
 				array("nom_cat", "=", $this->nomCat)
33
-			)
33
+			),
34
+			"order by" => array("rand()"),
35
+			"limit" => array("2")
34 36
 		);
35 37
 
36 38
 		$resp = $this->bdd->Select('*', 'reponses', $options);
@@ -56,7 +58,7 @@ class Categorie {
56 58
 			array_push($questsets, $questset->getArray());
57 59
 		}
58 60
 		return array(
59
-			"nom_cat" => $this->nomCat,
61
+			"nom_cat" => utf8_encode($this->nomCat),
60 62
 			"themes" => $questsets
61 63
 		);
62 64
 	}

+ 1
- 1
web/model/class.connector.php View File

@@ -47,7 +47,7 @@ class Connector {
47 47
 					throw new Exception('Problème lors de la création du substring');
48 48
 				}
49 49
 			} else if(($upName = strtoupper($name)) == "ORDER BY") {
50
-				if(sizeof($value) != 2) {
50
+				if(sizeof($value) != 2 && substr($value[0], -2) != "()") { 
51 51
 					throw new Exception('Nombre de paramètres incorrects (ORDER BY). Les paramètres passés sont : '
52 52
 						.implode(',', $value));
53 53
 				}

+ 2
- 2
web/model/class.question.php View File

@@ -45,8 +45,8 @@ class Question {
45 45
 
46 46
 	function getArray() {
47 47
 		return array(
48
-			"intitule" => $this->intitule,
49
-			"bonneReponse" => $this->bonneReponse
48
+			"intitule" => utf8_encode($this->intitule),
49
+			"bonneReponse" => utf8_encode($this->bonneReponse)
50 50
 		);
51 51
 	}
52 52
 }

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

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

+ 17
- 0
web/questions.php View File

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+// Fichier de tests du modèle
4
+
5
+require_once('model/classes.php');
6
+header("Content-Type:application/json");
7
+
8
+try{
9
+	$categoriesObj = Categorie::randSelect();
10
+	$categories = array();
11
+	foreach($categoriesObj as $categorie) {
12
+		array_push($categories, $categorie->getArray());
13
+	}
14
+	echo json_encode($categories);
15
+}catch(Exception $e) {
16
+	echo("<strong>Erreur : </strong>".$e->getMessage());
17
+}

+ 0
- 14
web/test.php View File

@@ -1,14 +0,0 @@
1
-<?php
2
-
3
-// Fichier de tests du modèle
4
-
5
-require_once('model/classes.php');
6
-
7
-try{
8
-	$categories = Categorie::randSelect();
9
-	foreach($categories as $categorie) {
10
-		json_encode($categorie->getArray());
11
-	}
12
-}catch(Exception $e) {
13
-	echo("<strong>Erreur : </strong>".$e->getMessage());
14
-}