Changeset 195 for Dev/trunk/classes


Ignore:
Timestamp:
12/23/11 16:37:26 (13 years ago)
Author:
jkraaijeveld
Message:

In Session: -datetime has been renamed to creationdate

Connector has been adjusted accordingly

  • Removed answersets

Added SessionInstance?: This class is for unique occurences of a session.

In SessionInstance? is a reference to the currently unimplemented ResultSet?. This class will contain all answersets and gameresults given the SessionInstance?.

Location:
Dev/trunk/classes
Files:
2 added
4 edited

Legend:

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

    r171 r195  
    6666                                case "password" : $addition = "predicates:password '" . $arguments[$key] . "'\n"; break;
    6767                                case "creator" : $addition = "predicates:creator '" . $arguments[$key] . "'\n"; break;
    68                                 case "datetime" : $addition = "predicates:datetime '" . $arguments[$key] . "'\n"; break;
     68                                case "creationdate" : $addition = "predicates:creationdate '" . $arguments[$key] . "'\n"; break;
    6969                                case "applications" : foreach($arguments[$key] as $application) { $addition = $addition . "predicates:has_application '" . $application . "'\n"; } break;
    70 
    7170                                case "surveys" : foreach($arguments[$key] as $survey) { $addition = $addition . "predicates:has_survey '" . $survey . "'\n"; } break;
    7271                                case "answersets" : foreach($arguments[$key] as $answerset) { $addition = $addition . "predicates:has_answerset '" . $answerset . "'\n"; } break;
    7372                                case "questions" : foreach($arguments[$key] as $question) { $addition = $addition . "predicates:has_question '" . $question . "'\n"; } break;
    74 
     73                                case "location" : $addition = "predicates:location '" . $arguments[$key] . "\n"; break;
     74                                case "facilitator" : $addition = "predicates:facilitator '" . $arguments[$key] . "\n"; break;
     75                                case "starttime" : $addition = "predicates:starttime '" . $arguments[$key] . "\n"; break;
     76                                case "endtime" : $addition = "predicates:endtime '" . $arguments[$key] . "\n"; break;
     77                                case "session" : $addition = "predicates:of_session '" . $arguments[$key] . "\n"; break;
     78                                case "resultset" : $addition = "predciates:has_resultset '" . $arguments[$key] . "\n"; break;
    7579                        }
    7680                        $argumentString = $argumentString . $addition;
  • Dev/trunk/classes/DatabaseInterface.php

    r149 r195  
    2525        private $answerSetConnector;
    2626        private $sessionConnector;
     27        private $sessionInstanceConnector;
    2728   
    2829    /**
     
    3940                $this->answerSetConnector = new AnswerSetConnector();
    4041                $this->sessionConnector = new SessionConnector();
     42                $this->sessionInstanceConnector = new SessionInstanceConnector();
    4143    }
    4244   
     
    7577                                return $this->sessionConnector->get($arguments);
    7678                                break;
     79                        case "sessioninstance":
     80                                return $this->sessionInstanceConnector->get($arguments);
     81                                break;
    7782        }
    7883    }
     
    8792        {
    8893            case "Application":
    89                 $this->applicationConnector->set($rToolObject);
     94                return $this->applicationConnector->set($rToolObject);
    9095                break;
    9196            case "Question":
    92                 $this->questionConnector->set($rToolObject);
     97                return $this->questionConnector->set($rToolObject);
    9398                break;
    9499            case "User":
    95                 $this->userConnector->set($rToolObject);
     100                return $this->userConnector->set($rToolObject);
    96101                break;
    97102            case "Survey":
    98                                 $this->surveyConnector->set($rToolObject);
     103                                return $this->surveyConnector->set($rToolObject);
    99104                                break;
    100105            case "Respondent":
    101                                 $this->respondentConnector->set($rToolObject);
     106                                return $this->respondentConnector->set($rToolObject);
    102107                                break;
    103108            case "Answer":
    104                                 $this->answerConnector->set($rToolObject);
     109                                return $this->answerConnector->set($rToolObject);
    105110                                break;
    106111                        case "AnswerSet":
    107                                 $this->answerSetConnector->set($rToolObject);
     112                                return $this->answerSetConnector->set($rToolObject);
    108113                                break;
    109114                        case "Session":
    110                                 $this->sessionConnector->set($rToolObject);
     115                                return $this->sessionConnector->set($rToolObject);
     116                                break;
     117                        case "SessionInstance":
     118                                return $this->sessionInstanceConnector->set($rToolObject);
    111119                                break;
    112120        }
     
    122130        foreach ($rToolObjects as $rToolObject)
    123131        {
    124             $this->set($rToolObject);
    125         }
     132                        if(!$this->set($rToolObject))
     133                                return false;
     134                }
     135                return true;
    126136    }
    127137
  • Dev/trunk/classes/Session.php

    r186 r195  
    1010        public $title;
    1111        public $creator;
    12         public $datetime;
     12        public $creationdate;
    1313        public $pipeline;
    14         public $answersets;
    1514
    1615       
     
    2322         * @param type $pipeline
    2423         */
    25         public function __construct($uid = null, $title = null, $creator = null, $datetime = null, $pipeline = null, $answersets = null)
     24        public function __construct($uid = null, $title = null, $creator = null, $datetime = null, $pipeline = null)
    2625        {
    2726                if(!isset($uid))
     
    3231                $this->title = $title;
    3332                $this->creator = $creator;
    34                 $this->datetime = $datetime;
     33                $this->creationdate = $datetime;
    3534                $this->pipeline = $pipeline;
    36                 $this->answersets = $answersets;
    3735        }
    3836
     
    6765                        $this->pipeline = $newPipeline;
    6866                }
    69                 if(!empty($this->answersets) && is_string($this->answersets[0]))
    70                 {
    71                         $newAnswerSets = array();
    72                         foreach($this->answersets as $element)
    73                         {
    74                                 $result = $dbi->get("answerset", array("uid" => $element));
    75                                 if(!isset($result[0]))
    76                                         return false;
    77                                 $newAnswerSets[] = $result[0];
    78                         }
    79                         $this->answersets = $newAnswerSets;
    80                 }
    8167                return true;
    8268        }
     
    9076         * are written to the file whilst the others get lost.
    9177         */
     78        //DO NOT USE - BROKEN AS OF 23/12/2011
    9279        public function toSPSS($location)
    9380        {
  • Dev/trunk/classes/SessionConnector.php

    r186 r195  
    2828         * function get()
    2929         * @param type $arguments : An array containing one or more of the following elements:
    30          * 'uid', 'title', 'datetime', 'applications', 'surveys', 'answersets'
     30         * 'uid', 'title', 'creationdate', 'applications', 'surveys'
    3131         */
    3232        public function get($arguments)
     
    3838                        PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
    3939                        PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
    40                         SELECT DISTINCT ?uid, ?title, ?creator, ?datetime
     40                        SELECT DISTINCT ?uid, ?title, ?creator, ?creationdate
    4141                        WHERE
    4242                        {
     
    4545                                predicates:title ?title ;
    4646                                predicates:creator ?creator ;
    47                                 predicates:datetime ?datetime ;
     47                                predicates:creationdate ?creationdate ;
    4848                                ' . $this->createArguments($arguments) . '
    4949                        }';
     
    5858                                //Create a session object out of every result, get all required fields as well.
    5959                                $pipeline = $this->getPipeline($result['?uid']->label);
    60                                 $answersets = $this->getAnswerSets($result['?uid']->label);
    6160                                $creator = $result['?creator']->label;
    6261                                $datetime = new DateTime();
    63                                 $datetime->setTimestamp(intval($result['?datetime']->label));
    64                                 $sessions[] = new Session($result['?uid']->label, $result['?title']->label, $creator, $datetime, $pipeline, $answersets);
     62                                $datetime->setTimestamp(intval($result['?creationdate']->label));
     63                                $sessions[] = new Session($result['?uid']->label, $result['?title']->label, $creator, $datetime, $pipeline);
    6564                        }
    6665                }
Note: See TracChangeset for help on using the changeset viewer.