Last change
on this file since 238 was
210,
checked in by jkraaijeveld, 13 years ago
|
Moved all classes into classes_old
|
File size:
1.2 KB
|
Rev | Line | |
---|
[139] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /** |
---|
| 4 | * Description of Survey |
---|
| 5 | * |
---|
| 6 | * @author jkraaijeveld |
---|
| 7 | */ |
---|
| 8 | class Survey extends ResearchToolObject{ |
---|
| 9 | public $title; |
---|
| 10 | public $description; |
---|
| 11 | public $creator; |
---|
| 12 | public $questions; |
---|
| 13 | |
---|
[149] | 14 | public function __construct($uid = null, $title = null, $description = null, $creator = null, $questions = null) { |
---|
[139] | 15 | if(!isset($uid)) |
---|
| 16 | { |
---|
| 17 | $uid = md5(uniqid(rand(), true)); |
---|
| 18 | } |
---|
| 19 | $this->uid = $uid; |
---|
| 20 | $this->title = $title; |
---|
[149] | 21 | $this->description = $description; |
---|
| 22 | $this->creator = $creator; |
---|
[139] | 23 | $this->questions = $questions; |
---|
[186] | 24 | } |
---|
| 25 | |
---|
| 26 | /** |
---|
| 27 | * function evaluate() |
---|
| 28 | * Evaluates the references |
---|
| 29 | */ |
---|
| 30 | public function evaluate() |
---|
| 31 | { |
---|
| 32 | $dbi = new DatabaseInterface(); |
---|
| 33 | if(is_string($this->creator)) |
---|
| 34 | { |
---|
| 35 | $result = $dbi->get("user", array("uid" => $this->creator)); |
---|
| 36 | if(!isset($result[0])) |
---|
| 37 | return false; |
---|
| 38 | $this->creator = $result[0]; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | if(!empty($this->questions) && is_string($this->questions[0])) |
---|
| 42 | { |
---|
| 43 | $newQuestions = array(); |
---|
| 44 | foreach($this->questions as $question) |
---|
| 45 | { |
---|
| 46 | $result = $dbi->get("question", array("uid" => $question)); |
---|
| 47 | if(!isset($result[0])) |
---|
| 48 | return false; |
---|
| 49 | $newQuestions[] = $result[0]; |
---|
| 50 | } |
---|
| 51 | $this->questions = newQuestions; |
---|
| 52 | } |
---|
| 53 | return true; |
---|
| 54 | } |
---|
[139] | 55 | } |
---|
| 56 | |
---|
| 57 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.