Last change
on this file since 35 was
31,
checked in by basvannuland, 14 years ago
|
new classes for survey answers writing and reading
added idtags as part of info
|
File size:
1.1 KB
|
Rev | Line | |
---|
[31] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | class SurveyAnswerRDFReader extends SurveyRDFReader
|
---|
| 4 | {
|
---|
| 5 | public function __construct($surveyUID)
|
---|
| 6 | {
|
---|
| 7 | parent::__construct($surveyUID);
|
---|
| 8 | }
|
---|
| 9 |
|
---|
| 10 | public function loadSurvey()
|
---|
| 11 | {
|
---|
| 12 | parent::loadSurvey();
|
---|
| 13 | $answerPath = 'surveys/answers_'.$this->surveyUID;
|
---|
| 14 | $answers = array();
|
---|
| 15 |
|
---|
| 16 | if($handle = opendir('$answerPath'))
|
---|
| 17 | {
|
---|
| 18 | while (false !== ($file = readdir($handle))) {
|
---|
| 19 | if(strstr($file, 'answer_'))
|
---|
| 20 | $answers[] = substr($file,0,strlen($file)-4);
|
---|
| 21 | }
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | foreach($answers as $answer)
|
---|
| 25 | {
|
---|
| 26 | $this->model->load($answerPath.'/'.$answer);
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | public function getAnswer($questionID)
|
---|
| 31 | {
|
---|
| 32 | $querystring = '
|
---|
| 33 | PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
|
---|
| 34 | PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
|
---|
| 35 | SELECT ?answered
|
---|
| 36 | WHERE
|
---|
| 37 | {
|
---|
| 38 | _question predicates:resource_type resources:question ;
|
---|
| 39 | predicates:uid "'.$questionID.'" ;
|
---|
| 40 | predicates:answered ?answered
|
---|
| 41 | }';
|
---|
| 42 |
|
---|
| 43 | $result = $this->model->sparqlQuery($querystring);
|
---|
| 44 |
|
---|
| 45 | return $result;
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.