Index: /Dev/trunk/classes/Loader.php
===================================================================
--- /Dev/trunk/classes/Loader.php	(revision 84)
+++ /Dev/trunk/classes/Loader.php	(revision 85)
@@ -45,5 +45,5 @@
         $sessions = array();
         
-        $sessionDBI = new SessionDatabaseInterface(null);
+        $sessionDBI = new SessionCreationDatabaseInterface(null);
         $sessionTitles = $sessionDBI->getExistingSessions();
         
Index: v/trunk/classes/QuestionDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/QuestionDatabaseInterface.php	(revision 84)
+++ 	(revision )
@@ -1,7 +1,0 @@
-<?php
-
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-?>
Index: /Dev/trunk/classes/QuestionRDFReader.php
===================================================================
--- /Dev/trunk/classes/QuestionRDFReader.php	(revision 84)
+++ /Dev/trunk/classes/QuestionRDFReader.php	(revision 85)
@@ -170,6 +170,5 @@
                     _question	predicates:resource_type	resources:question ;
                                 predicates:uid			"' . $questionID . '"  ;
-                                predicates:has_answer		_answer .
-                    _answer	predicates:description		?answerDescription
+                                predicates:has_answer		?answerDescription
             }';
 
Index: /Dev/trunk/classes/QuestionRDFWriter.php
===================================================================
--- /Dev/trunk/classes/QuestionRDFWriter.php	(revision 84)
+++ /Dev/trunk/classes/QuestionRDFWriter.php	(revision 85)
@@ -58,23 +58,7 @@
         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));
-
+            $answerValue = new Literal($answer);
             $predicateAnswer = new Resource(HAS_ANSWER);	
-            $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$resourceAnswer));
+            $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$answerValue));
         }	
     }
Index: /Dev/trunk/classes/SessionCreationDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/SessionCreationDatabaseInterface.php	(revision 85)
+++ /Dev/trunk/classes/SessionCreationDatabaseInterface.php	(revision 85)
@@ -0,0 +1,105 @@
+<?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 SessionCreationDatabaseInterface
+{		
+    protected $sessionRDFWriter;
+    protected $sessionRDFReader;
+
+
+    public function __construct($sessionID)
+    {
+        if($sessionID == null)
+            $sessionUID = md5( uniqid(rand(), true) );
+        else
+            $sessionUID = $sessionID;
+
+        $this->sessionRDFWriter = new SessionRDFWriter($sessionUID);
+        $this->sessionRDFReader = new SessionRDFReader($sessionUID);
+    }
+    
+    public function setSessionInfo($session)
+    {
+        $sTitle = $session['sessionTitle'];
+        $sDescription = $session['sessionDescription'];
+
+        $this->sessionRDFWriter->createSession($sTitle,$sDescription);
+        
+        $pipelineCount = $session['pipelineCount'];
+        
+        for($i = 1; $i <= $pipelineCount; $i++)
+        {
+            if(isset($session[$i.'s']))
+            {
+                $this->sessionRDFWriter->addSurveyToPipeline($session[$i.'s'], $i);
+            }
+            else if(isset($session[$i.'a']))
+            {
+                $this->sessionRDFWriter->addApplicationToPipeline($session[$i.'a'], $i);
+            }
+            else if(isset($session[$i.'d'])) 
+            {
+                $this->sessionRDFWriter->addDashboardToPipeline($session[$i.'d'], $i);
+            }
+        }
+    }
+    
+    public function getSessionInfo()
+    {
+        $sessionInfo = array();
+
+        $resultSession = $this->sessionRDFReader->getSurveyInfo();
+        
+        $sessionInfo['sessionTitle'] = substr($resultSession[0][0]['?title'],9,strlen($resultSession[0][0]['?title'])-11);
+        $sessionInfo['sessionDescription'] = substr($resultSession[0][0]['?description'],9,strlen($resultSession[0][0]['?description'])-11);
+        
+        foreach ($resultSession[1][1] as $surveyInfo) 
+        {
+             $surveyUID = substr($surveyInfo['?uid'],9,strlen($surveyInfo['?uid'])-11);
+             $surveyIndex = substr($surveyInfo['?index'],9,strlen($surveyInfo['?index'])-11);
+             $sessionInfo[$surveyIndex . 's'] = $surveyUID;
+        }
+        foreach ($resultSession[1][2] as $applicationInfo) 
+        {
+             $applicationUID = substr($applicationInfo['?uid'],9,strlen($applicationInfo['?uid'])-11);
+             $applicationIndex = substr($applicationInfo['?index'],9,strlen($applicationInfo['?index'])-11);
+             $sessionInfo[$applicationIndex . 'a'] = $applicationUID;
+        }
+        foreach ($resultSession[1][3] as $dashboardInfo) 
+        {
+             $dashboardUID = substr($dashboardInfo['?uid'],9,strlen($dashboardInfo['?uid'])-11);
+             $dashboardIndex = substr($dashboardInfo['?index'],9,strlen($dashboardInfo['?index'])-11);
+             $sessionInfo[$dashboardIndex . 'd'] = $dashboardUID;
+        }
+    }
+    
+    public function getExistingSessions()
+    {
+        $sessionIDs = array();
+        $sessions = array();
+
+        if($handle = opendir('data/sessions/'))
+        {
+            while (false !== ($file = readdir($handle))) {
+                if(strstr($file, 'session_'))
+                    $sessionIDs[] = substr($file,7,strlen($file)-11);
+            }
+        }
+
+        foreach($sessionIDs as $sessionID)
+        {
+            $sessionTitle = $this->sessionRDFReader->getSessionTitleByID($sessionID);
+            $$sessions[$sessionID] = substr($sessionTitle[0]['?title'],9,strlen($sessionTitle[0]['?title'])-11);
+        }
+
+        return $surveys;
+    }
+}
+?>
Index: v/trunk/classes/SessionDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/SessionDatabaseInterface.php	(revision 84)
+++ 	(revision )
@@ -1,105 +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 SessionDatabaseInterface
-{		
-    protected $sessionRDFWriter;
-    protected $sessionRDFReader;
-
-
-    public function __construct($sessionID)
-    {
-        if($sessionID == null)
-            $sessionUID = md5( uniqid(rand(), true) );
-        else
-            $sessionUID = $sessionID;
-
-        $this->sessionRDFWriter = new SessionRDFWriter($surveyUID);
-        $this->sessionRDFReader = new SessionRDFReader($surveyUID);
-    }
-    
-    public function setSessionInfo($session)
-    {
-        $sTitle = $session['sessionTitle'];
-        $sDescription = $session['sessionDescription'];
-
-        $this->sessionRDFWriter->createSession($sTitle,$sDescription);
-        
-        $pipelineCount = $session['pipelineCount'];
-        
-        for($i = 1; $i <= $pipelineCount; $i++)
-        {
-            if(isset($session[$i.'s']))
-            {
-                $this->sessionRDFWriter->addSurveyToPipeline($session[$i.'s'], $i);
-            }
-            else if(isset($session[$i.'a']))
-            {
-                $this->sessionRDFWriter->addApplicationToPipeline($session[$i.'a'], $i);
-            }
-            else if(isset($session[$i.'d'])) 
-            {
-                $this->sessionRDFWriter->addDashboardToPipeline($session[$i.'d'], $i);
-            }
-        }
-    }
-    
-    public function getSessionInfo()
-    {
-        $sessionInfo = array();
-
-        $resultSession = $this->sessionRDFReader->getSurveyInfo();
-        
-        $sessionInfo['sessionTitle'] = substr($resultSession[0][0]['?title'],9,strlen($resultSession[0][0]['?title'])-11);
-        $sessionInfo['sessionDescription'] = substr($resultSession[0][0]['?description'],9,strlen($resultSession[0][0]['?description'])-11);
-        
-        foreach ($resultSession[1][1] as $surveyInfo) 
-        {
-             $surveyUID = substr($surveyInfo['?uid'],9,strlen($surveyInfo['?uid'])-11);
-             $surveyIndex = substr($surveyInfo['?index'],9,strlen($surveyInfo['?index'])-11);
-             $sessionInfo[$surveyIndex . 's'] = $surveyUID;
-        }
-        foreach ($resultSession[1][2] as $applicationInfo) 
-        {
-             $applicationUID = substr($applicationInfo['?uid'],9,strlen($applicationInfo['?uid'])-11);
-             $applicationIndex = substr($applicationInfo['?index'],9,strlen($applicationInfo['?index'])-11);
-             $sessionInfo[$applicationIndex . 'a'] = $applicationUID;
-        }
-        foreach ($resultSession[1][3] as $dashboardInfo) 
-        {
-             $dashboardUID = substr($dashboardInfo['?uid'],9,strlen($dashboardInfo['?uid'])-11);
-             $dashboardIndex = substr($dashboardInfo['?index'],9,strlen($dashboardInfo['?index'])-11);
-             $sessionInfo[$dashboardIndex . 's'] = $dashboardUID;
-        }
-    }
-    
-    public function getExistingSessions()
-    {
-        $sessionIDs = array();
-        $sessions = array();
-
-        if($handle = opendir('data/sessions/'))
-        {
-            while (false !== ($file = readdir($handle))) {
-                if(strstr($file, 'session_'))
-                    $sessionIDs[] = substr($file,7,strlen($file)-11);
-            }
-        }
-
-        foreach($sessionIDs as $sessionID)
-        {
-            $sessionTitle = $this->sessionRDFReader->getSessionTitleByID($sessionID);
-            $$sessions[$sessionID] = substr($sessionTitle[0]['?title'],9,strlen($sessionTitle[0]['?title'])-11);
-        }
-
-        return $surveys;
-    }
-}
-?>
Index: /Dev/trunk/classes/SurveyAnswerDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/SurveyAnswerDatabaseInterface.php	(revision 84)
+++ /Dev/trunk/classes/SurveyAnswerDatabaseInterface.php	(revision 85)
@@ -24,5 +24,5 @@
         $this->surveyAnswerRDFWriter = new SurveyAnswerRDFWriter($surveyID,$sessionID,$respondentID);
     }
-    
+        
     public function setRespondentInfo($respondentInfo)
     {
@@ -31,7 +31,28 @@
     }
     
-    public function setSurveyAnswers($answer)
+    public function setSurveyAnswers($answers)
     {
+        $questionAnswerList = array();
         
+        $qNumber = 1;
+        while (isset($survey['questionID'.$qNumber]))
+        {
+            $qID = $survey['questionID'.$qNumber];
+            $aArray = array();
+            
+            $aNumber = 1;
+            while (isset($survey['q'.$qNumber.'result'.$aNumber]))
+            {
+                $aArray[] = $survey['q'.$qNumber.'result'.$aNumber];
+
+                $aNumber++;
+            }
+                
+            $questionAnswerList[$qID] = $aArray;
+
+            $qNumber++;
+        }
+        
+        $this->surveyAnswerRDFWriter->setAnswers($questionAnswerList);
     }
 }
Index: /Dev/trunk/classes/SurveyAnswerRDFWriter.php
===================================================================
--- /Dev/trunk/classes/SurveyAnswerRDFWriter.php	(revision 84)
+++ /Dev/trunk/classes/SurveyAnswerRDFWriter.php	(revision 85)
@@ -25,8 +25,10 @@
         if (!is_dir($this->path))
               mkdir($this->path);
+        if(file_exists($this->path.'/answer_'.$this->respondentID.'.rdf'))
+            $this->model->load($this->path.'/answer_'.$this->respondentID.'.rdf');
     }
 
     public function saveSurveyData()
-    {		
+    {
         $this->model->saveAs($this->path.'/answer_'.$this->respondentID.'.rdf','rdf');
     }
@@ -51,11 +53,9 @@
         $predicateRespondent = new Resource(RESPONDENT);
         $this->model->add(new Statement($resourceSurvey,$predicateRespondent,$resourceUser));
-        
-        $this->saveSurveyData();
     }
 
     public function setAnswers($answers)
     {
-        foreach($answers as $questionID => $answerValue)
+        foreach($answers as $questionID => $answerValues)
         {
             $resourceQuestion = new Resource(QUESTION.'/'.$questionID);
@@ -65,7 +65,10 @@
             $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
             
-            $predicateAnswered = new Resource(ANSWERED);	
-            $answer = new Literal($answerValue);
-            $this->model->add(new Statement($resourceQuestion,$predicateAnswered,$answer));
+            foreach($answerValues as $answerValue)
+            {
+                $predicateAnswered = new Resource(ANSWERED);	
+                $answer = new Literal($answerValue);
+                $this->model->add(new Statement($resourceQuestion,$predicateAnswered,$answer));
+            }
         }
     }
Index: /Dev/trunk/classes/SurveyCreationDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/SurveyCreationDatabaseInterface.php	(revision 84)
+++ /Dev/trunk/classes/SurveyCreationDatabaseInterface.php	(revision 85)
@@ -54,8 +54,5 @@
             while (isset($survey['q'.$qNumber.'ans'.$aNumber]))
             {
-                $aArray = array();
-                $aArray['Title'] = 'q'.$qNumber.'ans'.$aNumber;
-                $aArray['Description'] = $survey['q'.$qNumber.'ans'.$aNumber];
-                $qAnswers[] = $aArray;
+                $qAnswers[] = $survey['q'.$qNumber.'ans'.$aNumber];
 
                 $aNumber++;
@@ -73,4 +70,32 @@
         $this->surveyRDFWriter->saveSurvey();
         $this->questionRDFWriter->saveQuestions();
+    }
+    
+    public function saveQuestion($questionInfo)
+    {
+        $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++;
+        }
+        
+        if(!$this->checkQuestionIDExists($qID))
+        {
+            $this->questionRDFWriter->createQuestion($qTitle,$qDescription,$qType,$qID,"null","null",$qAnswers);
+        }
     }
 
@@ -122,5 +147,5 @@
         return $surveyInfo;
     }
-
+    
     public function getExistingSurveys()
     {
Index: /Dev/trunk/sessioncreation.php
===================================================================
--- /Dev/trunk/sessioncreation.php	(revision 84)
+++ /Dev/trunk/sessioncreation.php	(revision 85)
@@ -4,4 +4,15 @@
 if (is_null($_SESSION['username']))
     redirect('index.php');
+
+var_dump($_POST);
+
+/* LOAD SURVEY */
+if (isset($_POST['UID'])) {
+    $sessionID = $_POST['UID'];
+    $sessionDBI = new SessionCreationDatabaseInterface($sessionID);
+    $info = $sessionDBI->getSurveyInfo();
+
+    $savedSurvey = Survey::getSurvey($info);
+}
 
 $session = Session::getSession($_POST);
