Line | |
---|
1 | <?php |
---|
2 | /* |
---|
3 | * To change this template, choose Tools | Templates |
---|
4 | * and open the template in the editor. |
---|
5 | */ |
---|
6 | |
---|
7 | /** |
---|
8 | * Description of Survey |
---|
9 | * |
---|
10 | * @author fpvanagthoven |
---|
11 | */ |
---|
12 | class Survey { |
---|
13 | |
---|
14 | public $id; |
---|
15 | public $title; |
---|
16 | public $description; |
---|
17 | public $questions; |
---|
18 | |
---|
19 | public function __construct($id, $title, $description = null) { |
---|
20 | $this->id = $id; |
---|
21 | $this->title = $title; |
---|
22 | $this->description = $description; |
---|
23 | $this->questions = array(); |
---|
24 | } |
---|
25 | |
---|
26 | public static function getSurvey($info) { |
---|
27 | $id = $info['surveyID']; |
---|
28 | $title = $info['surveyTitle']; |
---|
29 | $description = $info['surveyDescription']; |
---|
30 | |
---|
31 | $survey = new Survey($id, $title, $description); |
---|
32 | |
---|
33 | $numQ = 1; //number questions |
---|
34 | while (isset($info['questionTitle' . $numQ])) { |
---|
35 | $id = $info['questionID' . $numQ]; |
---|
36 | $title = $info['questionTitle' . $numQ]; |
---|
37 | $type = $info['questionType' . $numQ]; |
---|
38 | $description = $info['questionDescription' . $numQ]; |
---|
39 | |
---|
40 | $question = new Question($id, $title, $type, $description); |
---|
41 | |
---|
42 | $numA = 1; //number answers |
---|
43 | while (isset($info['q' . $numQ . 'ans' . $numA])) { |
---|
44 | $answer = $info['q' . $numQ . 'ans' . $numA]; |
---|
45 | $question->answers[$numA] = $answer; |
---|
46 | |
---|
47 | $numA++; |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | $survey->questions[$numQ] = $question; |
---|
52 | |
---|
53 | $numQ++; |
---|
54 | } |
---|
55 | |
---|
56 | return $survey; |
---|
57 | } |
---|
58 | |
---|
59 | } |
---|
60 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.