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

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

Done: Default question description -> do not display in SurveyTool?. Added bug to TODO list

File size: 1.9 KB
Line 
1<?php
2
3/*
4 * To change this template, choose Tools | Templates
5 * and open the template in the editor.
6 */
7
8/**
9 * Description of Survey
10 *
11 * @author fpvanagthoven
12 */
13class Survey {
14
15    public $id;
16    public $title;
17    public $description;
18    public $questions;
19    public $results;
20   
21    const DEFAULT_DESCRIPTION = "Write a helpful description for this survey here.";
22
23    public function __construct($id, $title, $description = null) {
24        $this->id = $id;
25        $this->title = $title;
26        $this->description = $description;
27        $this->questions = array();
28
29        $this->results = null;
30    }
31
32    public function addQuestion($question) {
33        array_push($this->questions, $question);
34    }
35
36    public function setResults($surveyResults) {
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.