source: Dev/trunk/classes_old/Survey.php @ 156

Last change on this file since 156 was 137, checked in by jkraaijeveld, 14 years ago

Added old classes

File size: 2.0 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            $code = $info['questionCode' . $numQ];
51            $title = $info['questionTitle' . $numQ];
52            $type = $info['questionType' . $numQ];
53            $description = $info['questionDescription' . $numQ];
54
55            $question = new Question($id, $code, $title, $type, $description);
56
57            $numA = 1; //number answers
58            while (isset($info['q' . $numQ . 'ans' . $numA])) {
59                $answer = $info['q' . $numQ . 'ans' . $numA];
60                $question->answers[$numA] = $answer;
61
62                $numA++;
63            }
64
65
66            $survey->questions[$numQ] = $question;
67
68            $numQ++;
69        }
70
71        return $survey;
72    }
73
74    /**
75     * TODO: Should return Results-object from reading RDF-database
76     * @param type $surveyID
77     */
78    public static function getResults($surveyID) {
79       
80    }
81
82}
83
84?>
Note: See TracBrowser for help on using the repository browser.