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

Last change on this file since 95 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
RevLine 
[29]1<?php
[95]2
[29]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 {
[56]14
[29]15    public $id;
16    public $title;
17    public $description;
18    public $questions;
[95]19    public $results;
20   
21    const DEFAULT_DESCRIPTION = "Write a helpful description for this survey here.";
[56]22
23    public function __construct($id, $title, $description = null) {
[29]24        $this->id = $id;
25        $this->title = $title;
26        $this->description = $description;
27        $this->questions = array();
[95]28
29        $this->results = null;
[29]30    }
[56]31
[95]32    public function addQuestion($question) {
33        array_push($this->questions, $question);
34    }
35
36    public function setResults($surveyResults) {
37        $this->results = $surveyResults;
38    }
39
[56]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    }
[56]72
[95]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
[29]81}
[95]82
[29]83?>
Note: See TracBrowser for help on using the repository browser.