Index: Dev/trunk/classes/SurveyAnswerRDFReader.php
===================================================================
--- Dev/trunk/classes/SurveyAnswerRDFReader.php	(revision 51)
+++ Dev/trunk/classes/SurveyAnswerRDFReader.php	(revision 62)
@@ -1,120 +1,113 @@
 <?php
 
-class SurveyAnswerRDFReader extends SurveyRDFReader
+class SurveyAnswerRDFReader
 {	
-	protected $tempModel;
-	protected $answerPath;
-	
-    public function __construct($surveyUID)
+    protected $model;
+    protected $filePath;
+
+    public function __construct($surveyUID,$sessionID)
     {
-        parent::__construct($surveyUID);
-		
-		// Create empty MemModel
-		$factory = new ModelFactory();
-		$this->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();		
+        // Create empty MemModel
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+        $this->filePath = 'data/surveys/survey_'.$surveyUID . '.rdf';
+        
+        $this->model->load($this->filePath);
+    }
 
-		$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();		
+    public function loadAnsers($userID)
+    {
+        $this->model->load($this->filePath.'/answer_'.$this->userUID.'.rdf');
+    }
 
-		$this->tempModel->visualize();
-				
-		return $result;
-	}
+    public function getAnswers()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?answered 
+            WHERE 	
+            {
+                    _answer        predicates:answered 		?answered 	
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function getAnswerByQuestionID($questionID)
+    {
+        $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->model->sparqlQuery($querystring);
+
+        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;
+    }
 }
 
