Ignore:
Timestamp:
07/22/11 17:28:23 (14 years ago)
Author:
basvannuland
Message:

added database readers and writers for application info and facilitator info

possible to store survey application and creator info

File:
1 edited

Legend:

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

    r31 r40  
    33class SurveyAnswerRDFReader extends SurveyRDFReader
    44{       
     5        protected $tempModel;
     6       
    57    public function __construct($surveyUID)
    68    {
    79        parent::__construct($surveyUID);
     10               
     11                / Create empty MemModel
     12                $factory = new ModelFactory();
     13                $this->tempModel = $factory->getDefaultModel();
    814        }
    915       
    1016        public function loadSurvey()
    1117        {
    12                 parent::loadSurvey();
     18                parent::loadSurvey();           
     19               
     20        }
     21       
     22        public function getAnswerByQuestion($questionID)
     23        {
     24                $this->tempModel->loadModel($this->model);
     25               
    1326                $answerPath = 'surveys/answers_'.$this->surveyUID;
    1427                $answers = array();
     
    2437                foreach($answers as $answer)
    2538                {
    26                         $this->model->load($answerPath.'/'.$answer);
     39                        $this->tempModel->load($answerPath.'/'.$answer);
    2740                }
    28         }
     41               
     42                $this->tempModel->visualize();
    2943       
    30         public function getAnswer($questionID)
    31         {
    32         $querystring = '
     44                $querystring = '
    3345                        PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
    3446                        PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
     
    4153                        }';
    4254                       
    43                 $result = $this->model->sparqlQuery($querystring);
     55                $result = $this->tempModel->sparqlQuery($querystring);
     56               
     57                $this->tempModel->close();             
     58
     59                $this->tempModel->visualize();
     60                               
     61                return $result;
     62        }
     63       
     64        public function getAnswerByRespondent($respondentID)
     65        {
     66                $this->tempModel->loadModel($this->model);
     67               
     68                $answerPath = 'surveys/answers_'.$this->surveyUID;
     69               
     70                $this->tempModel->load($answerPath . '/$answer_' . $respondentID);
     71               
     72                $this->tempModel->visualize();
     73       
     74                $querystring = '
     75                        PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
     76                        PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
     77                        SELECT  ?answered
     78                        WHERE   
     79                        {
     80                                _question       predicates:resource_type        resources:question ;
     81                                                        predicates:answered             ?answered       
     82                        }';
     83                       
     84                $result = $this->tempModel->sparqlQuery($querystring);
     85               
     86                $this->tempModel->close();             
     87
     88                $this->tempModel->visualize();
     89                               
     90                return $result;
     91        }
     92       
     93        public function getAnswerByRespondentAndQuestion($respondentID,$questionID)
     94        {
     95                $this->tempModel->loadModel($this->model);
     96               
     97                $answerPath = 'surveys/answers_'.$this->surveyUID;
     98               
     99                $this->tempModel->load($answerPath . '/$answer_' . $respondentID);
     100               
     101                $this->tempModel->visualize();
     102       
     103                $querystring = '
     104                        PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
     105                        PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
     106                        SELECT  ?answered
     107                        WHERE   
     108                        {
     109                                _question       predicates:resource_type        resources:question ;
     110                                                        predicates:uid                          "'.$questionID.'"       ;
     111                                                        predicates:answered             ?answered       
     112                        }';
     113                       
     114                $result = $this->tempModel->sparqlQuery($querystring);
     115               
     116                $this->tempModel->close();             
     117
     118                $this->tempModel->visualize();
    44119                               
    45120                return $result;
Note: See TracChangeset for help on using the changeset viewer.