Index: /Dev/trunk/classes/QuestionDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/QuestionDatabaseInterface.php	(revision 82)
+++ /Dev/trunk/classes/QuestionDatabaseInterface.php	(revision 82)
@@ -0,0 +1,7 @@
+<?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 82)
+++ /Dev/trunk/classes/QuestionRDFReader.php	(revision 82)
@@ -0,0 +1,182 @@
+<?php
+
+class QuestionRDFReader
+{
+    protected $model;
+
+    protected $filePath;
+
+    public function __construct()
+    {
+        // Create empty MemModel
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        $this->filePath = 'data/questions/';
+        if (!is_dir($this->filePath))
+            mkdir($this->filePath);	
+    }
+    
+    public function loadQuestions()
+    {
+        if(file_exists($this->filePath.'questions.rdf'))
+        {
+            $this->model->load($this->filePath.'questions.rdf');
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    
+    public function readQuestionByID($questionID)
+    {        
+        $result = array();
+        $result['title'] = $this->readQuestionTitle($questionID);				
+        $result['description'] = $this->readQuestionDescription($questionID);
+        $result['type'] = $this->readQuestionType($questionID);
+        $result['code'] = $this->readQuestionCode($questionID);
+        $result['category'] = $this->readQuestionCategory($questionID);
+        $result['answers'] = $this->readQuestionAnswers($questionID);
+
+        return $result;
+    }
+    
+    public function readQuestionIDs()
+    {
+        $result = null;
+        
+        if(file_exists($this->filePath.'questions.rdf'))
+        {
+            // Create empty MemModel
+            $factory = new ModelFactory();
+            $tempmodel= $factory->getDefaultModel();
+            $tempmodel->load($this->filePath.'questions.rdf');
+
+            $querystring = '
+            PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT 	?questionID
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			?questionID				
+            }';
+            
+            $result = $tempmodel->sparqlQuery($querystring);
+        }
+        return $result; 
+    }
+
+    public function readQuestionTitle($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionTitle
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:title		?questionTitle 		
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readQuestionDescription($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionDescription
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:description		?questionDescription 		
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readQuestionType($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionType
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:question_type	?questionType				
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+    
+    public function readQuestionCode($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionCode
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:question_code	?questionCode				
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+    
+    public function readQuestionCategory($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionCategory
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:question_category	?questionCategory				
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readQuestionAnswers($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;
+    }
+}
+
+?>
Index: /Dev/trunk/classes/QuestionRDFWriter.php
===================================================================
--- /Dev/trunk/classes/QuestionRDFWriter.php	(revision 82)
+++ /Dev/trunk/classes/QuestionRDFWriter.php	(revision 82)
@@ -0,0 +1,82 @@
+<?php
+class QuestionRDFWriter 
+{
+    protected $model;
+
+    protected $filePath = 'data/questions/';
+
+    public function __construct()
+    {
+        // Create empty MemModel
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        if (!is_dir($this->filePath))
+            mkdir($this->filePath);
+        
+        if(file_exists($this->filePath.'questions.rdf'))
+            $this->model->load($this->filePath.'questions.rdf');
+    }	
+
+    public function saveQuestions()
+    {	
+        $this->model->saveAs($this->filePath.'questions.rdf','rdf');
+    }
+    
+    public function createQuestion($qTitle,$qDescription,$qType,$qID,$qCode,$qCategory,$qAnswers)
+    {
+        $resourceQuestion = new Resource(QUESTION.'/'.$qID);
+
+        $resourceQuestionType = new Resource(QUESTION);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
+
+        $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));
+
+        $predicateUniqueID = new Resource(UID);
+        $questionUID = new Literal($qID);
+        $this->model->add(new Statement($resourceQuestion,$predicateUniqueID,$questionUID));
+        
+        $predicateQCode = new Resource(QCODE);
+        $questionQCode = new Literal($qCode);
+        $this->model->add(new Statement($resourceQuestion,$predicateQCode,$questionQCode));
+        
+        $predicateQCategory = new Resource(QCATEGORY);
+        $questionQCategory = new Literal($qCategory);
+        $this->model->add(new Statement($resourceQuestion,$predicateQCategory,$questionQCategory));
+
+        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));
+        }	
+    }
+}
+?>
Index: /Dev/trunk/classes/SurveyCreationDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/SurveyCreationDatabaseInterface.php	(revision 82)
+++ /Dev/trunk/classes/SurveyCreationDatabaseInterface.php	(revision 82)
@@ -0,0 +1,179 @@
+<?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;
+    protected $questionRDFWriter;
+    protected $questionRDFReader;
+
+    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);
+        $this->questionRDFWriter = new QuestionRDFWriter();
+        $this->questionRDFReader = new QuestionRDFReader();
+    }
+
+    public function setSurveyInfo($survey,$user)
+    {
+        $sTitle = $survey['surveyTitle'];
+        $sDescription = $survey['surveyDescription'];
+
+        $this->surveyRDFWriter->createSurvey($sTitle,$sDescription);
+
+        $sUserID = $user['username'];
+
+        $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++;
+            }
+
+            if(!$this->checkQuestionIDExists($qID))
+            {
+                $this->questionRDFWriter->createQuestion($qTitle,$qDescription,$qType,$qID,"null","null",$qAnswers);
+            }            
+            $this->surveyRDFWriter->addQuestion($qID);
+
+            $qNumber++;
+        }
+
+        $this->surveyRDFWriter->saveSurvey();
+        $this->questionRDFWriter->saveQuestions();
+    }
+
+    public function getSurveyInfo()
+    {
+        $surveyInfo = array();
+
+        $this->questionRDFReader->loadQuestions();
+        
+        $resultSurvey = $this->surveyRDFReader->getSurveyInfo();
+        
+        $surveyInfo['surveyID'] = $resultSurvey['info'][0]['?uid']->label;
+        $surveyInfo['surveyTitle'] = $resultSurvey['info'][0]['?title']->label;
+        $surveyInfo['surveyDescription'] = $resultSurvey['info'][0]['?description']->label;
+        $surveyInfo['surveyCreator'] = $resultSurvey['info'][0]['?creator']->label;
+        $surveyQuestionIDs = $resultSurvey['questionIDs'];
+        
+        if($surveyQuestionIDs != false)
+        {
+            $qNumber = 1;
+            foreach($surveyQuestionIDs as $qID)
+            {
+                $questionID = $qID['?questionID']->label;
+                $surveyInfo['questionID'.$qNumber] = $questionID;
+
+                $questionTitleObject = $this->questionRDFReader->readQuestionTitle($questionID);
+                $surveyInfo['questionTitle'.$qNumber] = $questionTitleObject[0]['?questionTitle']->label;
+
+                $questionDescriptionObject = $this->questionRDFReader->readQuestionDescription($questionID);
+                $surveyInfo['questionDescription'.$qNumber] = $questionDescriptionObject[0]['?questionDescription']->label;
+
+                $questionTypeObject = $this->questionRDFReader->readQuestionType($questionID);
+                $surveyInfo['questionType'.$qNumber] = $questionTypeObject[0]['?questionType']->label;
+
+                $resultAnswers = $this->questionRDFReader->readQuestionAnswers($questionID);
+
+                if ($resultAnswers != null)
+                {
+                    for($aNumber = 1;$aNumber<=sizeof($resultAnswers);$aNumber++)
+                    {
+                        $surveyInfo['q'.$qNumber.'ans'.$aNumber] = $resultAnswers[$aNumber-1]['?answerDescription']->label;
+                    }
+                }
+                $resultAnswers = null;
+                $qNumber++;
+            }
+        }
+        
+        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] = $surveyTitle[0]['?title']->label;
+        }
+
+        return $surveys;
+    }
+    
+    public function getSurveyTitleByID($surveyID)
+    {
+        $surveyTitleLiteral = $this->surveyRDFReader->getSurveyTitleByID($surveyID);
+        $surveyTitle = $surveyTitle[0]['?title']->label;
+        
+        return $surveyTitle;
+    }
+
+    
+    
+    public function checkQuestionIDExists($qID)
+    {
+        $result = false;
+
+        $questionIDs = $this->questionRDFReader->readQuestionIDs();
+        
+        if ($questionIDs != null)
+        {
+            foreach($questionIDs as $questionID)
+            {
+                $id = $questionID['?questionID']->label;
+                if(!strcmp($id ,$qID))
+                {
+                    $result = true;
+                    break;
+                }
+            }
+        }
+
+        return $result;
+    }
+}
+?>
Index: /Dev/trunk/classes/SurveyRDFReader.php
===================================================================
--- /Dev/trunk/classes/SurveyRDFReader.php	(revision 81)
+++ /Dev/trunk/classes/SurveyRDFReader.php	(revision 82)
@@ -25,9 +25,9 @@
     public function getSurveyInfo()
     {		
-        SurveyRDFReader::loadSurvey();
+        $this->loadSurvey();
 
         $result = array();
-        $result[] = $this->readSurveyInfo();				
-        $result[] = $this->readSurveyQuestions();
+        $result['info'] = $this->readSurveyInfo();				
+        $result['questionIDs'] = $this->readSurveyQuestionIDs();
 
         return $result;
@@ -53,68 +53,6 @@
         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()
+    
+    public function readSurveyQuestionIDs()
     {
         $querystring = '
@@ -124,25 +62,6 @@
             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
+                    _survey	predicates:resource_type	resources:survey ;
+                                predicates:has_question		?questionID				
             }';
 
Index: /Dev/trunk/classes/SurveyRDFWriter.php
===================================================================
--- /Dev/trunk/classes/SurveyRDFWriter.php	(revision 81)
+++ /Dev/trunk/classes/SurveyRDFWriter.php	(revision 82)
@@ -48,63 +48,18 @@
     }
 
-    public function setUserData($userID)
+    public function setUserData($uID)
     {				
-        $resourceUser = new Resource(USER . '/' . $userID);
+        $userID = new Literal($uID);
 
         $predicateCreator = new Resource(CREATOR);
-        $this->model->add(new Statement($this->resourceSurvey,$predicateCreator,$resourceUser));
+        $this->model->add(new Statement($this->resourceSurvey,$predicateCreator,$userID));
     }
 
-    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 addQuestion($qID)
+    {		
+        $questionID = new Literal($qID);
+        $predicateQuestion = new Resource(HAS_QUESTION);
+        $this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$questionID));
+    }
 }
 
Index: /Dev/trunk/classes/UserDatabaseInterface.php
===================================================================
--- /Dev/trunk/classes/UserDatabaseInterface.php	(revision 81)
+++ /Dev/trunk/classes/UserDatabaseInterface.php	(revision 82)
@@ -25,6 +25,9 @@
         $userPassword = $this->RIJNDAEL_encrypt($userInfo['password']);
 
-        $this->userRDFWriter->addNewUser($userName, $userPassword);
-        $this->userRDFWriter->saveUsers();
+        if($this->checkUserName($userName))
+        {
+            $this->userRDFWriter->addNewUser($userName, $userPassword);
+            $this->userRDFWriter->saveUsers();            
+        }
     }
 
@@ -39,5 +42,5 @@
             foreach($resultUser as $user)
             {
-            $name = substr($user['?name'],9,strlen($user['?name'])-11);
+            $name = $user['?name']->label;
                 if(!strcmp($name ,$userName))
                 {
@@ -58,5 +61,5 @@
 
         $encryptedPasswordLiteral = $this->userRDFReader->getUserPassword($userName);
-        $encryptedPassword = substr($encryptedPasswordLiteral[0]['?password'],9,strlen($encryptedPasswordLiteral[0]['?password'])-11);
+        $encryptedPassword = $encryptedPasswordLiteral[0]['?password']->label;
 
         if(!strcmp($this->RIJNDAEL_encrypt($userPassword),$encryptedPassword))
Index: v/trunk/data/surveys/survey_79c98f73ea0d624440430af1e04eaedf.rdf
===================================================================
--- /Dev/trunk/data/surveys/survey_79c98f73ea0d624440430af1e04eaedf.rdf	(revision 81)
+++ 	(revision )
@@ -1,62 +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
-   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/survey/79c98f73ea0d624440430af1e04eaedf">
-   <ns1:resource_type rdf:resource="http://www.survey.tool/resources/survey"/>
-   <ns1:uid>79c98f73ea0d624440430af1e04eaedf</ns1:uid>
-   <ns1:title>A survey</ns1:title>
-   <ns1:description>Yes...</ns1:description>
-   <ns1:creator rdf:resource="http://www.survey.tool/resources/user/Creator"/>
-</rdf:Description>
-
-<rdf:Description rdf:about="http://www.survey.tool/resources/question/934b259ec25d99d245a0936c38593781">
-   <ns1:resource_type rdf:resource="http://www.survey.tool/resources/question"/>
-   <ns1:uid>934b259ec25d99d245a0936c38593781</ns1:uid>
-   <ns1:title>It's called awesome</ns1:title>
-   <ns1:description>So what's it called?</ns1:description>
-   <ns1:question_type>mc</ns1:question_type>
-</rdf:Description>
-
-<rdf:Description rdf:about="http://www.survey.tool/resources/answer/cc0e95f621c9c174769ccc8e74ba4e61">
-   <ns1:resource_type rdf:resource="http://www.survey.tool/resources/answer"/>
-   <ns1:uid>cc0e95f621c9c174769ccc8e74ba4e61</ns1:uid>
-   <ns1:title>q1ans1</ns1:title>
-   <ns1:description>James</ns1:description>
-</rdf:Description>
-
-<rdf:Description rdf:about="http://www.survey.tool/resources/question/934b259ec25d99d245a0936c38593781">
-   <ns1:has_answer rdf:resource="http://www.survey.tool/resources/answer/cc0e95f621c9c174769ccc8e74ba4e61"/>
-</rdf:Description>
-
-<rdf:Description rdf:about="http://www.survey.tool/resources/answer/3727f4cb541a95f2286cb66c597cdb85">
-   <ns1:resource_type rdf:resource="http://www.survey.tool/resources/answer"/>
-   <ns1:uid>3727f4cb541a95f2286cb66c597cdb85</ns1:uid>
-   <ns1:title>q1ans2</ns1:title>
-   <ns1:description>Awesome</ns1:description>
-</rdf:Description>
-
-<rdf:Description rdf:about="http://www.survey.tool/resources/question/934b259ec25d99d245a0936c38593781">
-   <ns1:has_answer rdf:resource="http://www.survey.tool/resources/answer/3727f4cb541a95f2286cb66c597cdb85"/>
-</rdf:Description>
-
-<rdf:Description rdf:about="http://www.survey.tool/resources/answer/2b2b3605488bd83155e3994ad3ff4800">
-   <ns1:resource_type rdf:resource="http://www.survey.tool/resources/answer"/>
-   <ns1:uid>2b2b3605488bd83155e3994ad3ff4800</ns1:uid>
-   <ns1:title>q1ans3</ns1:title>
-   <ns1:description>Sha' naynay</ns1:description>
-</rdf:Description>
-
-<rdf:Description rdf:about="http://www.survey.tool/resources/question/934b259ec25d99d245a0936c38593781">
-   <ns1:has_answer rdf:resource="http://www.survey.tool/resources/answer/2b2b3605488bd83155e3994ad3ff4800"/>
-</rdf:Description>
-
-<rdf:Description rdf:about="http://www.survey.tool/resources/survey/79c98f73ea0d624440430af1e04eaedf">
-   <ns1:has_question rdf:resource="http://www.survey.tool/resources/question/934b259ec25d99d245a0936c38593781"/>
-</rdf:Description>
-
-</rdf:RDF>
Index: /Dev/trunk/data/users/users.rdf
===================================================================
--- /Dev/trunk/data/users/users.rdf	(revision 81)
+++ /Dev/trunk/data/users/users.rdf	(revision 82)
@@ -4,4 +4,5 @@
 
 <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/">
@@ -14,3 +15,10 @@
 </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/mainmenu.php
===================================================================
--- /Dev/trunk/mainmenu.php	(revision 81)
+++ /Dev/trunk/mainmenu.php	(revision 82)
@@ -2,5 +2,4 @@
 require 'classes/master.php'; //should be at top of every page   
 
-    var_dump($_POST);
 if (isset($_POST['login'])) {
     if ($_POST['username'] == '')
Index: /Dev/trunk/rdfConstants.php
===================================================================
--- /Dev/trunk/rdfConstants.php	(revision 81)
+++ /Dev/trunk/rdfConstants.php	(revision 82)
@@ -5,5 +5,5 @@
 
 // Default namespace for survey tool
-define('SURVEYTOOL_NAMESPACE','http://www.survey.tool/');
+define('SURVEYTOOL_NAMESPACE','http://tbm.tudelft.nl/researchtool/');
 define('SURVEYTOOL_RESOURCES_NAMESPACE',SURVEYTOOL_NAMESPACE . 'resources/');
 define('SURVEYTOOL_PREDICATES_NAMESPACE',SURVEYTOOL_NAMESPACE . 'predicates/');
@@ -29,4 +29,6 @@
 define('RTYPE',SURVEYTOOL_PREDICATES_NAMESPACE . 'resource_type');
 define('QTYPE',SURVEYTOOL_PREDICATES_NAMESPACE . 'question_type');
+define('QCODE',SURVEYTOOL_PREDICATES_NAMESPACE . 'question_code');
+define('QCATEGORY',SURVEYTOOL_PREDICATES_NAMESPACE . 'question_category');
 define('HAS_QUESTION',SURVEYTOOL_PREDICATES_NAMESPACE . 'has_question');
 define('HAS_ANSWER',SURVEYTOOL_PREDICATES_NAMESPACE . 'has_answer');
Index: /Dev/trunk/surveycreation.php
===================================================================
--- /Dev/trunk/surveycreation.php	(revision 81)
+++ /Dev/trunk/surveycreation.php	(revision 82)
@@ -26,5 +26,5 @@
 //    echo '<br/><br/>';
     $surveyDBI = new SurveyDatabaseInterface($_POST['surveyID']);
-    $surveyDBI->setSurveyInfo($_POST);
+    $surveyDBI->setSurveyInfo($_POST,$_SESSION);
     $info = $surveyDBI->getSurveyInfo();
 //    echo '<br/><br/>';
