Changes in Dev/trunk/classes/SurveyRDFReader.php [16:28]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/SurveyRDFReader.php
r16 r28 3 3 class SurveyRDFReader 4 4 { 5 var $model; 6 7 public function SurveyRDFReader() 8 { 5 protected $model; 6 7 protected $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/survey_'.$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 ?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 }'; 26 75 27 76 $result = $this->model->sparqlQuery($querystring); … … 30 79 } 31 80 32 public function readSurvey Description()81 public function readSurveyQuestionsDescription() 33 82 { 34 83 $querystring = ' 35 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>84 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> 36 85 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 37 SELECT ?description 38 WHERE { resources:survey predicates:description ?description }'; 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 }'; 39 145 40 146 $result = $this->model->sparqlQuery($querystring);
Note: See TracChangeset
for help on using the changeset viewer.