- Timestamp:
- 07/15/11 15:33:08 (14 years ago)
- Location:
- Dev/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/SurveyRDFReader.php
r14 r16 20 20 { 21 21 $querystring = ' 22 PREFIX predicate : <' .SURVEYTOOL_PREDICATES_NAMESPACE . '>23 PREFIX namespace: <' . SURVEYTOOL_NAMESPACE . '>24 SELECT ? surveyTitle25 WHERE { namespace:Survey predicate:title ?surveyTitle }';22 PREFIX predicates: <' .SURVEYTOOL_PREDICATES_NAMESPACE . '> 23 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 24 SELECT ?title 25 WHERE { resources:survey predicates:title ?title }'; 26 26 27 27 $result = $this->model->sparqlQuery($querystring); … … 30 30 } 31 31 32 32 public function readSurveyDescription() 33 33 { 34 34 $querystring = ' 35 PREFIX predicate : <' .SURVEYTOOL_PREDICATES_NAMESPACE . '>36 PREFIX namespace: <' . SURVEYTOOL_NAMESPACE . '>37 SELECT ? surveyDescription38 WHERE { namespace:Survey predicate:description ?surveyDescription }';35 PREFIX predicates: <' .SURVEYTOOL_PREDICATES_NAMESPACE . '> 36 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 37 SELECT ?description 38 WHERE { resources:survey predicates:description ?description }'; 39 39 40 40 $result = $this->model->sparqlQuery($querystring); -
Dev/trunk/classes/SurveyRDFWriter.php
r14 r16 6 6 7 7 var $resourceSurvey; 8 var $resourceTitle;9 var $resourceDescription;10 11 8 /** 12 9 * Use SurveyRDFWriter::getInstance() instead of this … … 25 22 { 26 23 27 $this->resourceSurvey = new Resource(SURVEYTOOL_NAMESPACE.'Survey'); 28 $this->resourceTitle = new Resource(TITLE); 29 $this->resourceDescription = new Resource(DESCRIPTION); 24 $this->resourceSurvey = new Resource(SURVEY); 30 25 } 31 26 32 27 public function createSurvey($sTitle, $sDescription) 33 28 { 29 30 $predicateTitle = new Resource(TITLE); 34 31 $surveyTitle = new Literal($sTitle); 35 $this->model->add(new Statement($this->resourceSurvey,$ this->resourceTitle,$surveyTitle));32 $this->model->add(new Statement($this->resourceSurvey,$predicateTitle,$surveyTitle)); 36 33 34 $predicateDescription = new Resource(DESCRIPTION); 37 35 $surveyDescription = new Literal($sDescription); 38 $this->model->add(new Statement($this->resourceSurvey,$this->resourceDescription,$surveyDescription)); 36 $this->model->add(new Statement($this->resourceSurvey,$predicateDescription,$surveyDescription)); 37 } 38 39 public function addQuestion($qTitle,$qDescription,$qType,$qAnswers) 40 { 41 $resourceQuestion = new Resource(QUESTION); 42 $predicateQuestion = new Resource(HAS_QUESTION); 43 $this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$resourceQuestion)); 44 45 $predicateTitle = new Resource(TITLE); 46 $questionTitle = new Literal($qTitle); 47 $this->model->add(new Statement($resourceQuestion,$predicateTitle,$questionTitle)); 48 49 $predicateDescription = new Resource(DESCRIPTION); 50 $questionDescription = new Literal($qDescription); 51 $this->model->add(new Statement($resourceQuestion,$predicateDescription,$questionDescription)); 52 53 $predicateType = new Resource(TYPE); 54 $resourceQuestionType = new Resource(QUESTION_TYPE); 55 $this->model->add(new Statement($resourceQuestion,$predicateType,$resourceQuestionType)); 56 57 foreach($qAnswers as $answer) 58 { 59 $resourceAnswer = new Resource(ANSWER); 60 $predicateAnswer = new Resource(HAS_ANSWER); 61 $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$resourceAnswer)); 62 63 $predicateTitle = new Resource(TITLE); 64 $answerTitle = new Literal($answer['Title']); 65 $this->model->add(new Statement($resourceAnswer,$predicateTitle,$answerTitle)); 66 67 $predicateDescription = new Resource(DESCRIPTION); 68 $answerDescription = new Literal($answer['Description']); 69 $this->model->add(new Statement($resourceAnswer,$predicateDescription,$answerDescription)); 70 71 } 72 73 39 74 } 40 75 -
Dev/trunk/rdfConstants.php
r14 r16 20 20 define('DESCRIPTION',SURVEYTOOL_PREDICATES_NAMESPACE . 'description'); 21 21 define('TYPE',SURVEYTOOL_PREDICATES_NAMESPACE . 'type'); 22 define('HAS_QUESTION',SURVEYTOOL_PREDICATES_NAMESPACE . 'has_question'); 23 define('HAS_ANSWER',SURVEYTOOL_PREDICATES_NAMESPACE . 'has_answer'); 22 24 define('NUMBER_OF_ANSWERS',SURVEYTOOL_PREDICATES_NAMESPACE . 'number_of_answers'); 23 25 define('SCALE',SURVEYTOOL_PREDICATES_NAMESPACE . 'scale'); -
Dev/trunk/submitsurvey.php
r14 r16 25 25 26 26 foreach($result as $line){ 27 $value = $line['? surveyTitle'];27 $value = $line['?title']; 28 28 if($value != "") 29 29 echo $value->toString()."<br/>"; … … 35 35 36 36 foreach($result2 as $line){ 37 $value = $line['? surveyDescription'];37 $value = $line['?description']; 38 38 if($value != "") 39 39 echo $value->toString()."<br/>";
Note: See TracChangeset
for help on using the changeset viewer.