Changes in Dev/trunk/classes/SurveyRDFReader.php [28:16]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/SurveyRDFReader.php
r28 r16 3 3 class SurveyRDFReader 4 4 { 5 protected $model; 6 7 protected $surveyUID; 8 9 public function __construct($surveyUID) 10 { 5 var $model; 6 7 public function SurveyRDFReader() 8 { 11 9 // Create empty MemModel 12 10 $factory = new ModelFactory(); 13 $this->model = $factory->getDefaultModel(); 14 15 $this->surveyUID = $surveyUID; 11 $this->model = $factory->getDefaultModel(); 16 12 } 17 13 18 public function loadSurvey( )14 public function loadSurvey($sTitle) 19 15 { 20 $this->model->load('surveys/ survey_'.$this->surveyUID.'.rdf');16 $this->model->load('surveys/'.$sTitle.'.rdf'); 21 17 } 22 18 23 public function getSurveyInfo() 24 { 25 SurveyRDFReader::loadSurvey(); 26 27 $result = array(); 28 $result[] = $this->readSurveyInfo(); 29 $result[] = $this->readSurveyQuestions(); 30 31 return $result; 32 } 33 34 public function readSurveyInfo() 19 public function readSurveyTitle() 35 20 { 36 21 $querystring = ' 37 PREFIX predicates: <' . 22 PREFIX predicates: <' .SURVEYTOOL_PREDICATES_NAMESPACE . '> 38 23 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 39 SELECT ?uid ?title ?description 40 WHERE 41 { 42 _survey predicates:resource_type resources:survey ; 43 predicates:uid ?uid ; 44 predicates:title ?title ; 45 predicates:description ?description 46 }'; 47 48 $result = $this->model->sparqlQuery($querystring); 49 50 return $result; 51 } 52 53 public function readSurveyQuestions() 54 { 55 $result = array(); 56 $result[] = $this->readSurveyQuestionsTitle(); 57 $result[] = $this->readSurveyQuestionsDescription(); 58 $result[] = $this->readSurveyQuestionsType(); 59 $result[] = $this->readSurveyQuestionsID(); 60 61 return $result; 62 } 63 64 public function readSurveyQuestionsTitle() 65 { 66 $querystring = ' 67 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> 68 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 69 SELECT ?questionTitle 70 WHERE 71 { 72 _question predicates:resource_type resources:question ; 73 predicates:title ?questionTitle 74 }'; 24 SELECT ?title 25 WHERE { resources:survey predicates:title ?title }'; 75 26 76 27 $result = $this->model->sparqlQuery($querystring); … … 79 30 } 80 31 81 public function readSurvey QuestionsDescription()32 public function readSurveyDescription() 82 33 { 83 34 $querystring = ' 84 PREFIX predicates: <' . 35 PREFIX predicates: <' .SURVEYTOOL_PREDICATES_NAMESPACE . '> 85 36 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 86 SELECT ?questionDescription 87 WHERE 88 { 89 _question predicates:resource_type resources:question ; 90 predicates:description ?questionDescription 91 }'; 92 93 $result = $this->model->sparqlQuery($querystring); 94 95 return $result; 96 } 97 98 public function readSurveyQuestionsType() 99 { 100 $querystring = ' 101 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> 102 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 103 SELECT ?questionType 104 WHERE 105 { 106 _question predicates:resource_type resources:question ; 107 predicates:question_type ?questionType 108 }'; 109 110 $result = $this->model->sparqlQuery($querystring); 111 112 return $result; 113 } 114 115 public function readSurveyQuestionsID() 116 { 117 $querystring = ' 118 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> 119 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 120 SELECT ?questionID 121 WHERE 122 { 123 _question predicates:resource_type resources:question ; 124 predicates:uid ?questionID 125 }'; 126 127 $result = $this->model->sparqlQuery($querystring); 128 129 return $result; 130 } 131 132 public function readSurveyAnswers($qID) 133 { 134 $querystring = ' 135 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> 136 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 137 SELECT ?answerTitle 138 WHERE 139 { 140 _question predicates:resource_type resources:question ; 141 predicates:uid "' . $qID . '" ; 142 predicates:has_answer _answer . 143 _answer predicates:title ?answerTitle 144 }'; 37 SELECT ?description 38 WHERE { resources:survey predicates:description ?description }'; 145 39 146 40 $result = $this->model->sparqlQuery($querystring);
Note: See TracChangeset
for help on using the changeset viewer.