tempModel = $factory->getDefaultModel(); $this->answerPath = 'data/surveys/answers_'.$this->surveyUID; } public function loadSurvey() { parent::loadSurvey(); } public function getAnswerByQuestion($questionID) { $this->tempModel->loadModel($this->model); $answers = array(); if($handle = opendir($this->answerPath)) { while (false !== ($file = readdir($handle))) { if(strstr($file, 'answer_')) $answers[] = substr($file,0,strlen($file)-4); } } foreach($answers as $answer) { $this->tempModel->load($this->answerPath.'/'.$answer); } $this->tempModel->visualize(); $querystring = ' PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> SELECT ?answered WHERE { _question predicates:resource_type resources:question ; predicates:uid "'.$questionID.'" ; predicates:answered ?answered }'; $result = $this->tempModel->sparqlQuery($querystring); $this->tempModel->close(); $this->tempModel->visualize(); return $result; } public function getAnswerByRespondent($respondentID) { $this->tempModel->loadModel($this->model); $this->tempModel->load($this->answerPath . '/$answer_' . $respondentID); $this->tempModel->visualize(); $querystring = ' PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> SELECT ?answered WHERE { _question predicates:resource_type resources:question ; predicates:answered ?answered }'; $result = $this->tempModel->sparqlQuery($querystring); $this->tempModel->close(); $this->tempModel->visualize(); return $result; } public function getAnswerByRespondentAndQuestion($respondentID,$questionID) { $this->tempModel->loadModel($this->model); $this->tempModel->load($this->answerPath . '/$answer_' . $respondentID); $this->tempModel->visualize(); $querystring = ' PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> SELECT ?answered WHERE { _question predicates:resource_type resources:question ; predicates:uid "'.$questionID.'" ; predicates:answered ?answered }'; $result = $this->tempModel->sparqlQuery($querystring); $this->tempModel->close(); $this->tempModel->visualize(); return $result; } } ?>