Changeset 28 for Dev/trunk


Ignore:
Timestamp:
07/21/11 13:06:09 (14 years ago)
Author:
basvannuland
Message:

added uid to data return

Location:
Dev/trunk
Files:
5 edited

Legend:

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

    r26 r28  
    1010
    1111class SurveyDatabaseInterface
    12 {       
    13     protected static $instance;
    14        
     12{               
    1513        protected $surveyRDFWriter;
    1614        protected $surveyRDFReader;
    1715 
    1816
    19     protected function __construct()
     17    public function __construct($surveyID=null)
    2018    {
    21         //protected to prevent direct instantiation
    22                 $surveyUID = md5( uniqid(rand(), true) );
    23                
     19                if($surveyID == null)
     20                        $surveyUID = md5( uniqid(rand(), true) );
     21                else
     22                        $surveyUID = $surveyID;
     23                                       
    2424                $this->surveyRDFWriter = new SurveyRDFWriter($surveyUID);
    2525                $this->surveyRDFReader = new SurveyRDFReader($surveyUID);
    2626    }
    27 
    28         public static function getInstance()
    29     {
    30         if (!self::$instance)
    31         {
    32             self::$instance = new SurveyDatabaseInterface();
    33         }
    34 
    35         return self::$instance;
    36     }
     27               
     28        public function __destruct()
     29        {
     30                echo "Destroyed";
     31        }
    3732       
    3833        public function setSurveyInfo($survey)
     
    7671                $resultSurvey = $this->surveyRDFReader->getSurveyInfo();
    7772               
     73                $surveyInfo['surveyID'] = substr($resultSurvey[0][0]['?uid'],9,strlen($resultSurvey[0][0]['?uid'])-11);
    7874                $surveyInfo['surveyTitle'] = substr($resultSurvey[0][0]['?title'],9,strlen($resultSurvey[0][0]['?title'])-11);
    7975                $surveyInfo['surveyDescription'] = substr($resultSurvey[0][0]['?description'],9,strlen($resultSurvey[0][0]['?description'])-11);
  • Dev/trunk/classes/SurveyRDFReader.php

    r26 r28  
    33class SurveyRDFReader
    44{
    5         var $model;
     5        protected $model;
    66       
    7         var $surveyUID;
     7        protected $surveyUID;
    88       
    99    public function __construct($surveyUID)
     
    1818        public function loadSurvey()
    1919        {
    20                 $this->model->load('surveys/'.$this->surveyUID.'.rdf');
     20                $this->model->load('surveys/survey_'.$this->surveyUID.'.rdf');
    2121        }
    2222       
     
    3737                        PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
    3838                        PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
    39                         SELECT  ?title ?description
     39                        SELECT  ?uid ?title ?description
    4040                        WHERE   
    4141                        {
    4242                                _survey         predicates:resource_type        resources:survey ;
    43                                                         predicates:title                        ?title ;
    44                                                         predicates:description          ?description
     43                                                        predicates:uid                          ?uid    ;
     44                                                        predicates:title                        ?title  ;
     45                                                        predicates:description          ?description
    4546                        }';
    4647                       
  • Dev/trunk/classes/SurveyRDFWriter.php

    r26 r28  
    33class SurveyRDFWriter
    44{
    5         var $model;
     5        protected $model;
    66               
    7         var $resourceSurvey;
    8         var $surveyUID;
     7        protected $resourceSurvey;
     8        protected $surveyUID;
    99       
    1010    public function __construct($surveyUID)
     
    1616                $this->surveyUID = $surveyUID;
    1717               
    18     }
     18    }   
     19       
     20        public function saveSurvey()
     21        {       
     22                $this->model->saveAs('surveys/survey_'.$this->surveyUID.'.rdf','rdf');
     23        }
    1924       
    2025        public function createSurvey($sTitle, $sDescription)
     
    3641                $predicateDescription = new Resource(DESCRIPTION);
    3742                $surveyDescription = new Literal($sDescription);
    38                 $this->model->add(new Statement($this->resourceSurvey,$predicateDescription,$surveyDescription));
    39                
     43                $this->model->add(new Statement($this->resourceSurvey,$predicateDescription,$surveyDescription));               
    4044        }
    4145       
     
    8993               
    9094                $predicateQuestion = new Resource(HAS_QUESTION);
    91                 $this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$resourceQuestion));
    92                
     95                $this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$resourceQuestion));           
    9396        }
    94        
    95         public function saveSurvey()
    96         {       
    97                 $this->model->saveAs('surveys/'.$this->surveyUID.'.rdf','rdf');
    98         }
    99 
    10097}
    10198
  • Dev/trunk/rdfConstants.php

    r26 r28  
    2626define('NUMBER_OF_ANSWERS',SURVEYTOOL_PREDICATES_NAMESPACE . 'number_of_answers');
    2727define('SCALE',SURVEYTOOL_PREDICATES_NAMESPACE . 'scale');
     28define('ANSWERED',SURVEYTOOL_PREDICATES_NAMESPACE . 'answered');
    2829
    2930// Arry with types of survey questions
  • Dev/trunk/surveycreation.php

    r26 r28  
    77        var_dump($_POST);
    88        echo '<br/><br/>';
    9         $surveyDBI = SurveyDatabaseInterface::getInstance();
     9        $surveyDBI =  new SurveyDatabaseInterface();
    1010        $surveyDBI->setSurveyInfo($_POST);
    1111        $info = $surveyDBI->getSurveyInfo();
Note: See TracChangeset for help on using the changeset viewer.