[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; |
---|
[75] | 18 | |
---|
| 19 | public $results; |
---|
[56] | 20 | |
---|
| 21 | public function __construct($id, $title, $description = null) { |
---|
[29] | 22 | $this->id = $id; |
---|
| 23 | $this->title = $title; |
---|
| 24 | $this->description = $description; |
---|
| 25 | $this->questions = array(); |
---|
[75] | 26 | |
---|
| 27 | $this->results = null; |
---|
[29] | 28 | } |
---|
[75] | 29 | |
---|
| 30 | public function addQuestion($question) |
---|
| 31 | { |
---|
| 32 | array_push($this->questions, $question); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | public function setResults($surveyResults) |
---|
| 36 | { |
---|
| 37 | $this->results = $surveyResults; |
---|
| 38 | } |
---|
[56] | 39 | |
---|
| 40 | public static function getSurvey($info) { |
---|
[29] | 41 | $id = $info['surveyID']; |
---|
| 42 | $title = $info['surveyTitle']; |
---|
| 43 | $description = $info['surveyDescription']; |
---|
[56] | 44 | |
---|
[29] | 45 | $survey = new Survey($id, $title, $description); |
---|
[56] | 46 | |
---|
[29] | 47 | $numQ = 1; //number questions |
---|
[56] | 48 | while (isset($info['questionTitle' . $numQ])) { |
---|
[35] | 49 | $id = $info['questionID' . $numQ]; |
---|
[29] | 50 | $title = $info['questionTitle' . $numQ]; |
---|
| 51 | $type = $info['questionType' . $numQ]; |
---|
| 52 | $description = $info['questionDescription' . $numQ]; |
---|
[56] | 53 | |
---|
[35] | 54 | $question = new Question($id, $title, $type, $description); |
---|
[29] | 55 | |
---|
| 56 | $numA = 1; //number answers |
---|
[56] | 57 | while (isset($info['q' . $numQ . 'ans' . $numA])) { |
---|
[29] | 58 | $answer = $info['q' . $numQ . 'ans' . $numA]; |
---|
| 59 | $question->answers[$numA] = $answer; |
---|
[56] | 60 | |
---|
[29] | 61 | $numA++; |
---|
| 62 | } |
---|
[56] | 63 | |
---|
| 64 | |
---|
[29] | 65 | $survey->questions[$numQ] = $question; |
---|
[56] | 66 | |
---|
[29] | 67 | $numQ++; |
---|
| 68 | } |
---|
[56] | 69 | |
---|
[29] | 70 | return $survey; |
---|
| 71 | } |
---|
[75] | 72 | |
---|
| 73 | /** |
---|
| 74 | * TODO: Should return Results-object from reading RDF-database |
---|
| 75 | * @param type $surveyID |
---|
| 76 | */ |
---|
| 77 | public static function getResults($surveyID) |
---|
| 78 | { |
---|
| 79 | |
---|
| 80 | } |
---|
[56] | 81 | |
---|
[29] | 82 | } |
---|
| 83 | ?> |
---|