[12] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | class SurveyRDFReader
|
---|
| 4 | {
|
---|
| 5 | var $model;
|
---|
[26] | 6 |
|
---|
| 7 | var $surveyUID;
|
---|
| 8 |
|
---|
| 9 | public function __construct($surveyUID)
|
---|
| 10 | {
|
---|
[12] | 11 | // Create empty MemModel
|
---|
| 12 | $factory = new ModelFactory();
|
---|
[26] | 13 | $this->model = $factory->getDefaultModel();
|
---|
| 14 |
|
---|
| 15 | $this->surveyUID = $surveyUID;
|
---|
[12] | 16 | }
|
---|
| 17 |
|
---|
[26] | 18 | public function loadSurvey()
|
---|
[12] | 19 | {
|
---|
[26] | 20 | $this->model->load('surveys/'.$this->surveyUID.'.rdf');
|
---|
[12] | 21 | }
|
---|
| 22 |
|
---|
[26] | 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()
|
---|
[12] | 35 | {
|
---|
| 36 | $querystring = '
|
---|
[26] | 37 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
|
---|
[16] | 38 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
|
---|
[26] | 39 | SELECT ?title ?description
|
---|
| 40 | WHERE
|
---|
| 41 | {
|
---|
| 42 | _survey predicates:resource_type resources:survey ;
|
---|
| 43 | predicates:title ?title ;
|
---|
| 44 | predicates:description ?description
|
---|
| 45 | }';
|
---|
[12] | 46 |
|
---|
| 47 | $result = $this->model->sparqlQuery($querystring);
|
---|
[26] | 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 | }';
|
---|
| 74 |
|
---|
| 75 | $result = $this->model->sparqlQuery($querystring);
|
---|
[12] | 76 |
|
---|
| 77 | return $result;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
[26] | 80 | public function readSurveyQuestionsDescription()
|
---|
[12] | 81 | {
|
---|
| 82 | $querystring = '
|
---|
[26] | 83 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
|
---|
[16] | 84 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
|
---|
[26] | 85 | SELECT ?questionDescription
|
---|
| 86 | WHERE
|
---|
| 87 | {
|
---|
| 88 | _question predicates:resource_type resources:question ;
|
---|
| 89 | predicates:description ?questionDescription
|
---|
| 90 | }';
|
---|
[12] | 91 |
|
---|
| 92 | $result = $this->model->sparqlQuery($querystring);
|
---|
| 93 |
|
---|
| 94 | return $result;
|
---|
| 95 | }
|
---|
[26] | 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 | }';
|
---|
| 144 |
|
---|
| 145 | $result = $this->model->sparqlQuery($querystring);
|
---|
| 146 |
|
---|
| 147 | return $result;
|
---|
| 148 | }
|
---|
[12] | 149 | }
|
---|
| 150 |
|
---|
| 151 | ?>
|
---|