Changeset 28
- Timestamp:
- 07/21/11 13:06:09 (14 years ago)
- Location:
- Dev/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/SurveyDatabaseInterface.php
r26 r28 10 10 11 11 class SurveyDatabaseInterface 12 { 13 protected static $instance; 14 12 { 15 13 protected $surveyRDFWriter; 16 14 protected $surveyRDFReader; 17 15 18 16 19 p rotected function __construct()17 public function __construct($surveyID=null) 20 18 { 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 24 24 $this->surveyRDFWriter = new SurveyRDFWriter($surveyUID); 25 25 $this->surveyRDFReader = new SurveyRDFReader($surveyUID); 26 26 } 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 } 37 32 38 33 public function setSurveyInfo($survey) … … 76 71 $resultSurvey = $this->surveyRDFReader->getSurveyInfo(); 77 72 73 $surveyInfo['surveyID'] = substr($resultSurvey[0][0]['?uid'],9,strlen($resultSurvey[0][0]['?uid'])-11); 78 74 $surveyInfo['surveyTitle'] = substr($resultSurvey[0][0]['?title'],9,strlen($resultSurvey[0][0]['?title'])-11); 79 75 $surveyInfo['surveyDescription'] = substr($resultSurvey[0][0]['?description'],9,strlen($resultSurvey[0][0]['?description'])-11); -
Dev/trunk/classes/SurveyRDFReader.php
r26 r28 3 3 class SurveyRDFReader 4 4 { 5 var$model;5 protected $model; 6 6 7 var$surveyUID;7 protected $surveyUID; 8 8 9 9 public function __construct($surveyUID) … … 18 18 public function loadSurvey() 19 19 { 20 $this->model->load('surveys/ '.$this->surveyUID.'.rdf');20 $this->model->load('surveys/survey_'.$this->surveyUID.'.rdf'); 21 21 } 22 22 … … 37 37 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> 38 38 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 39 SELECT ? title ?description39 SELECT ?uid ?title ?description 40 40 WHERE 41 41 { 42 42 _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 45 46 }'; 46 47 -
Dev/trunk/classes/SurveyRDFWriter.php
r26 r28 3 3 class SurveyRDFWriter 4 4 { 5 var$model;5 protected $model; 6 6 7 var$resourceSurvey;8 var$surveyUID;7 protected $resourceSurvey; 8 protected $surveyUID; 9 9 10 10 public function __construct($surveyUID) … … 16 16 $this->surveyUID = $surveyUID; 17 17 18 } 18 } 19 20 public function saveSurvey() 21 { 22 $this->model->saveAs('surveys/survey_'.$this->surveyUID.'.rdf','rdf'); 23 } 19 24 20 25 public function createSurvey($sTitle, $sDescription) … … 36 41 $predicateDescription = new Resource(DESCRIPTION); 37 42 $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)); 40 44 } 41 45 … … 89 93 90 94 $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)); 93 96 } 94 95 public function saveSurvey()96 {97 $this->model->saveAs('surveys/'.$this->surveyUID.'.rdf','rdf');98 }99 100 97 } 101 98 -
Dev/trunk/rdfConstants.php
r26 r28 26 26 define('NUMBER_OF_ANSWERS',SURVEYTOOL_PREDICATES_NAMESPACE . 'number_of_answers'); 27 27 define('SCALE',SURVEYTOOL_PREDICATES_NAMESPACE . 'scale'); 28 define('ANSWERED',SURVEYTOOL_PREDICATES_NAMESPACE . 'answered'); 28 29 29 30 // Arry with types of survey questions -
Dev/trunk/surveycreation.php
r26 r28 7 7 var_dump($_POST); 8 8 echo '<br/><br/>'; 9 $surveyDBI = SurveyDatabaseInterface::getInstance();9 $surveyDBI = new SurveyDatabaseInterface(); 10 10 $surveyDBI->setSurveyInfo($_POST); 11 11 $info = $surveyDBI->getSurveyInfo();
Note: See TracChangeset
for help on using the changeset viewer.