Index: /Dev/trunk/classes/Loader.php
===================================================================
--- /Dev/trunk/classes/Loader.php	(revision 82)
+++ /Dev/trunk/classes/Loader.php	(revision 83)
@@ -15,5 +15,5 @@
         $surveys = array();
 
-        $surveyDBI = new SurveyDatabaseInterface(null);
+        $surveyDBI = new SurveyCreationDatabaseInterface(null);
         $surveyIDTitles = $surveyDBI->getExistingSurveys();
 
Index: /Dev/trunk/classes/SessionCreationTool.php
===================================================================
--- /Dev/trunk/classes/SessionCreationTool.php	(revision 82)
+++ /Dev/trunk/classes/SessionCreationTool.php	(revision 83)
@@ -10,4 +10,5 @@
     private $session;
     private $surveys;
+    private $applications;
 
     public function __construct($session = null) {
@@ -40,4 +41,5 @@
     private function init() {
         $this->surveys = Loader::loadSurveys();
+        $this->applications = Loader::loadApplications();
     }
 
@@ -227,4 +229,13 @@
         ?>
         <select id="applicationsList" size="5" class="width100p">
+            <?php
+            foreach ($this->applications as $application) {
+                ?>
+                <option name="<?php echo $application->id; ?>" value="<?php echo $application->id; ?>">
+                    <?php echo $application->title; ?>
+                </option>
+                <?php
+            }
+            ?>
         </select>
         <?php
Index: /Dev/trunk/classes/SurveyAnswerDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/SurveyAnswerDatabaseInterface.php	(revision 82)
+++ /Dev/trunk/classes/SurveyAnswerDatabaseInterface.php	(revision 83)
@@ -1,5 +1,4 @@
 <?php
-
-// Survey class as intermediate for storing answer data from the site to the RDF database 
+// Survey database interface class as intermediate for storing data from the site to the RDF database 
 require_once 'rdfConstants.php';
 
@@ -9,45 +8,31 @@
 
 
-class SurveyAnswerDatabaseInterface
-{		
-	protected $surveyAnswerRDFWriter;
-	protected $surveyAnswerRDFReader;
- 
-
-    public function __construct($surveyID,$applicationID)
-    {					
-		$this->surveyAnswerRDFWriter = new SurveyAnswerRDFWriter($surveyUID,$applicationID);
-		$this->surveyAnswerRDFReader = new SurveyAnswerRDFReader($surveyUID,$applicationID);
+class SurveyAnswerDatabaseInterface extends SurveyCreationDatabaseInterface
+{
+    protected $surveyAnswerRDFReader;
+    protected $surveyAnswerRDFWriter;
+    
+    public function __construct($surveyID,$sessionID,$respondentID)
+    {
+        parent::__construct($surveyID);
+        if($respondentID == null)
+            $respondentID = md5( uniqid(rand(), true) );
+        else
+            $respondentID = $respondentID;
+        
+        $this->surveyAnswerRDFReader = new SurveyAnswerRDFReader($surveyID,$sessionID,$respondentID);
+        $this->surveyAnswerRDFWriter = new SurveyAnswerRDFWriter($surveyID,$sessionID,$respondentID);
     }
-	
-	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()
-	{
-		
-	}
+    
+    public function setRespondentInfo($respondentInfo)
+    {
+        $name = $respondentInfo['username'];
+        $this->surveyAnswerRDFWriter->setRespondentData($name);
+    }
+    
+    public function setSurveyAnswers($answer)
+    {
+        
+    }
 }
 ?>
Index: /Dev/trunk/classes/SurveyAnswerRDFReader.php
===================================================================
--- /Dev/trunk/classes/SurveyAnswerRDFReader.php	(revision 82)
+++ /Dev/trunk/classes/SurveyAnswerRDFReader.php	(revision 83)
@@ -4,7 +4,9 @@
 {	
     protected $model;
+    protected $respondentID;
+    
     protected $filePath;
 
-    public function __construct($surveyUID,$sessionID)
+    public function __construct($surveyUID,$sessionID,$respondentID)
     {
 
@@ -12,12 +14,21 @@
         $factory = new ModelFactory();
         $this->model = $factory->getDefaultModel();
-        $this->filePath = 'data/surveys/survey_'.$surveyUID . '.rdf';
         
-        $this->model->load($this->filePath);
+        $this->respondentID = $respondentID;
+        
+        $this->filePath = 'data/sessions/' .  $sessionID . '/survey_'.$surveyUID . '/';
     }
 
-    public function loadAnsers($userID)
+    public function loadAnsers()
     {
-        $this->model->load($this->filePath.'/answer_'.$this->userUID.'.rdf');
+        if(file_exists($this->filePath.'questions.rdf'))
+        {
+            $this->model->load($this->filePath.'/answer_'.$this->respondentID.'.rdf');
+            return true;
+        }
+        else
+        {
+            return false;
+        }
     }
 
@@ -56,5 +67,5 @@
     }
 
-    public function getAnswerByRespondent($respondentID)
+    public function getAnswersByRespondent($respondentID)
     {
         $this->tempModel->loadModel($this->model);
Index: /Dev/trunk/classes/SurveyAnswerRDFWriter.php
===================================================================
--- /Dev/trunk/classes/SurveyAnswerRDFWriter.php	(revision 82)
+++ /Dev/trunk/classes/SurveyAnswerRDFWriter.php	(revision 83)
@@ -3,8 +3,9 @@
 class SurveyAnswerRDFWriter
 {
-    protected $userUID;
-    protected $filePath;
+    protected $surveyID;
+    protected $respondentID;
+    protected $path;
 
-    public function __construct($surveyUID,$sessionID,$userID)
+    public function __construct($surveyID,$sessionID,$respondentID)
     {
         // Create empty MemModel
@@ -12,19 +13,26 @@
         $this->model = $factory->getDefaultModel();
         
-        $this->filePath = 'data/sessions/' .  $sessionID . '/survey_'.$surveyUID . '/';
-        $this->userID = $userID;
+        $basePath = 'data/sessions/';
+        $sessionPath = $basePath . $sessionID . '/';
+        $this->path  = $sessionPath .'survey_'.$surveyID . '/';
+        $this->surveyID = $surveyID;
+        $this->respondentID = $respondentID;
         
-        if (!is_dir($this->filePath))
-            mkdir($this->filePath);		
+        if (!is_dir($basePath))
+            mkdir($basePath);
+        if (!is_dir($sessionPath))
+             mkdir($sessionPath);
+        if (!is_dir($this->path))
+              mkdir($this->path);
     }
 
-    public function saveSurvey()
+    public function saveSurveyData()
     {		
-        $this->model->saveAs($this->filePath.'/answer_'.$this->userUID.'.rdf','rdf');
+        $this->model->saveAs($this->path.'/answer_'.$this->respondentID.'.rdf','rdf');
     }
 
     public function setRespondentData($name)
     {				
-        $resourceUser = new Resource(USER . '/' . $this->userID);		
+        $resourceUser = new Resource(USER . '/' . $this->respondentID);		
 
         $resourceUserType = new Resource(USER);
@@ -32,14 +40,17 @@
         $this->model->add(new Statement($resourceUser,$predicateRType,$resourceUserType));
 
-        $LiteralUserName = new Literal($name);
+        $literalUserName = new Literal($name);
         $predicateName = new Resource(NAME);
-        $this->model->add(new Statement($resourceUser,$predicateUniqueID,$LiteralUserName));		
+        $this->model->add(new Statement($resourceUser,$predicateName,$literalUserName));		
 
-        $literalUserID = new Literal($this->userUID);
+        $literalUserID = new Literal($this->respondentID);
         $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));
+        $resourceSurvey = new Resource(SURVEY.'/'.$this->surveyID);
+        $predicateRespondent = new Resource(RESPONDENT);
+        $this->model->add(new Statement($resourceSurvey,$predicateRespondent,$resourceUser));
+        
+        $this->saveSurveyData();
     }
 
@@ -47,7 +58,11 @@
     {
         foreach($answers as $questionID => $answerValue)
-        {					
+        {
             $resourceQuestion = new Resource(QUESTION.'/'.$questionID);
 
+            $resourceQuestionType = new Resource(QUESTION);
+            $predicateRType = new Resource(RTYPE);
+            $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
+            
             $predicateAnswered = new Resource(ANSWERED);	
             $answer = new Literal($answerValue);
Index: /Dev/trunk/classes/SurveyCreationDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/SurveyCreationDatabaseInterface.php	(revision 82)
+++ /Dev/trunk/classes/SurveyCreationDatabaseInterface.php	(revision 83)
@@ -8,5 +8,5 @@
 
 
-class SurveyDatabaseInterface
+class SurveyCreationDatabaseInterface
 {		
     protected $surveyRDFWriter;
Index: v/trunk/classes/SurveyDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/SurveyDatabaseInterface.php	(revision 82)
+++ 	(revision )
@@ -1,132 +1,0 @@
-<?php
-// Survey database interface class as intermediate for storing data from the site to the RDF database 
-require_once 'rdfConstants.php';
-
-// Include RAP Library to write RDF files
-include(RDFAPI_INCLUDE_DIR . "RDFAPI.php");
-
-
-
-class SurveyDatabaseInterface
-{		
-    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);
-    }
-
-    public function setSurveyInfo($survey)
-    {
-        $sTitle = $survey['surveyTitle'];
-        $sDescription = $survey['surveyDescription'];
-
-        $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;
-    }
-    
-    public function getSurveyTitleByID($surveyID)
-    {
-        $surveyTitleLiteral = $this->surveyRDFReader->getSurveyTitleByID($surveyID);
-        $surveyTitle = substr($surveyTitle[0]['?title'],9,strlen($surveyTitle[0]['?title'])-11);
-        
-        return $surveyTitle;
-    }
-
-}
-?>
Index: /Dev/trunk/classes/UserDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/UserDatabaseInterface.php	(revision 82)
+++ /Dev/trunk/classes/UserDatabaseInterface.php	(revision 83)
@@ -25,5 +25,5 @@
         $userPassword = $this->RIJNDAEL_encrypt($userInfo['password']);
 
-        if($this->checkUserName($userName))
+        if(!$this->checkUserName($userName))
         {
             $this->userRDFWriter->addNewUser($userName, $userPassword);
@@ -42,5 +42,5 @@
             foreach($resultUser as $user)
             {
-            $name = $user['?name']->label;
+                $name = $user['?name']->label;
                 if(!strcmp($name ,$userName))
                 {
Index: v/trunk/data/users/users.rdf
===================================================================
--- /Dev/trunk/data/users/users.rdf	(revision 82)
+++ 	(revision )
@@ -1,24 +1,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!-- Generated by RdfSerializer.php from RDF RAP.
-# http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/index.html !-->
-
-<rdf:RDF
-   xml:base="data/users/users.rdf#"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:ns1="http://www.survey.tool/predicates/">
-
-<rdf:Description rdf:about="http://www.survey.tool/resources/user/90d392c2c2e4303c80e7fdf114bb5c5a">
-   <ns1:resource_type rdf:resource="http://www.survey.tool/resources/user"/>
-   <ns1:name>Bas</ns1:name>
-   <ns1:uid>90d392c2c2e4303c80e7fdf114bb5c5a</ns1:uid>
-   <ns1:password>7oQB+6q1NLM/zyzMcaYsfuEUcvuUlgm/UfP/xwxJFRA=</ns1:password>
-</rdf:Description>
-
-<rdf:Description rdf:about="http://www.survey.tool/resources/user/e93dda3924206c6fd2e4a52a2999415a">
-   <ns1:resource_type rdf:resource="http://www.survey.tool/resources/user"/>
-   <ns1:name>Igor</ns1:name>
-   <ns1:uid>e93dda3924206c6fd2e4a52a2999415a</ns1:uid>
-   <ns1:password>AHNpYa+Ft7ZrC5KpRisJTJkhIqCANtF46xizdXF4ecQ=</ns1:password>
-</rdf:Description>
-
-</rdf:RDF>
Index: /Dev/trunk/survey.php
===================================================================
--- /Dev/trunk/survey.php	(revision 82)
+++ /Dev/trunk/survey.php	(revision 83)
@@ -11,6 +11,8 @@
     $surveyID = $_GET['id'];
 
-    $surveyDBI = new SurveyDatabaseInterface($surveyID);
+    $surveyDBI = new SurveyAnswerDatabaseInterface($surveyID,'123','321');
     $info = $surveyDBI->getSurveyInfo();
+    $surveyDBI->setRespondentInfo($_SESSION);
+    $surveyDBI->setSurveyAnswers($_POST);
 
     $savedSurvey = Survey::getSurvey($info);
Index: /Dev/trunk/surveycreation.php
===================================================================
--- /Dev/trunk/surveycreation.php	(revision 82)
+++ /Dev/trunk/surveycreation.php	(revision 83)
@@ -12,5 +12,5 @@
 if (isset($_POST['UID'])) {
     $surveyID = $_POST['UID'];
-    $surveyDBI = new SurveyDatabaseInterface($surveyID);
+    $surveyDBI = new SurveyCreationDatabaseInterface($surveyID);
     $info = $surveyDBI->getSurveyInfo();
 
@@ -25,5 +25,5 @@
 //    var_dump($_POST);
 //    echo '<br/><br/>';
-    $surveyDBI = new SurveyDatabaseInterface($_POST['surveyID']);
+    $surveyDBI = new SurveyCreationDatabaseInterface($_POST['surveyID']);
     $surveyDBI->setSurveyInfo($_POST,$_SESSION);
     $info = $surveyDBI->getSurveyInfo();
