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