source: Dev/trunk/classes/Survey.php @ 75

Last change on this file since 75 was 75, checked in by fpvanagthoven, 14 years ago

Application should now just be RDF-saved. Beginning on DashboardTool?.php.

File size: 1.8 KB
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 */
12class Survey {
13
14    public $id;
15    public $title;
16    public $description;
17    public $questions;
18       
19        public $results;
20
21    public function __construct($id, $title, $description = null) {
22        $this->id = $id;
23        $this->title = $title;
24        $this->description = $description;
25        $this->questions = array();
26               
27                $this->results = null;
28    }
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        }
39
40    public static function getSurvey($info) {
41        $id = $info['surveyID'];
42        $title = $info['surveyTitle'];
43        $description = $info['surveyDescription'];
44
45        $survey = new Survey($id, $title, $description);
46
47        $numQ = 1; //number questions
48        while (isset($info['questionTitle' . $numQ])) {
49            $id = $info['questionID' . $numQ];
50            $title = $info['questionTitle' . $numQ];
51            $type = $info['questionType' . $numQ];
52            $description = $info['questionDescription' . $numQ];
53
54            $question = new Question($id, $title, $type, $description);
55
56            $numA = 1; //number answers
57            while (isset($info['q' . $numQ . 'ans' . $numA])) {
58                $answer = $info['q' . $numQ . 'ans' . $numA];
59                $question->answers[$numA] = $answer;
60
61                $numA++;
62            }
63
64
65            $survey->questions[$numQ] = $question;
66
67            $numQ++;
68        }
69
70        return $survey;
71    }
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        }
81
82}
83?>
Note: See TracBrowser for help on using the repository browser.