Changeset 131 for Dev/trunk


Ignore:
Timestamp:
10/24/11 14:21:53 (14 years ago)
Author:
jkraaijeveld
Message:

Deleted previous database classes
Submitted (partial) new database connection

Location:
Dev/trunk/classes
Files:
7 added
37 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/Application.php

    r89 r131  
    66 * @author fpvanagthoven
    77 */
    8 class Application {
     8class Application extends ResearchToolObject{
    99   
    10     public $id;
    1110    public $title;
    1211    public $description;
    1312    public $style;
    1413
    15     public function __construct($id = null, $title = null, $description = null, $style = null)
     14    public function __construct($uid = null, $title = null, $description = null, $style = null)
    1615    {
    17         $this->id = $id;
     16        if(!isset ($uid))
     17        {
     18            $uid = md5(uniqid(rand(), true));
     19        }
     20        $this->uid = $uid;
    1821        $this->title = $title;
    1922        $this->description = $description;
    2023        $this->style = $style;
    2124    }
    22    
    23     public static function getApplication($info)
    24     {
    25         return new Application(
    26                 $info['applicationID'],
    27                 $info['applicationTitle'],
    28                 $info['applicationDescription'],
    29                 $info['applicationStyle']);
    30     }
    3125
    3226}
  • Dev/trunk/classes/Question.php

    r114 r131  
    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.