source: Dev/trunk/classes/Question.php @ 117

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

questions get loaded in fully

File size: 1.3 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 Question
10 *
11 * @author fpvanagthoven
12 */
13class Question {   
14    public $code;
15    public $title;
16    public $type;
17    public $description;
18    public $answers; // format answers['#']
19    public $category;
20   
21    public function __construct($code, $title = null, $type = null, $description = null)
22    {
23        $this->code = $code;
24        $this->title = $title;
25        $this->type = $type;
26        $this->description = $description;
27        $this->answers = array();
28    }
29   
30    /* reminder that constructor doesn't contain category haha */
31    public function setCategory($category)
32    {
33        $this->category = $category;
34    }
35   
36    public static function getQuestion($code, $info)
37    {
38        $question = new Question($code);
39        $question->title = $info['questionTitle'];
40        $question->type = $info['questionType'];
41        if(isset($info['questionDescription']))
42            $question->description = $info['questionDescription'];
43        $question->category = $info['questionCategory'];
44       
45        $i = 1;
46        while (isset($info['ans' . $i]))
47        {
48            array_push($question->answers, $info['ans' . $i]);
49            $i++;
50        }
51       
52        return $question;
53    }
54
55}
56
57?>
Note: See TracBrowser for help on using the repository browser.