Ignore:
Timestamp:
10/24/11 13:47:23 (14 years ago)
Author:
jkraaijeveld
Message:

Added support for questions and users

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/jos-branch/classes/Question.php

    r114 r130  
    1111 * @author fpvanagthoven
    1212 */
    13 class Question {   
    14     public $code;
     13class Question extends ResearchToolObject{   
    1514    public $title;
    1615    public $type;
    1716    public $description;
     17    public $category;
    1818    public $answers; // format answers['#']
    19     public $category;
    2019   
    21     public function __construct($code, $title = null, $type = null, $description = null)
     20    /**
     21     * Constructor for a Question. $uid equals the corresponding code.
     22     * @param type $uid
     23     * @param type $title
     24     * @param type $type
     25     * @param type $description
     26     * @param type $category
     27     * @param type $answers
     28     */
     29    public function __construct($uid, $title = null, $type = null, $description = null, $category = null, $answers = null)
    2230    {
    23         $this->code = $code;
     31        $this->uid = $uid;
    2432        $this->title = $title;
    2533        $this->type = $type;
    2634        $this->description = $description;
    27         $this->answers = array();
     35        $this->category =  $category;
     36        $this->answers = $answers;
    2837    }
    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 
    5538}
    5639
Note: See TracChangeset for help on using the changeset viewer.