Rev | Line | |
---|
[29] | 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 { |
---|
[56] | 13 | |
---|
[29] | 14 | public $id; |
---|
| 15 | public $title; |
---|
| 16 | public $description; |
---|
| 17 | public $questions; |
---|
[56] | 18 | |
---|
| 19 | public function __construct($id, $title, $description = null) { |
---|
[29] | 20 | $this->id = $id; |
---|
| 21 | $this->title = $title; |
---|
| 22 | $this->description = $description; |
---|
| 23 | $this->questions = array(); |
---|
| 24 | } |
---|
[56] | 25 | |
---|
| 26 | public static function getSurvey($info) { |
---|
[29] | 27 | $id = $info['surveyID']; |
---|
| 28 | $title = $info['surveyTitle']; |
---|
| 29 | $description = $info['surveyDescription']; |
---|
[56] | 30 | |
---|
[29] | 31 | $survey = new Survey($id, $title, $description); |
---|
[56] | 32 | |
---|
[29] | 33 | $numQ = 1; //number questions |
---|
[56] | 34 | while (isset($info['questionTitle' . $numQ])) { |
---|
[35] | 35 | $id = $info['questionID' . $numQ]; |
---|
[29] | 36 | $title = $info['questionTitle' . $numQ]; |
---|
| 37 | $type = $info['questionType' . $numQ]; |
---|
| 38 | $description = $info['questionDescription' . $numQ]; |
---|
[56] | 39 | |
---|
[35] | 40 | $question = new Question($id, $title, $type, $description); |
---|
[29] | 41 | |
---|
| 42 | $numA = 1; //number answers |
---|
[56] | 43 | while (isset($info['q' . $numQ . 'ans' . $numA])) { |
---|
[29] | 44 | $answer = $info['q' . $numQ . 'ans' . $numA]; |
---|
| 45 | $question->answers[$numA] = $answer; |
---|
[56] | 46 | |
---|
[29] | 47 | $numA++; |
---|
| 48 | } |
---|
[56] | 49 | |
---|
| 50 | |
---|
[29] | 51 | $survey->questions[$numQ] = $question; |
---|
[56] | 52 | |
---|
[29] | 53 | $numQ++; |
---|
| 54 | } |
---|
[56] | 55 | |
---|
[29] | 56 | return $survey; |
---|
| 57 | } |
---|
[56] | 58 | |
---|
[29] | 59 | } |
---|
| 60 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.