Changeset 130 for Dev/branches/jos-branch/classes/Question.php
- Timestamp:
- 10/24/11 13:47:23 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/jos-branch/classes/Question.php
r114 r130 11 11 * @author fpvanagthoven 12 12 */ 13 class Question { 14 public $code; 13 class Question extends ResearchToolObject{ 15 14 public $title; 16 15 public $type; 17 16 public $description; 17 public $category; 18 18 public $answers; // format answers['#'] 19 public $category;20 19 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) 22 30 { 23 $this-> code = $code;31 $this->uid = $uid; 24 32 $this->title = $title; 25 33 $this->type = $type; 26 34 $this->description = $description; 27 $this->answers = array(); 35 $this->category = $category; 36 $this->answers = $answers; 28 37 } 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 38 } 56 39
Note: See TracChangeset
for help on using the changeset viewer.