瀏覽代碼

Not exactly

Brendan Abolivier 9 年之前
父節點
當前提交
7d5b2964e2
共有 2 個文件被更改,包括 17 次插入4 次删除
  1. 9
    1
      web/model/class.categorie.php
  2. 8
    3
      web/model/class.questset.php

+ 9
- 1
web/model/class.categorie.php 查看文件

@@ -44,9 +44,17 @@ class Categorie {
44 44
 		$arrayCat = $bdd->Select("*", "categorie");
45 45
 		$return = array();
46 46
 		for($i = 0; $i < 2; $i++) {
47
-			$catIndex = rand(0, sizeof($arrayCat));
47
+			$catIndex = rand(0, sizeof($arrayCat)-1);
48 48
 			array_push($return, new Categorie($arrayCat[$catIndex]['nom_cat']));
49 49
 		}
50 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 查看文件

@@ -1,7 +1,6 @@
1 1
 <?php
2 2
 
3 3
 class Questset {
4
-	private $categorie;
5 4
 	private $reponse1;
6 5
 	private $reponse2;
7 6
 	private $questions;
@@ -27,11 +26,9 @@ class Questset {
27 26
 					array_push($this->questions, new Question($question['intitule']));
28 27
 				}
29 28
 
30
-				$this->categorie = $bdd->Select('*', 'reponses', $options)[0]['nom_cat'];
31 29
 			} catch(Exception $e) {
32 30
 				throw $e;
33 31
 			}
34
-			echo "Initialized\n";
35 32
 		} else {
36 33
 			throw new Exception('Un tableau de réponses est attendu dans le constructeur.');
37 34
 		}
@@ -44,4 +41,12 @@ class Questset {
44 41
 	function getLength() {
45 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
 }