Index: Dev/trunk/classes/ApplicationDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/ApplicationDatabaseInterface.php	(revision 61)
+++ Dev/trunk/classes/ApplicationDatabaseInterface.php	(revision 62)
@@ -11,47 +11,54 @@
 class ApplicationDatabaseInterface
 {		
-	protected $applicationRDFWriter;
-	protected $applicationRDFReader;
- 
+    protected $applicationRDFWriter;
+    protected $applicationRDFReader;
 
-    public function __construct($surveyID)
-    {
-		if($surveyID == null)
-			$surveyUID = md5( uniqid(rand(), true) );
-		else
-			$surveyUID = $surveyID;
-					
-		$this->applicationRDFWriter = new ApplicationRDFWriter();
-		$this->applicationRDFReader = new ApplicationRDFReader();
+
+    public function __construct()
+    {					
+        $this->applicationRDFWriter = new ApplicationRDFWriter();
+        $this->applicationRDFReader = new ApplicationRDFReader();
     }
 
-	public function setApplicationInfo($application)
-	{
-		$aTitle = $application['applicationTitle'];
-		$aDescription = $application['applicationDescription'];
-		$aStyle	= $application['applicationStyle'];
-		
-		$this->applicationRDFWriter->setApplicationInfo($aTitle, $aDescription, $aStyle);
-		
-		$this->applicationRDFWriter->saveApplications();
-	}
-	
-	public function getApplicationInfo()
-	{
-		$applicationInfo = array();
-		
-		$resultApplication = $this->applicationRDFReader->readAllApplications();
-		
-		for($aNumber = 0;$aNumber<=sizeof($resultApplication[0]);$aNumber++)
-		{
-			$applicationInfo['applicationID'] = substr($resultSurvey[0][$aNumber]['?uid'],9,strlen($resultSurvey[0][$aNumber]['?uid'])-11);
-			$applicationInfo['applicationTitle'] = substr($resultSurvey[1][$aNumber]['?title'],9,strlen($resultSurvey[0][$aNumber]['?title'])-11);
-			$applicationInfo['applicationDescription'] = substr($resultSurvey[2][$aNumber]['?description'],9,strlen($resultSurvey[0][$aNumber]['?description'])-11);
-			$applicationInfo['applicationStyle'] = substr($resultSurvey[3][$aNumber]['?style'],9,strlen($resultSurvey[0][$aNumber]['?style'])-11);
-		}		
-				
-		return $applicationInfo;
-	}
-	
+    public function setApplicationInfo($applicationInfo)
+    {
+        $appTitle = $application['applicationTitle'];
+        $appDescription = $application['applicationDescription'];
+        $appStyle	= $application['applicationStyle'];
+
+        $this->applicationRDFWriter->setApplicationInfo($appTitle, $appDescription, $appStyle);
+
+        $this->applicationRDFWriter->saveApplications();
+    }
+
+    public function getApplicationInfo($applicationID)
+    {
+        $applicationInfo = array();
+
+        $resultApplication = $this->applicationRDFReader->getApplicationInfo($applicationID);
+
+        $applicationInfo['applicationID'] = substr($resultApplication['?uid'],9,strlen($resultApplication['?uid'])-11);
+        $applicationInfo['applicationTitle'] = substr($resultApplication['?title'],9,strlen($resultApplication['?title'])-11);
+        $applicationInfo['applicationDescription'] = substr($resultApplication['?description'],9,strlen($resultApplication['?description'])-11);
+        $applicationInfo['applicationStyle'] = substr($resultApplication['?style'],9,strlen($resultApplication['?style'])-11);
+
+        return $applicationInfo;
+    }
+
+    public function getExistingApplications()
+    {
+        $applicationInfo = array();
+
+        $resultApplication = $this->applicationRDFReader->readAllApplications();
+
+        for($aNumber = 0;$aNumber<=sizeof($resultApplication[0]);$aNumber++)
+        {
+            $aID = substr($resultSurvey[0][$aNumber]['?uid'],9,strlen($resultSurvey[0][$aNumber]['?uid'])-11);
+            $aTitle = substr($resultSurvey[1][$aNumber]['?title'],9,strlen($resultSurvey[0][$aNumber]['?title'])-11);
+            $applicationInfo[$aID] = $aTitle;
+        }		
+
+        return $applicationInfo;
+    }
 }
 ?>
Index: Dev/trunk/classes/ApplicationRDFReader.php
===================================================================
--- Dev/trunk/classes/ApplicationRDFReader.php	(revision 61)
+++ Dev/trunk/classes/ApplicationRDFReader.php	(revision 62)
@@ -3,116 +3,116 @@
 class ApplicationRDFReader
 {
-	protected $model;
-			
+    protected $model;
+
     public function __construct()
     {
-        // Create empty MemModel
-		$factory = new ModelFactory();
-		$this->model = $factory->getDefaultModel();
-		
-		$fileName = 'data/applications/applications.rdf';
-		
-		if(file_exists($fileName))
-			$this->model->load($fileName);
+    // Create empty MemModel
+    $factory = new ModelFactory();
+    $this->model = $factory->getDefaultModel();
+
+    $fileName = 'data/applications/applications.rdf';
+
+    if(file_exists($fileName))
+        $this->model->load($fileName);
     }
-	
-	public function readApplicationInfo($applicationID)
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?title ?description ?style
-			WHERE 	
-			{
-				_application	predicates:resource_type	resources:application ;
-								predicates:uid				"' . $applicationID . '"	;
-								predicates:title 			?title 	;
-								prdeicates:description		?description	;
-								predicates:style			?style
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-				
-		return $result;
-	}
-	
-	public function readAllApplications()
-	{
-		$result = array();
-		$result[] = $this->readApplicationIDs();
-		$result[] = $this->readApplicationTitles();				
-		$result[] = $this->readApplicationDescriptions();
-		$result[] = $this->readApplicationStyles();
-		
-		return $restult;
-	}
-	
-	public function readApplicationIDs()
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?uid
-			WHERE 	
-			{
-				_application	predicates:resource_type	resources:application ;
-								predicates:uid				?uid
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-				
-		return $result;
-	}
-	
-	public function readApplicationTitles()
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?title
-			WHERE 	
-			{
-				_application	predicates:resource_type	resources:application ;
-								predicates:title 			?title 
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-				
-		return $result;
-	}
-	
-	public function readApplicationDescriptions()
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?description
-			WHERE 	
-			{
-				_application	predicates:resource_type	resources:application ;
-								prdeicates:description		?description	
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-				
-		return $result;
-	}
-	
-	public function readApplicationStyles()
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?style
-			WHERE 	
-			{
-				_application	predicates:resource_type	resources:application ;
-								predicates:style			?style
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-				
-		return $result;
-	}
+
+    public function readApplicationInfo($applicationID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?title ?description ?style
+            WHERE 	
+            {
+                    _application	predicates:resource_type	resources:application ;
+                                        predicates:uid			"' . $applicationID . '"	;
+                                        predicates:title 		?title 	;
+                                        prdeicates:description		?description	;
+                                        predicates:style		?style
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readAllApplications()
+    {
+        $result = array();
+        $result[] = $this->readApplicationIDs();
+        $result[] = $this->readApplicationTitles();				
+        $result[] = $this->readApplicationDescriptions();
+        $result[] = $this->readApplicationStyles();
+
+        return $restult;
+    }
+
+    public function readApplicationIDs()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?uid
+            WHERE 	
+            {
+                    _application	predicates:resource_type	resources:application ;
+                                        predicates:uid			?uid
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readApplicationTitles()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?title
+            WHERE 	
+            {
+                    _application	predicates:resource_type	resources:application ;
+                                        predicates:title 		?title 
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readApplicationDescriptions()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?description
+            WHERE 	
+            {
+                    _application	predicates:resource_type	resources:application ;
+                                        prdeicates:description		?description	
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readApplicationStyles()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?style
+            WHERE 	
+            {
+                    _application	predicates:resource_type	resources:application ;
+                                        predicates:style		?style
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
 }
 
Index: Dev/trunk/classes/ApplicationRDFWriter.php
===================================================================
--- Dev/trunk/classes/ApplicationRDFWriter.php	(revision 61)
+++ Dev/trunk/classes/ApplicationRDFWriter.php	(revision 62)
@@ -3,50 +3,50 @@
 class ApplicationRDFWriter
 {
-	protected $model;
-	protected $fileName = 'data/applications/applications.rdf';
+    protected $model;
+    protected $fileName = 'data/applications/applications.rdf';
 
-	public function __construct($applicationID)
+    public function __construct($applicationID)
     {
         // Create empty MemModel
-		$factory = new ModelFactory();
-		$this->model = $factory->getDefaultModel();
-		
-		$this->applicationID = $applicationID;		
-		
-		if(file_exists($this->fileName))
-			$this->model->load($this->fileName);
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        $this->applicationID = $applicationID;		
+
+        if(file_exists($this->fileName))
+        $this->model->load($this->fileName);
     }	
-	
-	public function saveApplications()
-	{	
-		$this->model->saveAs($fileName,'rdf');
-	}
-	
-	public function setApplicationInfo($aTitle, $aDescription, $aStyle)
-	{
-		$applicationID = md5( uniqid(rand(), true) );
-		
-		$resourceApplication = new Resource(APPLICATION.'/'.$applicationID);
-		
-		$resourceApplicationType = new Resource(APPLICATION);
-		$predicateRType = new Resource(RTYPE);
-		$this->model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType));
-		
-		$literalApplicationID = new Literal($applicationID);
-		$predicateUniqueID = new Resource(UID);
-		$this->model->add(new Statement($resourceApplication,$predicateUniqueID,$literalApplicationID));
-			
-		$applicationTitle = new Literal($aTitle);
-		$predicateTitle = new Resource(TITLE);	
-		$this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle));		
-		
-		$applicationDescription = new Literal($aDescription);
-		$predicateDescription = new Resource(DESCRIPTION);
-		$this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription));		
-		
-		$applicationStyle = new Literal($aStyle);
-		$predicateStyle = new Resource(STYLE);
-		$this->model->add(new Statement($resourceApplication,$predicateStyle,$applicationStyle));		
-	}
+
+    public function saveApplications()
+    {	
+        $this->model->saveAs($fileName,'rdf'); 
+    }
+
+    public function setApplicationInfo($aTitle, $aDescription, $aStyle)
+    {
+        $applicationID = md5( uniqid(rand(), true) );
+
+        $resourceApplication = new Resource(APPLICATION.'/'.$applicationID);
+
+        $resourceApplicationType = new Resource(APPLICATION);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType));
+
+        $literalApplicationID = new Literal($applicationID);
+        $predicateUniqueID = new Resource(UID);
+        $this->model->add(new Statement($resourceApplication,$predicateUniqueID,$literalApplicationID));
+
+        $applicationTitle = new Literal($aTitle);
+        $predicateTitle = new Resource(TITLE);	
+        $this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle));		
+
+        $applicationDescription = new Literal($aDescription);
+        $predicateDescription = new Resource(DESCRIPTION);
+        $this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription));		
+
+        $applicationStyle = new Literal($aStyle);
+        $predicateStyle = new Resource(STYLE);
+        $this->model->add(new Statement($resourceApplication,$predicateStyle,$applicationStyle));
+    }
 }
 
Index: Dev/trunk/classes/SurveyAnswerDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/SurveyAnswerDatabaseInterface.php	(revision 61)
+++ Dev/trunk/classes/SurveyAnswerDatabaseInterface.php	(revision 62)
@@ -1,5 +1,5 @@
 <?php
 
-// Survey class as intermediate for storing data from the site to the RDF database 
+// Survey class as intermediate for storing answer data from the site to the RDF database 
 require_once 'rdfConstants.php';
 
@@ -15,14 +15,39 @@
  
 
-    public function __construct($surveyID,$userID)
+    public function __construct($surveyID,$applicationID)
     {					
-		$this->surveyAnswerRDFWriter = new SurveyAnswerRDFWriter($surveyUID,$userID);
-		$this->surveyAnswerRDFReader = new SurveyAnswerRDFReader($surveyUID);
+		$this->surveyAnswerRDFWriter = new SurveyAnswerRDFWriter($surveyUID,$applicationID);
+		$this->surveyAnswerRDFReader = new SurveyAnswerRDFReader($surveyUID,$applicationID);
     }
+	
+	public function setRespondentInfo($respondentInfo)
+	{
+		$respondentName = $surveyInfo['respondentName'];	
+			
+		$this->surveyAnswerRDFWriter->setRespondentData($respondentName);
+	}
 	
 	public function setSurveyAnswerInfo($surveyInfo)
 	{
-
-	}	
+		
+		$qAnswers = array();
+		$qNumber = 1;
+		while (isset($surveyInfo['questionID'.$qNumber]))
+		{
+			if (isset($surveyInfo['q'.$qNumber.'answered']))
+			{
+				$qAnswers[$surveyInfo['questionID'.$qNumber]] = $surveyInfo['q'.$qNumber.'answered'];
+			}
+			
+			$qNumber++;
+		}
+		
+		$this->surveyAnswerRDFWriter->setAnswers($qAnswers);
+	}
+	
+	public function getSurveyAnswerInfo()
+	{
+		
+	}
 }
 ?>
Index: Dev/trunk/classes/SurveyAnswerRDFReader.php
===================================================================
--- Dev/trunk/classes/SurveyAnswerRDFReader.php	(revision 61)
+++ 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;
+    }
 }
 
Index: Dev/trunk/classes/SurveyAnswerRDFWriter.php
===================================================================
--- Dev/trunk/classes/SurveyAnswerRDFWriter.php	(revision 61)
+++ Dev/trunk/classes/SurveyAnswerRDFWriter.php	(revision 62)
@@ -1,55 +1,58 @@
 <?php
 
-class SurveyAnswerRDFWriter extends SurveyRDFWriter
+class SurveyAnswerRDFWriter
 {
-	protected $userUID;
-	protected $answerPath;
+    protected $userUID;
+    protected $filePath;
 
-	public function __construct($surveyUID,$userUID)
+    public function __construct($surveyUID,$sessionID,$userID)
     {
-        parent::__construct($surveyUID);
-		
-		$this->userUID = $userUID;
-		$this->answerPath = 'data/surveys/answers_'.$this->surveyUID;
+        // Create empty MemModel
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+        
+        $this->filePath = 'data/sessions/' .  $sessionID . '/survey_'.$surveyUID . '/';
+        $this->userID = $userID;
+        
+        if (!is_dir($this->filePath))
+            mkdir($this->filePath);		
     }
-	
-	public function saveSurvey()
-	{	
-		if (!is_dir($this->answerPath))
-			mkdir($this->answerPath);		
-		$this->model->saveAs($this->answerPath.'/answer_'.$this->userUID.'.rdf','rdf');
-	}
-	
-	public function setRespondentData($name)
-	{				
-		$resourceUser = new Resource(USER . '/' . $userID);		
-		
-		$resourceUserType = new Resource(USER);
-		$predicateRType = new Resource(RTYPE);
-		$this->model->add(new Statement($resourceUser,$predicateRType,$resourceUserType));
-		
-		$LiteralUserName = new Literal($name);
-		$predicateName = new Resource(NAME);
-		$this->model->add(new Statement($resourceUser,$predicateUniqueID,$LiteralUserName));		
-		
-		$literalUserID = new Literal($this->userUID);
-		$predicateUniqueID = new Resource(UID);
-		$this->model->add(new Statement($resourceUser,$predicateUniqueID,$literalUserID));
-		
-		$predicateRespondent = new Resource(REPONDENT);
-		$this->model->add(new Statement($this->resourceSurvey,$predicateRespondent,$resourceUser));
-	}
-	
-	public function setAnswers($answers)
-	{
-		foreach($answers as $questionID => $answerValue)
-		{					
-			$resourceQuestion = new Resource(QUESTION.'/'.$questionID);
-						
-			$predicateAnswered = new Resource(ANSWERED);	
-			$answer = new Literal($answerValue);
-			$this->model->add(new Statement($resourceQuestion,$predicateAnswered,$answer));
-		}
-	}
+
+    public function saveSurvey()
+    {		
+        $this->model->saveAs($this->filePath.'/answer_'.$this->userUID.'.rdf','rdf');
+    }
+
+    public function setRespondentData($name)
+    {				
+        $resourceUser = new Resource(USER . '/' . $this->userID);		
+
+        $resourceUserType = new Resource(USER);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceUser,$predicateRType,$resourceUserType));
+
+        $LiteralUserName = new Literal($name);
+        $predicateName = new Resource(NAME);
+        $this->model->add(new Statement($resourceUser,$predicateUniqueID,$LiteralUserName));		
+
+        $literalUserID = new Literal($this->userUID);
+        $predicateUniqueID = new Resource(UID);
+        $this->model->add(new Statement($resourceUser,$predicateUniqueID,$literalUserID));
+
+        $predicateRespondent = new Resource(REPONDENT);
+        $this->model->add(new Statement($this->resourceSurvey,$predicateRespondent,$resourceUser));
+    }
+
+    public function setAnswers($answers)
+    {
+        foreach($answers as $questionID => $answerValue)
+        {					
+            $resourceQuestion = new Resource(QUESTION.'/'.$questionID);
+
+            $predicateAnswered = new Resource(ANSWERED);	
+            $answer = new Literal($answerValue);
+            $this->model->add(new Statement($resourceQuestion,$predicateAnswered,$answer));
+        }
+    }
 }
 
Index: Dev/trunk/classes/SurveyDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/SurveyDatabaseInterface.php	(revision 61)
+++ Dev/trunk/classes/SurveyDatabaseInterface.php	(revision 62)
@@ -10,110 +10,115 @@
 class SurveyDatabaseInterface
 {		
-	protected $surveyRDFWriter;
-	protected $surveyRDFReader;
- 
+    protected $surveyRDFWriter;
+    protected $surveyRDFReader;
+
 
     public function __construct($surveyID)
     {
-		if($surveyID == null)
-			$surveyUID = md5( uniqid(rand(), true) );
-		else
-			$surveyUID = $surveyID;
-					
-		$this->surveyRDFWriter = new SurveyRDFWriter($surveyUID);
-		$this->surveyRDFReader = new SurveyRDFReader($surveyUID);
+        if($surveyID == null)
+            $surveyUID = md5( uniqid(rand(), true) );
+        else
+            $surveyUID = $surveyID;
+
+        $this->surveyRDFWriter = new SurveyRDFWriter($surveyUID);
+        $this->surveyRDFReader = new SurveyRDFReader($surveyUID);
     }
-	
-	public function setSurveyInfo($survey)
-	{
-		$sTitle = $survey['surveyTitle'];
-		$sDescription = $survey['surveyDescription'];
-		
-		$this->surveyRDFWriter->createSurvey($sTitle,$sDescription);
-		
-		$qNumber = 1;
-		while (isset($survey['questionTitle'.$qNumber]))
-		{
-			$qTitle = $survey['questionTitle'.$qNumber];
-			$qDescription = $survey['questionDescription'.$qNumber];
-			$qType = $survey['questionType'.$qNumber];
-			if (isset($survey['questionID'.$qNumber]))
-				$qID = $survey['questionID'.$qNumber];
-			else
-				$qID = md5( uniqid(rand(), true) );
-			
-			$qAnswers = array();
-			$aNumber = 1;
-			while (isset($survey['q'.$qNumber.'ans'.$aNumber]))
-			{
-				$aArray = array();
-				$aArray['Title'] = $survey['q'.$qNumber.'ans'.$aNumber];
-				$aArray['Description'] = 'answerDescription'.$aNumber;
-				$qAnswers[] = $aArray;
-				
-				$aNumber++;
-			}
-			
-			$this->surveyRDFWriter->addQuestion($qTitle,$qDescription,$qType,$qID,$qAnswers);
-			
-			$qNumber++;
-		}
 
-		$this->surveyRDFWriter->saveSurvey();
-	}
-	
-	public function getSurveyInfo()
-	{
-		$surveyInfo = array();
-		
-		$resultSurvey = $this->surveyRDFReader->getSurveyInfo();
-		
-		$surveyInfo['surveyID'] = substr($resultSurvey[0][0]['?uid'],9,strlen($resultSurvey[0][0]['?uid'])-11);
-		$surveyInfo['surveyTitle'] = substr($resultSurvey[0][0]['?title'],9,strlen($resultSurvey[0][0]['?title'])-11);
-		$surveyInfo['surveyDescription'] = substr($resultSurvey[0][0]['?description'],9,strlen($resultSurvey[0][0]['?description'])-11);
-									
-		for($qNumber = 1;$qNumber<=sizeof($resultSurvey[1][0]);$qNumber++)
-		{
-			$surveyInfo['questionID'.$qNumber] = substr($resultSurvey[1][3][$qNumber-1]['?questionID'],9,strlen($resultSurvey[1][3][$qNumber-1]['?questionID'])-11);
-			$surveyInfo['questionTitle'.$qNumber] = substr($resultSurvey[1][0][$qNumber-1]['?questionTitle'],9,strlen($resultSurvey[1][0][$qNumber-1]['?questionTitle'])-11);
-			$surveyInfo['questionDescription'.$qNumber] = substr($resultSurvey[1][1][$qNumber-1]['?questionDescription'],9,strlen($resultSurvey[1][1][$qNumber-1]['?questionDescription'])-11);
-			$surveyInfo['questionType'.$qNumber] = substr($resultSurvey[1][2][$qNumber-1]['?questionType'],9,strlen($resultSurvey[1][2][$qNumber-1]['?questionType'])-11);
-						
-			$resultAnswers = $this->surveyRDFReader->readSurveyAnswers($surveyInfo['questionID'.$qNumber]);
-						
-			if ($resultAnswers != null)
-			{
-				for($aNumber = 1;$aNumber<=sizeof($resultAnswers);$aNumber++)
-				{
-					$surveyInfo['q'.$qNumber.'ans'.$aNumber] = substr($resultAnswers[$aNumber-1]['?answerTitle'],9,strlen($resultAnswers[$aNumber-1]['?answerTitle'])-11);
-				}
-			}
-		}
-		
-		return $surveyInfo;
-	}
+    public function setSurveyInfo($survey)
+    {
+        $sTitle = $survey['surveyTitle'];
+        $sDescription = $survey['surveyDescription'];
 
-	public function getExistingSurveys()
-	{
-		$surveyIDs = array();
-		$surveys = array();
-	
-		if($handle = opendir('data/surveys/'))
-		{
-			while (false !== ($file = readdir($handle))) {
-				if(strstr($file, 'survey_'))
-					$surveyIDs[] = substr($file,7,strlen($file)-11);
-			}
-		}
-		
-		foreach($surveyIDs as $surveyID)
-		{
-			$surveyTitle = $this->surveyRDFReader->getSurveyTitleByID($surveyID);
-			$surveys[$surveyID] = substr($surveyTitle[0]['?title'],9,strlen($surveyTitle[0]['?title'])-11);
-		}
-		
-		return $surveys;
-	}
-	
+        $this->surveyRDFWriter->createSurvey($sTitle,$sDescription);
+
+        $sUserID = "Creator";
+
+        $this->surveyRDFWriter->setUserData($sUserID);
+
+        $qNumber = 1;
+        while (isset($survey['questionTitle'.$qNumber]))
+        {
+            $qTitle = $survey['questionTitle'.$qNumber];
+            $qDescription = $survey['questionDescription'.$qNumber];
+            $qType = $survey['questionType'.$qNumber];
+            if (isset($survey['questionID'.$qNumber]))
+                $qID = $survey['questionID'.$qNumber];
+            else
+                $qID = md5( uniqid(rand(), true) );
+
+            $qAnswers = array();
+            $aNumber = 1;
+            while (isset($survey['q'.$qNumber.'ans'.$aNumber]))
+            {
+                $aArray = array();
+                $aArray['Title'] = 'q'.$qNumber.'ans'.$aNumber;
+                $aArray['Description'] = $survey['q'.$qNumber.'ans'.$aNumber];
+                $qAnswers[] = $aArray;
+
+                $aNumber++;
+            }
+
+            $this->surveyRDFWriter->addQuestion($qTitle,$qDescription,$qType,$qID,$qAnswers);
+
+            $qNumber++;
+        }
+
+        $this->surveyRDFWriter->saveSurvey();
+    }
+
+    public function getSurveyInfo()
+    {
+        $surveyInfo = array();
+
+        $resultSurvey = $this->surveyRDFReader->getSurveyInfo();
+
+        $surveyInfo['surveyID'] = substr($resultSurvey[0][0]['?uid'],9,strlen($resultSurvey[0][0]['?uid'])-11);
+        $surveyInfo['surveyTitle'] = substr($resultSurvey[0][0]['?title'],9,strlen($resultSurvey[0][0]['?title'])-11);
+        $surveyInfo['surveyDescription'] = substr($resultSurvey[0][0]['?description'],9,strlen($resultSurvey[0][0]['?description'])-11);
+        $surveyInfo['surveyCreator'] = substr($resultSurvey[0][0]['?creator'],9,strlen($resultSurvey[0][0]['?creator'])-11);
+
+        for($qNumber = 1;$qNumber<=sizeof($resultSurvey[1][0]);$qNumber++)
+        {
+            $surveyInfo['questionID'.$qNumber] = substr($resultSurvey[1][3][$qNumber-1]['?questionID'],9,strlen($resultSurvey[1][3][$qNumber-1]['?questionID'])-11);
+            $surveyInfo['questionTitle'.$qNumber] = substr($resultSurvey[1][0][$qNumber-1]['?questionTitle'],9,strlen($resultSurvey[1][0][$qNumber-1]['?questionTitle'])-11);
+            $surveyInfo['questionDescription'.$qNumber] = substr($resultSurvey[1][1][$qNumber-1]['?questionDescription'],9,strlen($resultSurvey[1][1][$qNumber-1]['?questionDescription'])-11);
+            $surveyInfo['questionType'.$qNumber] = substr($resultSurvey[1][2][$qNumber-1]['?questionType'],9,strlen($resultSurvey[1][2][$qNumber-1]['?questionType'])-11);
+
+            $resultAnswers = $this->surveyRDFReader->readSurveyAnswers($surveyInfo['questionID'.$qNumber]);
+
+            if ($resultAnswers != null)
+            {
+                for($aNumber = 1;$aNumber<=sizeof($resultAnswers);$aNumber++)
+                {
+                    $surveyInfo['q'.$qNumber.'ans'.$aNumber] = substr($resultAnswers[$aNumber-1]['?answerDescription'],9,strlen($resultAnswers[$aNumber-1]['?answerDescription'])-11);
+                }
+            }
+        }
+
+        return $surveyInfo;
+    }
+
+    public function getExistingSurveys()
+    {
+        $surveyIDs = array();
+        $surveys = array();
+
+        if($handle = opendir('data/surveys/'))
+        {
+            while (false !== ($file = readdir($handle))) {
+                if(strstr($file, 'survey_') && strstr($file, '.rdf'))
+                    $surveyIDs[] = substr($file,7,strlen($file)-11);
+            }
+        }
+
+        foreach($surveyIDs as $surveyID)
+        {
+            $surveyTitle = $this->surveyRDFReader->getSurveyTitleByID($surveyID);
+            $surveys[$surveyID] = substr($surveyTitle[0]['?title'],9,strlen($surveyTitle[0]['?title'])-11);
+        }
+
+        return $surveys;
+    }
+
 }
 ?>
Index: Dev/trunk/classes/SurveyRDFReader.php
===================================================================
--- Dev/trunk/classes/SurveyRDFReader.php	(revision 61)
+++ Dev/trunk/classes/SurveyRDFReader.php	(revision 62)
@@ -3,175 +3,174 @@
 class SurveyRDFReader
 {
-	protected $model;
-	
-	protected $surveyUID;
-	protected $filePath;
-	
+    protected $model;
+
+    protected $surveyUID;
+    protected $filePath;
+
     public function __construct($surveyUID)
     {
         // Create empty MemModel
-		$factory = new ModelFactory();
-		$this->model = $factory->getDefaultModel();
-		
-		$this->surveyUID = $surveyUID;
-		$this->filePath = 'data/surveys/survey_'.$this->surveyUID.'.rdf';
-	}
-	
-	public function loadSurvey()
-	{
-		$this->model->load($this->filePath);
-	}
-	
-	public function getSurveyInfo()
-	{		
-		SurveyRDFReader::loadSurvey();
-	
-		$result = array();
-		$result[] = $this->readSurveyInfo();				
-		$result[] = $this->readSurveyQuestions();
-		
-		return $result;
-	}
-	
-	public function readSurveyInfo()
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?uid ?title ?description 
-			WHERE 	
-			{
-				_survey		predicates:resource_type	resources:survey ;
-							predicates:uid				?uid	;
-							predicates:title 			?title 	;
-							predicates:description		?description 
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-				
-		return $result;
-	}
-	
-	public function readSurveyQuestions()
-	{
-		$result = array();
-		$result[] = $this->readSurveyQuestionsTitle();				
-		$result[] = $this->readSurveyQuestionsDescription();
-		$result[] = $this->readSurveyQuestionsType();
-		$result[] = $this->readSurveyQuestionsID();		
-				
-		return $result;
-	}
-	
-	public function readSurveyQuestionsTitle()
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?questionTitle
-			WHERE 
-			{	
-				_question	predicates:resource_type	resources:question ;
-							predicates:title			?questionTitle 		
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-		
-		return $result;
-	}
-	
-	public function readSurveyQuestionsDescription()
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?questionDescription
-			WHERE 
-			{	
-				_question	predicates:resource_type	resources:question ;
-							predicates:description		?questionDescription 		
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-		
-		return $result;
-	}
-	
-	public function readSurveyQuestionsType()
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?questionType
-			WHERE 
-			{	
-				_question	predicates:resource_type	resources:question ;
-							predicates:question_type	?questionType				
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-		
-		return $result;
-	}
-	
-	public function readSurveyQuestionsID()
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?questionID
-			WHERE 
-			{	
-				_question	predicates:resource_type	resources:question ;
-							predicates:uid				?questionID				
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-		
-		return $result;
-	}
-	
-	public function readSurveyAnswers($questionID)
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?answerTitle
-			WHERE 
-			{
-				_question		predicates:resource_type	resources:question ;
-								predicates:uid				"' . $questionID . '"  ;
-								predicates:has_answer		_answer .
-				_answer			predicates:title			?answerTitle								
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-		
-		return $result;
-	}
-	
-	public function getSurveyTitleByID($surveyID)
-	{
-		
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        $this->surveyUID = $surveyUID;
+        $this->filePath = 'data/surveys/survey_'.$this->surveyUID.'.rdf';
+    }
+
+    public function loadSurvey()
+    {
+     $this->model->load($this->filePath);
+    }
+
+    public function getSurveyInfo()
+    {		
+        SurveyRDFReader::loadSurvey();
+
+        $result = array();
+        $result[] = $this->readSurveyInfo();				
+        $result[] = $this->readSurveyQuestions();
+
+        return $result;
+    }
+
+    public function readSurveyInfo()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?uid ?title ?description ?creator
+            WHERE 	
+            {
+                    _survey	predicates:resource_type	resources:survey ;
+                                predicates:uid			?uid	;
+                                predicates:title 		?title 	;
+                                predicates:description		?description ;
+                                predicates:creator		?creator
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readSurveyQuestions()
+    {
+        $result = array();
+        $result[] = $this->readSurveyQuestionsTitle();				
+        $result[] = $this->readSurveyQuestionsDescription();
+        $result[] = $this->readSurveyQuestionsType();
+        $result[] = $this->readSurveyQuestionsID();		
+
+        return $result;
+    }
+
+    public function readSurveyQuestionsTitle()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionTitle
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:title		?questionTitle 		
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readSurveyQuestionsDescription()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionDescription
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:description		?questionDescription 		
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readSurveyQuestionsType()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionType
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:question_type	?questionType				
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readSurveyQuestionsID()
+    {
+        $querystring = '
+            PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT 	?questionID
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			?questionID				
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readSurveyAnswers($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?answerDescription
+            WHERE 
+            {
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:has_answer		_answer .
+                    _answer	predicates:description		?answerDescription
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function getSurveyTitleByID($surveyID)
+    {
         // Create empty MemModel
-		$factory = new ModelFactory();
-		$tempmodel= $factory->getDefaultModel();
-		$tempmodel->load('data/surveys/survey_'.$surveyID.'.rdf');
-		
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?title 
-			WHERE 	
-			{
-				_survey		predicates:resource_type	resources:survey ;
-							predicates:title 			?title 	
-			}';
-			
-		$result = $tempmodel->sparqlQuery($querystring);
-				
-		return $result;
-	}
+        $factory = new ModelFactory();
+        $tempmodel= $factory->getDefaultModel();
+        $tempmodel->load('data/surveys/survey_'.$surveyID.'.rdf');
+
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?title 
+            WHERE 	
+            {
+                    _survey     predicates:resource_type	resources:survey ;
+                                predicates:title 		?title 	
+            }';
+
+        $result = $tempmodel->sparqlQuery($querystring);
+
+        return $result;
+    }
 }
-
 ?>
Index: Dev/trunk/classes/SurveyRDFWriter.php
===================================================================
--- Dev/trunk/classes/SurveyRDFWriter.php	(revision 61)
+++ Dev/trunk/classes/SurveyRDFWriter.php	(revision 62)
@@ -3,114 +3,108 @@
 class SurveyRDFWriter 
 {
-	protected $model;
-		
-	protected $resourceSurvey;
-	protected $surveyUID;
-	protected $filePath;
-	
+    protected $model;
+
+    protected $resourceSurvey;
+    protected $surveyUID;
+
+    protected $filePath;
+
     public function __construct($surveyUID)
     {
         // Create empty MemModel
-		$factory = new ModelFactory();
-		$this->model = $factory->getDefaultModel();
-		
-		$this->surveyUID = $surveyUID;
-		$this->filePath = 'data/surveys/survey_'.$this->surveyUID.'.rdf';
-		
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        $this->surveyUID = $surveyUID;	
+        $this->filePath = 'data/surveys/';
+        if (!is_dir($this->filePath))
+            mkdir($this->filePath);	
     }	
-	
-	public function saveSurvey()
-	{	
-		$this->model->saveAs($this->filePath);
-	}
-	
-	public function createSurvey($sTitle, $sDescription)
-	{		
-		$this->resourceSurvey = new Resource(SURVEY.'/'.$this->surveyUID);
-		
-		$resourceSurveyType = new Resource(SURVEY);
-		$predicateRType = new Resource(RTYPE);
-		$this->model->add(new Statement($this->resourceSurvey,$predicateRType,$resourceSurveyType));
-		
-		$literalSurveyID = new Literal($this->surveyUID);
-		$predicateUniqueID = new Resource(UID);
-		$this->model->add(new Statement($this->resourceSurvey,$predicateUniqueID,$literalSurveyID));
-		
-		$predicateTitle = new Resource(TITLE);		
-		$surveyTitle = new Literal($sTitle);
-		$this->model->add(new Statement($this->resourceSurvey,$predicateTitle,$surveyTitle));		
-		
-		$predicateDescription = new Resource(DESCRIPTION);
-		$surveyDescription = new Literal($sDescription);
-		$this->model->add(new Statement($this->resourceSurvey,$predicateDescription,$surveyDescription));		
-	}
-	
-	public function setUserData($userID)
-	{				
-		$resourceUser = new Resource(USER . '/' . $userID);
-				
-		$predicateCreator = new Resource(CREATOR);
-		$this->model->add(new Statement($this->resourceSurvey,$predicateCreator,$resourceUser));
-	}
-	
-	public function setApplicationData($applicationID)
-	{
-		$resourceApplication = new Resource(APPLICATION . '/' . $applicationID);
-				
-		$predicatePartOf = new Resource(PART_OF);
-		$this->model->add(new Statement($this->resourceSurvey,$predicatePartOf,$resourceApplication));
-	}
-	
-	public function addQuestion($qTitle,$qDescription,$qType,$qID,$qAnswers)
-	{
-		$questionID = $qID;
-		$resourceQuestion = new Resource(QUESTION.'/'.$questionID);
-				
-		$resourceQuestionType = new Resource(QUESTION);
-		$predicateRType = new Resource(RTYPE);
-		$this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
-				
-		$predicateUniqueID = new Resource(UID);
-		$questionUID = new Literal($questionID);
-		$this->model->add(new Statement($resourceQuestion,$predicateUniqueID,$questionUID));
-				
-		$predicateTitle = new Resource(TITLE);		
-		$questionTitle = new Literal($qTitle);
-		$this->model->add(new Statement($resourceQuestion,$predicateTitle,$questionTitle));	
-		
-		$predicateDescription = new Resource(DESCRIPTION);
-		$questionDescription = new Literal($qDescription);
-		$this->model->add(new Statement($resourceQuestion,$predicateDescription,$questionDescription));		
-		
-		$predicateQType = new Resource(QTYPE);
-		$resourceQuestionType = new Literal($qType);
-		$this->model->add(new Statement($resourceQuestion,$predicateQType,$resourceQuestionType));
-		
-		foreach($qAnswers as $answer)
-		{		
-			$answerID = md5( uniqid(rand(), true) );	
-			$resourceAnswer = new Resource(ANSWER.'/'.$answerID);
-				
-			$resourceAnswerType = new Resource(ANSWER);
-			$predicateRType = new Resource(RTYPE);
-			$this->model->add(new Statement($resourceAnswer,$predicateRType,$resourceAnswerType));	
 
-			$predicateUniqueID = new Resource(UID);
-			$answerUID = new Literal($answerID);
-			$this->model->add(new Statement($resourceAnswer,$predicateUniqueID,$answerUID));			
-						
-			$answerTitle = new Literal($answer['Title']);
-			$this->model->add(new Statement($resourceAnswer,$predicateTitle,$answerTitle));
-			
-			$answerDescription = new Literal($answer['Description']);
-			$this->model->add(new Statement($resourceAnswer,$predicateDescription,$answerDescription));
-			
-			$predicateAnswer = new Resource(HAS_ANSWER);	
-			$this->model->add(new Statement($resourceQuestion,$predicateAnswer,$resourceAnswer));
-		}
-		
-		$predicateQuestion = new Resource(HAS_QUESTION);
-		$this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$resourceQuestion));		
-	}
+    public function saveSurvey()
+    {	
+        $this->model->saveAs($this->filePath.'survey_'.$this->surveyUID.'.rdf','rdf');
+    }
+
+    public function createSurvey($sTitle, $sDescription)
+    {		
+        $this->resourceSurvey = new Resource(SURVEY.'/'.$this->surveyUID);
+
+        $resourceSurveyType = new Resource(SURVEY);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($this->resourceSurvey,$predicateRType,$resourceSurveyType));
+
+        $literalSurveyID = new Literal($this->surveyUID);
+        $predicateUniqueID = new Resource(UID);
+        $this->model->add(new Statement($this->resourceSurvey,$predicateUniqueID,$literalSurveyID));
+
+        $predicateTitle = new Resource(TITLE);		
+        $surveyTitle = new Literal($sTitle);
+        $this->model->add(new Statement($this->resourceSurvey,$predicateTitle,$surveyTitle));		
+
+        $predicateDescription = new Resource(DESCRIPTION);
+        $surveyDescription = new Literal($sDescription);
+        $this->model->add(new Statement($this->resourceSurvey,$predicateDescription,$surveyDescription));		
+    }
+
+    public function setUserData($userID)
+    {				
+        $resourceUser = new Resource(USER . '/' . $userID);
+
+        $predicateCreator = new Resource(CREATOR);
+        $this->model->add(new Statement($this->resourceSurvey,$predicateCreator,$resourceUser));
+    }
+
+    public function addQuestion($qTitle,$qDescription,$qType,$qID,$qAnswers)
+    {
+        $questionID = $qID;
+        $resourceQuestion = new Resource(QUESTION.'/'.$questionID);
+
+        $resourceQuestionType = new Resource(QUESTION);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
+
+        $predicateUniqueID = new Resource(UID);
+        $questionUID = new Literal($questionID);
+        $this->model->add(new Statement($resourceQuestion,$predicateUniqueID,$questionUID));
+
+        $predicateTitle = new Resource(TITLE);		
+        $questionTitle = new Literal($qTitle);
+        $this->model->add(new Statement($resourceQuestion,$predicateTitle,$questionTitle));	
+
+        $predicateDescription = new Resource(DESCRIPTION);
+        $questionDescription = new Literal($qDescription);
+        $this->model->add(new Statement($resourceQuestion,$predicateDescription,$questionDescription));		
+
+        $predicateQType = new Resource(QTYPE);
+        $resourceQuestionType = new Literal($qType);
+        $this->model->add(new Statement($resourceQuestion,$predicateQType,$resourceQuestionType));
+
+            foreach($qAnswers as $answer)
+            {		
+                $answerID = md5( uniqid(rand(), true) );	
+                $resourceAnswer = new Resource(ANSWER.'/'.$answerID);
+
+                $resourceAnswerType = new Resource(ANSWER);
+                $predicateRType = new Resource(RTYPE);
+                $this->model->add(new Statement($resourceAnswer,$predicateRType,$resourceAnswerType));	
+
+                $predicateUniqueID = new Resource(UID);
+                $answerUID = new Literal($answerID);
+                $this->model->add(new Statement($resourceAnswer,$predicateUniqueID,$answerUID));			
+
+                $answerTitle = new Literal($answer['Title']);
+                $this->model->add(new Statement($resourceAnswer,$predicateTitle,$answerTitle));
+
+                $answerDescription = new Literal($answer['Description']);
+                $this->model->add(new Statement($resourceAnswer,$predicateDescription,$answerDescription));
+
+                $predicateAnswer = new Resource(HAS_ANSWER);	
+                $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$resourceAnswer));
+            }
+
+            $predicateQuestion = new Resource(HAS_QUESTION);
+            $this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$resourceQuestion));		
+        }
 }
 
Index: Dev/trunk/classes/UserDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/UserDatabaseInterface.php	(revision 61)
+++ Dev/trunk/classes/UserDatabaseInterface.php	(revision 62)
@@ -9,69 +9,68 @@
 class UserDatabaseInterface
 {
-	protected $key = 'CPSsecretKey';
-	
-	protected $userRDFWriter;
-	protected $userRDFReader;
-	
-	public function __construct()
-	{
-		$this->userRDFWriter = new UserRDFWriter();
-		$this->userRDFReader = new UserRDFReader();
-	}
-	
-	public function addNewUser($userInfo)
-	{
-		$userName = $userInfo['username'];
-		$userPassword = $this->RIJNDAEL_encrypt($userInfo['password']);
-		
-		$this->userRDFWriter->addNewUser($userName, $userPassword);
-		$this->userRDFWriter->saveUsers();
-	}
-	
-	public function checkUserName($userName)
-	{
-		$result = false;
-		
-		$resultUser = $this->userRDFReader->getUserNames();
-		
-		if ($resultUser != null)
-		{
-			foreach($resultUser as $user)
-			{
-				$name = substr($user['?name'],9,strlen($user['?name'])-11);
-				if(!strcmp($name ,$userName))
-				{
-					$result = true;
-				}
-			}
-		}
-		
-		return $result;
-	}
-	
-	public function checkUserPassword($userInfo)
-	{
-		$result = false;
-	
-		$userName = $userInfo['username'];
-		$userPassword = $userInfo['password'];
-		
-		$encryptedPasswordLiteral = $this->userRDFReader->getUserPassword($userName);
-		$encryptedPassword = substr($encryptedPasswordLiteral[0]['?password'],9,strlen($encryptedPasswordLiteral[0]['?password'])-11);
-				
-		if(!strcmp($this->RIJNDAEL_encrypt($userPassword),$encryptedPassword))
-			$result = true;
-		
-		return $result;
-	}
-	
-	protected function RIJNDAEL_encrypt($text)
-	{
-		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
-		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
-		
-		return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->key, $text, MCRYPT_MODE_ECB, $iv)); 
-	}
+    protected $key = 'CPSsecretKey';
 
+    protected $userRDFWriter;
+    protected $userRDFReader;
+
+    public function __construct()
+    {
+        $this->userRDFWriter = new UserRDFWriter();
+        $this->userRDFReader = new UserRDFReader();
+    }
+
+    public function addNewUser($userInfo)
+    {
+        $userName = $userInfo['username'];
+        $userPassword = $this->RIJNDAEL_encrypt($userInfo['password']);
+
+        $this->userRDFWriter->addNewUser($userName, $userPassword);
+        $this->userRDFWriter->saveUsers();
+    }
+
+    public function checkUserName($userName)
+    {
+        $result = false;
+
+        $resultUser = $this->userRDFReader->getUserNames();
+
+        if ($resultUser != null)
+        {
+            foreach($resultUser as $user)
+            {
+            $name = substr($user['?name'],9,strlen($user['?name'])-11);
+                if(!strcmp($name ,$userName))
+                {
+                    $result = true;
+                }
+            }
+        }
+
+        return $result;
+    }
+
+    public function checkUserPassword($userInfo)
+    {
+        $result = false;
+
+        $userName = $userInfo['username'];
+        $userPassword = $userInfo['password'];
+
+        $encryptedPasswordLiteral = $this->userRDFReader->getUserPassword($userName);
+        $encryptedPassword = substr($encryptedPasswordLiteral[0]['?password'],9,strlen($encryptedPasswordLiteral[0]['?password'])-11);
+
+        if(!strcmp($this->RIJNDAEL_encrypt($userPassword),$encryptedPassword))
+            $result = true;
+
+        return $result;
+    }
+
+    protected function RIJNDAEL_encrypt($text)
+    {
+        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
+        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
+
+        return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->key, $text, MCRYPT_MODE_ECB, $iv)); 
+    }
 }
 
Index: Dev/trunk/classes/UserRDFReader.php
===================================================================
--- Dev/trunk/classes/UserRDFReader.php	(revision 61)
+++ Dev/trunk/classes/UserRDFReader.php	(revision 62)
@@ -3,52 +3,51 @@
 class UserRDFReader
 {
-	protected $model;
-	protected $fileName = 'data/users/users.rdf';
-			
+    protected $model;
+    protected $fileName = 'data/users/users.rdf';
+
     public function __construct()
     {
         // Create empty MemModel
-		$factory = new ModelFactory();
-		$this->model = $factory->getDefaultModel();
-		
-		
-		if(file_exists($this->fileName))
-			$this->model->load($this->fileName);
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        if(file_exists($this->fileName))
+            $this->model->load($this->fileName);
     }
-	
-	public function getUserNames()
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?name 
-			WHERE 	
-			{
-				_user		predicates:resource_type	resources:user ;
-							predicates:name 			?name 	
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-				
-		return $result;
-	}
-	
-	public function getUserPassword($userName)
-	{
-		$querystring = '
-			PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT 	?password 
-			WHERE 	
-			{
-				_user		predicates:resource_type	resources:user ;
-							predicates:name				"' . $userName . '"	;
-							predicates:password			?password
-			}';
-			
-		$result = $this->model->sparqlQuery($querystring);
-				
-		return $result;
-	}
+
+    public function getUserNames()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?name 
+            WHERE 	
+            {
+                    _user	predicates:resource_type	resources:user ;
+                                predicates:name 		?name 	
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function getUserPassword($userName)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?password 
+            WHERE 	
+            {
+                    _user	predicates:resource_type	resources:user ;
+                                predicates:name			"' . $userName . '"	;
+                                predicates:password		?password
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
 }
 
Index: Dev/trunk/classes/UserRDFWriter.php
===================================================================
--- Dev/trunk/classes/UserRDFWriter.php	(revision 61)
+++ Dev/trunk/classes/UserRDFWriter.php	(revision 62)
@@ -3,45 +3,44 @@
 class UserRDFWriter
 {
+    protected $model;
+    protected $fileName = 'data/users/users.rdf';
 
-	protected $model;
-	protected $fileName = 'data/users/users.rdf';
-			
     public function __construct()
     {
         // Create empty MemModel
-		$factory = new ModelFactory();
-		$this->model = $factory->getDefaultModel();
-		
-		if(file_exists($this->fileName))
-			$this->model->load($this->fileName);
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        if(file_exists($this->fileName))
+            $this->model->load($this->fileName);
     }
-	
-	public function saveUsers()
-	{						
-		$this->model->saveAs($this->fileName,'rdf');
-	}
-	
-	public function addNewUser($name,$password)
-	{
-		$userID = md5( uniqid(rand(), true) );
-		
-		$resourceUser = new Resource(USER . '/' . $userID);
-		
-		$resourceUserType = new Resource(USER);
-		$predicateRType = new Resource(RTYPE);
-		$this->model->add(new Statement($resourceUser,$predicateRType,$resourceUserType));
-		
-		$literalUserName = new Literal($name);
-		$predicateName = new Resource(NAME);
-		$this->model->add(new Statement($resourceUser,$predicateName,$literalUserName));	
-		
-		$literalUserID = new Literal($userID);
-		$predicateUniqueID = new Resource(UID);
-		$this->model->add(new Statement($resourceUser,$predicateUniqueID,$literalUserID));		
-		
-		$literalPassword = new Literal($password);
-		$predicatePassword = new Resource(PASSWORD);
-		$this->model->add(new Statement($resourceUser,$predicatePassword,$literalPassword));	
-	}
+
+    public function saveUsers()
+    {						
+        $this->model->saveAs($this->fileName,'rdf');
+    }
+
+    public function addNewUser($name,$password)
+    {
+        $userID = md5( uniqid(rand(), true) );
+
+        $resourceUser = new Resource(USER . '/' . $userID);
+
+        $resourceUserType = new Resource(USER);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceUser,$predicateRType,$resourceUserType));
+
+        $literalUserName = new Literal($name);
+        $predicateName = new Resource(NAME);
+        $this->model->add(new Statement($resourceUser,$predicateName,$literalUserName));	
+
+        $literalUserID = new Literal($userID);
+        $predicateUniqueID = new Resource(UID);
+        $this->model->add(new Statement($resourceUser,$predicateUniqueID,$literalUserID));		
+
+        $literalPassword = new Literal($password);
+        $predicatePassword = new Resource(PASSWORD);
+        $this->model->add(new Statement($resourceUser,$predicatePassword,$literalPassword));	
+    }
 
 }
