Index: Dev/trunk/classes/Application.php
===================================================================
--- Dev/trunk/classes/Application.php	(revision 117)
+++ Dev/trunk/classes/Application.php	(revision 131)
@@ -6,27 +6,21 @@
  * @author fpvanagthoven
  */
-class Application {
+class Application extends ResearchToolObject{
     
-    public $id;
     public $title;
     public $description;
     public $style;
 
-    public function __construct($id = null, $title = null, $description = null, $style = null) 
+    public function __construct($uid = null, $title = null, $description = null, $style = null) 
     {
-        $this->id = $id;
+        if(!isset ($uid))
+        {
+            $uid = md5(uniqid(rand(), true));
+        }
+        $this->uid = $uid;
         $this->title = $title;
         $this->description = $description;
 	$this->style = $style;
     }
-    
-    public static function getApplication($info)
-    {
-        return new Application(
-                $info['applicationID'],
-                $info['applicationTitle'],
-                $info['applicationDescription'],
-                $info['applicationStyle']);
-    }
 
 }
Index: Dev/trunk/classes/ApplicationConnector.php
===================================================================
--- Dev/trunk/classes/ApplicationConnector.php	(revision 131)
+++ Dev/trunk/classes/ApplicationConnector.php	(revision 131)
@@ -0,0 +1,141 @@
+<?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");
+
+/**
+ * Description of ApplicationConnector
+ *
+ * @author jkraaijeveld
+ */
+class ApplicationConnector implements IConnector{
+    
+    protected $model;
+    protected $fileName = 'data/applications/applications.rdf';
+
+    /**
+     * Constructor for ApplicationConnector.
+     */
+    public function __construct()
+    {
+        //Ensure the required folder for this connector exists
+        if (!is_dir('data/applications/'))
+            mkdir('data/applications/');	
+    }
+    
+    /**
+     * function load()
+     * Loads the file into the standard MemModel.
+     */
+    public function load() {
+        //Get the Memory Model from the ModelFactory
+        $this->model = ModelFactory::getDefaultModel();
+        
+        //Ensure the required file exists before loading
+        if(file_exists($this->fileName))
+            $this->model->load($this->fileName);
+    }
+    
+    /**
+     * function save()
+     * Saves the MemModel into the given file.
+     */
+    public function save() {
+        $this->model->saveAs($this->fileName,'rdf'); 
+    }
+    
+    /**
+     * function get($arguments)
+     * Gets the array of Application objects belonging to arguments supplied.
+     * @param type $arguments : An array containing zero or more of the following keys:
+     *                          'uid', 'title', 'description', 'style'
+     */
+    public function get($arguments) {
+        $this->load();
+        //Determine which arguments are supplied
+        $keys = array_keys($arguments);
+        //Set default values for arguments
+        $uid = "?uid"; $title = "?title"; $description = "?description"; $style = "?style";
+        //Set the arguments if they are supplied
+        if(in_array("uid", $keys))
+            $uid = "\"".$arguments["uid"]."\"";
+        if(in_array("title", $keys))
+            $title = '\''.$arguments["title"].'\'';
+        if(in_array("description", $keys))
+            $description = "\"".$arguments["description"]."\"";
+        if(in_array("style", $keys))
+            $style = "\"".$arguments["style"]."\"";    
+
+        //Create the querystring 
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT ?uid, ?title, ?description, ?style
+            WHERE 	
+            {
+                    _application	predicates:resource_type	resources:application ;
+					predicates:uid ?uid ;
+					predicates:title ?title ;
+					predicates:description ?description ;
+					predicates:style ?style ;
+                     			predicates:uid ' . $uid . ' 
+					predicates:title ' . $title . ' 
+					predicates:description ' . $description . ' 
+					predicates:style ' . $style . '
+            }';
+
+        //Query the model
+        $results = $this->model->sparqlQuery($querystring);
+        $applications = array();
+        if(!empty($results))
+        {
+            //Run over all results and create appropriate Application objets
+            foreach($results as $result)
+            { 
+                    $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label);
+            }
+        }
+        return $applications;
+    }
+    
+    /**
+     * function set()
+     * Finds the required databaseentry matching the given object and removes
+     * it from the rdf file. Then adds the new RDF entry matching the object.
+     * @param type $rToolObject: The ResearchToolObject to be saved. 
+     */
+    public function set($rToolObject)
+    {
+        $this->load();
+        $resourceApplication = new Resource(APPLICATION.'/'.$rToolObject->uid);
+        //Remove the old value stored with the given id
+        $this->model->subtract($this->model->find($resourceApplication, null, null));
+
+        //Add the new statements to the model
+        $resourceApplicationType = new Resource(APPLICATION);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType));
+		
+        $literalApplicationID = new Literal($rToolObject->uid);
+        $predicateUniqueID = new Resource(UID);
+        $this->model->add(new Statement($resourceApplication,$predicateUniqueID,$literalApplicationID));
+
+        $applicationTitle = new Literal($rToolObject->title);
+        $predicateTitle = new Resource(TITLE);	
+        $this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle));
+
+        $applicationDescription = new Literal($rToolObject->description);
+        $predicateDescription = new Resource(DESCRIPTION);
+        $this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription));
+
+        $applicationStyle = new Literal($rToolObject->style);
+        $predicateStyle = new Resource(STYLE);
+        $this->model->add(new Statement($resourceApplication,$predicateStyle,$applicationStyle));
+		
+	$this->save();
+    }
+}
+
+?>
Index: Dev/trunk/classes/ApplicationCreationTool.php
===================================================================
--- Dev/trunk/classes/ApplicationCreationTool.php	(revision 117)
+++ 	(revision )
@@ -1,92 +1,0 @@
-<?php
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of ApplicationCreationTool
- *
- * @author fpvanagthoven
- */
-class ApplicationCreationTool {
-
-    private $application;
-
-    public function __construct($application = null) {
-        $this->application = $application;
-
-        $this->javascript();
-
-        $this->init();
-    }
-
-    private function javascript() {
-        ?>
-        <script type="text/javascript" src="js/creation.js"></script>
-        <script language="JavaScript" type="text/javascript">
-            function save(id){
-                var form = document.getElementById('applicationCreationForm');
-                var applicationUID = id;
-                                        
-                var applicationIDInput = document.createElement('input');
-                applicationIDInput.name = 'applicationUID';
-                applicationIDInput.value = applicationUID;
-                applicationIDInput.type = 'hidden';
-                                
-                form.appendChild(applicationIDInput);
-                                
-                form.submit();
-            }
-        </script>
-        <?php
-    }
-
-    private function init() {
-        ?>
-        <div id="creation">
-            <form id="applicationCreationForm" action="" method="post">
-                <?php
-                $this->title();
-                $this->description();
-
-                $this->save();
-                ?>
-            </form>
-        </div>
-        <?php
-    }
-
-    private function title() {
-        if (isset($this->application->title))
-            $value = $this->application->title;
-        else
-            $value = 'Untitled Application';
-        ?>
-        <input type="text" id="applicationTitle" class="titleBox" name="applicationTitle" value="<?php echo str_replace("\"", "&quot;", $value); ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
-        <?php
-    }
-
-    private function description() {
-        if (isset($this->application->description))
-            $value = $this->application->description;
-        else
-            $value = 'Write a description for this application here.';
-        ?>
-        <textarea id="applicationDescription" class="descriptionBox" name="applicationDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea>
-        <?php
-    }
-
-    private function save() {
-        if (isset($this->application)) {
-            $id = $this->application->id;
-        } else {
-            $id = null;
-        }
-        ?>
-        <input type="button" onclick="save('<?php echo $id; ?>')" class="surveyButton topRight" value="Save" />
-        <?php
-    }
-
-}
-?>
Index: Dev/trunk/classes/ApplicationDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/ApplicationDatabaseInterface.php	(revision 117)
+++ 	(revision )
@@ -1,77 +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 ApplicationDatabaseInterface
-{		
-    protected $applicationRDFWriter;
-    protected $applicationRDFReader;
-
-    protected $applicationID;
-
-
-    public function __construct($applicationID)
-    {		
-        if($applicationID == null)
-            $this->applicationID = md5( uniqid(rand(), true) );
-        else
-            $this->applicationID = $applicationID;
-			
-        $this->applicationRDFWriter = new ApplicationRDFWriter($this->applicationID);
-        $this->applicationRDFReader = new ApplicationRDFReader();
-    }
-    
-    public function getApplicationID()
-    {
-        return $this->applicationID;
-    }
-
-    public function setApplicationInfo($applicationInfo)
-    {
-        $appTitle = $applicationInfo['applicationTitle'];
-        $appDescription = $applicationInfo['applicationDescription'];
-        $appStyle = null;
-
-        $this->applicationRDFWriter->setApplicationInfo($appTitle, $appDescription, $appStyle);
-
-        $this->applicationRDFWriter->saveApplications();
-    }
-
-    public function getApplicationInfo($applicationID)
-    {
-        $applicationInfo = array();
-
-        $resultApplication = $this->applicationRDFReader->readApplicationInfo($applicationID);
-        
-        $applicationInfo['applicationID'] = $applicationID;
-        $applicationInfo['applicationTitle'] = $resultApplication[0]['?title']->label;
-        $applicationInfo['applicationDescription'] = $resultApplication[0]['?description']->label;
-        $applicationInfo['applicationStyle'] = $resultApplication[0]['?style']->label;
-        return $applicationInfo;
-    }
-
-    public function getExistingApplications()
-    {
-        $applicationInfo = array();
-
-        $resultApplication = $this->applicationRDFReader->readAllApplications();
-        if($resultApplication[0] != false)
-        {
-            for($aNumber = 0;$aNumber<sizeof($resultApplication[0]);$aNumber++)
-            {
-                $aID = $resultApplication[0][$aNumber]['?uid']->label;
-                $aTitle = $resultApplication[1][$aNumber]['?title']->label;
-                $applicationInfo[$aID] = $aTitle;
-            }
-        }
-
-        return $applicationInfo;
-    }
-}
-?>
Index: Dev/trunk/classes/ApplicationMenu.php
===================================================================
--- Dev/trunk/classes/ApplicationMenu.php	(revision 117)
+++ 	(revision )
@@ -1,62 +1,0 @@
-<?php
-
-/**
- * Description of ApplicationMenu
- *
- * @author fpvanagthoven
- */
-class ApplicationMenu extends Menu {
-
-    public function __construct($applications) {
-        ?><fieldset class="menu"><?php
-        parent::__construct('Application');
-        ?> <div class="menuButtons"> <?php
-        ApplicationMenu::createApplicationButton();
-        ApplicationMenu::loadApplicationButton();
-        ?> </div> <?php
-        ApplicationMenu::loadApplicationList($applications);
-        ?></fieldset><?php
-    }
-
-    public static function createApplicationButton() {
-        ?>
-
-        <form action="applicationcreation.php" method="post">
-
-            <input type="submit" value="New" class="surveyButton bigSurveyButton" />
-
-        </form>
-
-        <?php
-    }
-
-    /**
-     *
-     * @param Survey $surveys An array of surveys
-     */
-    public static function loadApplicationButton() {
-        ?>
-        <form id="loadApplicationForm" action="applicationcreation.php" method="post">
-            <input type="button" onclick="loadApplication()" value="Load / Edit" class="surveyButton bigSurveyButton" />
-        </form>
-
-
-        <?php
-    }
-
-    public static function loadApplicationList($applications) {
-        ?>
-        <select id="applicationsToLoad" class="toLoad" size="1000">
-            <?php
-            if (!empty($applications)) {
-                foreach ($applications as $application) {
-                    ?><option value='<?php echo $application->id; ?>'><?php echo $application->title; ?></option><?php
-            }
-        }
-            ?>
-        </select>
-        <?php
-    }
-
-}
-?>
Index: Dev/trunk/classes/ApplicationRDFReader.php
===================================================================
--- Dev/trunk/classes/ApplicationRDFReader.php	(revision 117)
+++ 	(revision )
@@ -1,127 +1,0 @@
-<?php
-
-class ApplicationRDFReader
-{
-    protected $model;
-    protected $fileName;
-
-    public function __construct()
-    {
-        $this->fileName = 'data/applications/applications.rdf';
-    
-        $this->reloadApplications();
-    }
-    
-    public function reloadApplications()
-    {
-        // Create empty MemModel   
-        $factory = new ModelFactory();
-        $this->model = $factory->getDefaultModel();
-        
-        if(file_exists($this->fileName))
-            $this->model->load($this->fileName);
-    }
-
-    public function readApplicationInfo($applicationID)
-    {        
-        $this->reloadApplications();
-        
-        $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 	;
-                                        predicates: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 $result;
-    }
-
-    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 ;
-                                        predicates: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 117)
+++ 	(revision )
@@ -1,56 +1,0 @@
-<?php
-
-class ApplicationRDFWriter
-{
-    protected $model;
-    protected $fileName = 'data/applications/applications.rdf';
-
-    public function __construct($applicationID)
-    {
-        // Create empty MemModel
-        $factory = new ModelFactory();
-        $this->model = $factory->getDefaultModel();
-
-        $this->applicationID = $applicationID;		
-        
-        if (!is_dir('data/applications/'))
-            mkdir('data/applications/');	
-        
-        if(file_exists($this->fileName))
-            $this->model->load($this->fileName);
-    }	
-
-    public function saveApplications()
-    {	
-        $this->model->saveAs($this->fileName,'rdf'); 
-    }
-
-    public function setApplicationInfo($aTitle, $aDescription, $aStyle)
-    {              
-        $resourceApplication = new Resource(APPLICATION.'/'.$this->applicationID);
-        //remove the old values...
-        $this->model->subtract($this->model->find($resourceApplication, null, null));        
-       
-        //...and add the new ones!
-        $resourceApplicationType = new Resource(APPLICATION);
-        $predicateRType = new Resource(RTYPE);
-        $this->model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType));
-        $literalApplicationID = new Literal($this->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/DashboardCreationDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/DashboardCreationDatabaseInterface.php	(revision 117)
+++ 	(revision )
@@ -1,65 +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 DashboardCreationDatabaseInterface
-{    
-    protected $dashboardRDFWriter;
-    protected $dashboardRDFReader;
-    
-    public function __construct($dashID)
-    {
-        if($dashID == null)
-            $dashboardID = md5( uniqid(rand(), true) );
-        else
-            $dashboardID = $dashID;
-        
-        $this->dashboardRDFWriter = new DashboardRDFWriter($dashboardID);
-        $this->dashboardRDFReader = new DashboardRDFReader($dashboardID);
-    }
-    
-    public function setDashboardInfo($dashboard,$user)
-    {
-        $dTitle = $dashboard['dashboardTitle'];
-        $dDescription = $dashboard['dashboardDescription'];
-        
-        $dCreatorID = $user['username'];
-        
-        $this->dashboardRDFWriter->createDashboard($dTitle, $dDescription, $dCreatorID);
-        
-        $gNumber = 1;
-        while (isset($dashboard['graphTitle'.$gNumber]))
-        {
-            if (isset($dashboard['graphID'.$gNumber]))
-                $gID = $dashboard['graphID'.$gNumber];
-            else
-                $gID = md5( uniqid(rand(), true) );
-            $gTitle = $dashboard['graphTitle'.$gNumber];
-            $gDescription = $dashboard['graphDescription'.$gNumber];
-            
-            $gTypes = array();
-            $tNumber = 1;
-            while(isset($dashboard['g'.$gNumber.'type'.$tNumber]))
-            {
-                $gTypes[] = $dashboard['g'.$gNumber.'type'.$tNumber];
-                $tNumber++;
-            }
-            $gData = array();
-            $dNumber = 1;
-            while(isset($dashboard['g'.$dNumber.'datatype'.$tNumber]) && isset($dashboard['g'.$gNumber.'dataid'.$dNumber]))
-            {
-                $dData = array();
-                $dData['type'] = $dashboard['g'.$gNumber.'datatype'.$dNumber];
-                $dData['id'] = $dashboard['g'.$gNumber.'dataid'.$dNumber];
-                $gData[] = $dData;
-                $dNumber++;
-            }
-        }
-    }
-}
-
-?>
Index: Dev/trunk/classes/DashboardRDFReader.php
===================================================================
--- Dev/trunk/classes/DashboardRDFReader.php	(revision 117)
+++ 	(revision )
@@ -1,151 +1,0 @@
-<?php
-
-class DashboardRDFReader
-{
-    protected $model;
-
-    protected $dashboardID;
-    protected $filePath;
-
-    public function __construct($dashboardID)
-    {
-        // Create empty MemModel
-        $factory = new ModelFactory();
-        $this->model = $factory->getDefaultModel();
-
-        $this->dashboardID = $dashboardID;
-        $this->filePath = 'data/dashboards/dashboard_'.$this->dashboardID.'.rdf';
-    }
-    
-    public function loadDashboard()
-    {
-        if(file_exists($this->filePath))
-        {
-            $this->model->load($this->filePath);
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
-    
-    public function getDashboardInfo()
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?uid ?title ?description ?creator
-            WHERE 	
-            {
-                    _dashboard	predicates:resource_type	resources:dashboard ;
-                                predicates:uid			?uid	;
-                                predicates:title 		?title 	;
-                                predicates:description		?description ;
-                                predicates:creator		?creator
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-    
-    public function readDashboardGraphs()
-    {
-        $result = array();
-        $result[] = $this->readSDashboardGraphsTitle();				
-        $result[] = $this->readDashboardGraphsDescription();
-
-        return $result;
-    }
-
-    public function readDashboardGraphsTitle()
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?graphTitle
-            WHERE 
-            {	
-                    _graph	predicates:resource_type	resources:graph ;
-                                predicates:title		?graphTitle 		
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-
-    public function readDashboardGraphsDescription()
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?graphDescription
-            WHERE 
-            {	
-                    _graph	predicates:resource_type	resources:graph ;
-                                predicates:description		?graphDescription 		
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-
-    public function readDashboardGraphsID()
-    {
-        $querystring = '
-            PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT 	?graphID
-            WHERE 
-            {	
-                    _graph	predicates:resource_type	resources:graph ;
-                                predicates:uid			?graphID				
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-
-    public function readGraphTypes($graphID)
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?type
-            WHERE 
-            {
-                    _graph	predicates:resource_type	resources:graph ;
-                                predicates:uid			"' . $graphID . '"  ;
-                                predicates:graph_type		?type
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-    
-    public function readGraphData($graphID)
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?datatype ?dataid
-            WHERE 
-            {
-                    _graph	predicates:resource_type	resources:graph ;
-                                predicates:uid			"' . $graphID . '"  .
-                    _data       predicates:has_data             resources:data  ;
-                                predicates:data_type		?datatype   ;
-                                predicates:uid                  ?dataid
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-}
-?>
Index: Dev/trunk/classes/DashboardRDFWriter.php
===================================================================
--- Dev/trunk/classes/DashboardRDFWriter.php	(revision 117)
+++ 	(revision )
@@ -1,95 +1,0 @@
-<?php
-
-class DashboardRDFWriter 
-{
-    protected $model;
-
-    protected $resourceDashboard;
-    protected $dashboardID;
-
-    protected $filePath;
-
-    public function __construct($dashboardID)
-    {
-        // Create empty MemModel
-        $factory = new ModelFactory();
-        $this->model = $factory->getDefaultModel();
-
-        $this->dashboardID = $dashboardID;	
-        $this->filePath = 'data/dashboards/';
-        if (!is_dir($this->filePath))
-            mkdir($this->filePath);	
-    }	
-
-    public function saveDashboard()
-    {	
-        $this->model->saveAs($this->filePath.'dashboard_'.$this->dashboardID.'.rdf','rdf');
-    }
-    
-    public function createDashboard($dTitle, $dDescription, $dCreatorID)
-    {
-        $this->resourceDashboard = new Resource(DASHBOARD.'/'.$this->dashboardID);
-
-        $resourceDashboardType = new Resource(DASHBOARD);
-        $predicateRType = new Resource(RTYPE);
-        $this->model->add(new Statement($this->resourceDashboard,$predicateRType,$resourceDashboardType));
-
-        $literalDashboardID = new Literal($this->dashboardID);
-        $predicateUniqueID = new Resource(UID);
-        $this->model->add(new Statement($this->resourceDashboard,$predicateUniqueID,$literalDashboardID));
-
-        $predicateTitle = new Resource(TITLE);		
-        $dashboardTitle = new Literal($dTitle);
-        $this->model->add(new Statement($this->resourceDashboard,$predicateTitle,$dashboardTitle));		
-
-        $predicateDescription = new Resource(DESCRIPTION);
-        $dashboardDescription = new Literal($dDescription);
-        $this->model->add(new Statement($this->resourceDashboard,$predicateDescription,$dashboardDescription));
-        
-        $predicateCreator = new Resource(CREATOR);
-        $userID = new Literal($dCreatorID);
-        $this->model->add(new Statement($this->resourceDashboard,$predicateCreator,$userID));
-    }
-    
-    public function addGraph($gID,$gTitle,$gDescription,$gTypes,$gData)
-    {
-        $resourceGraph = new Resource(GRAPH);
-        
-        $predicateTitle = new Resource(TITLE);		
-        $graphTitle = new Literal($gTitle);
-        $this->model->add(new Statement($resourceGraph,$predicateTitle,$graphTitle));		
-
-        $predicateDescription = new Resource(DESCRIPTION);
-        $graphDescription = new Literal($gDescription);
-        $this->model->add(new Statement($resourceGraph,$predicateDescription,$graphDescription));
-        
-        $predicateUniqueID = new Resource(UID);
-        $graphID = new Literal($gID);
-        $this->model->add(new Statement($resourceQuestion,$predicateUniqueID,$graphID));
-        
-        $predicateGraphType = new Resource(GRAPH_TYPE);
-        foreach($gTypes as $gType)
-        {
-            $graphType = new Literal($gType);
-            $this->model->add(new Statement($resourceGraph,$predicateGraphType,$gType));
-        }
-        
-        $predicateData = new Resource(HAS_DATA);
-        foreach($gData as $gThis)
-        {
-            $resourceData = new Resource(DATA);
-            $this->model->add(new Statement($resourceGraph,$predicateData,$resourceData));
-            
-            $dataType = new Literal($gThis['type']);
-            $predicateDataType = new Resource(DATA_TYPE);
-            $this->model->add(new Statement($resourceData,$predicateDataType,$dataType));
-            
-            $dataID = new Literal($gThis['id']);
-            $this->model->add(new Statement($resourceData,$predicateUniqueID,$dataID));            
-        }
-        
-        $predicateHasGraph = new Resource(HAS_GRAPH);
-        $this->model->add(new Statement($this->resourceDashboard,$predicateHasGraph,$resourceGraph));
-    }
-}
-?>
Index: Dev/trunk/classes/DashboardTool.php
===================================================================
--- Dev/trunk/classes/DashboardTool.php	(revision 117)
+++ 	(revision )
@@ -1,98 +1,0 @@
-<?php
-
-/**
- * Description of DashboardTool
- *
- * @author Frans
- */
-class DashboardTool {
-
-    private $surveys;
-    private $gamedata;
-
-    public function __construct($surveys, $gamedata = null) {
-        $this->surveys = $surveys;
-        $this->gamedata = $gamedata;
-
-        $this->init();
-    }
-
-    private function init() {
-        $this->visualizeSurvey();
-    }
-
-    private function visualizeSurvey() {
-        foreach ($this->surveys as $survey) {
-            $surveyResults = $survey->results;
-
-            /* iterate at the same time through these arrays */
-            $questions = $survey->questions;
-            $questionResults = $surveyResults->getQuestionResults();
-            ?>
-            <div class="resultsDiv borderRadius padding1em">
-                <?php
-                $i = 0;
-                while (isset($questions[$i])) {
-                    ?><div class="resultDiv"><?php        
-                    $this->displayQuestion($questions[$i]);
-                    $this->visualizeResult($questionResults[$i]);
-                    ?></div><?php
-                    
-                    $i++;
-                }
-                ?>
-            </div>
-                <?php
-            }
-        }
-
-        private function visualizeResult($questionResult) {
-            
-        $this->displayVisualization($questionResult);
-        $this->displayChangeVisualizationBar();
-            
-    }
-
-    private function displayQuestion($question) {
-        echo $question->title;
-        echo "<br />";
-        echo $question->description;
-    }
-
-    private function displayVisualization($questionResult) {
-        $type = $questionResult->getType();
-        
-        switch ($type) {
-            case 0:
-                $value = "TEXT";
-
-                break;
-            case 1:
-                $value = "INTEGER";
-                break;
-            case 2:
-                $value = "MULT. CHOICE";
-                break;
-            case 3:
-                $value = "CHECKBOXES";
-                break;
-            case 4:
-                $value = "SCALE";
-                break;
-            default:
-                break;
-        }
-        echo $value;
-        
-        foreach($questionResult->answers as $answer)
-        {
-            echo "<br />" . $answer;
-        }
-    }
-
-    private function displayChangeVisualizationBar() {
-        
-    }
-
-}
-    ?>
Index: Dev/trunk/classes/DatabaseInterface.php
===================================================================
--- Dev/trunk/classes/DatabaseInterface.php	(revision 131)
+++ Dev/trunk/classes/DatabaseInterface.php	(revision 131)
@@ -0,0 +1,91 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of DatabaseInterface
+ * Initializes all the connectors, serves as only entrance and exit point
+ * for the frontend
+ * @author jkraaijeveld
+ */
+class DatabaseInterface {
+    
+    /**
+     * Constructor for the DatabaseInterface class
+     */
+    private $applicationConnector;
+    private $questionConnector;
+    private $userConnector;
+    
+    /**
+     * Constructor for DatabaseInterface.
+     * Initializes all the connectors.
+     */
+    public function __construct() {
+        $this->applicationConnector = new ApplicationConnector();
+        $this->questionConnector = new QuestionConnector();
+        $this->userConnector = new UserConnector();
+    }
+    
+    /**
+     * Get the data corresponding to the given type and arguments
+     * @param type $type
+     * @param type $arguments
+     * @return type 
+     */
+    public function get($type, $arguments)
+    {
+        switch(strtolower($type))
+        {
+            case "application":
+                return $this->applicationConnector->get($arguments);
+                break;
+            case "question":
+                return $this->questionConnector->get($arguments);
+                break;
+            case "user":
+                return $this->userConnector->get($arguments);
+                break;
+        }
+    }
+	
+    /**
+     * Saves the given object based on its class.
+     * @param type $rToolObject 
+     */
+    public function set($rToolObject)
+    {
+        switch(get_class($rToolObject))
+        {
+            case "Application":
+                $this->applicationConnector->set($rToolObject);
+                break;
+            case "Question":
+                $this->questionConnector->set($rToolObject);
+                break;
+            case "User":
+                $this->userConnector->set($rToolObject);
+                break;
+        }
+    }
+    
+    /**
+     * Saves all the objects in the given array, assuming they are 
+     * valid ResearchToolObjects.
+     * @param type $rToolObjects 
+     */
+    public function batchSet($rToolObjects)
+    {
+        foreach ($rToolObjects as $rToolObject)
+        {
+            $this->set($rToolObject);
+        }
+    }
+
+	
+}
+
+?>
Index: Dev/trunk/classes/IConnector.php
===================================================================
--- Dev/trunk/classes/IConnector.php	(revision 131)
+++ Dev/trunk/classes/IConnector.php	(revision 131)
@@ -0,0 +1,21 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of Connector
+ *
+ * @author jkraaijeveld
+ */
+interface IConnector {
+    //This class will outline everything a Connector needs to operate within the system
+    public function get($arguments);
+    public function set($rToolObject);
+    public function load();
+    public function save();
+}
+
+?>
Index: Dev/trunk/classes/Loader.php
===================================================================
--- Dev/trunk/classes/Loader.php	(revision 117)
+++ 	(revision )
@@ -1,73 +1,0 @@
-<?php
-
-/**
- * Helper class to load arrays of objects from the database.
- *
- * @author fpvanagthoven
- */
-class Loader {
-
-    public static function load($info, $classname) {
-        $theArray = array();
-        
-        foreach ($info as $id => $title)
-        {
-            $object = new $classname($id, $title);
-            array_push($theArray, $object);
-        }
-        
-        return $theArray;
-    }
-
-    /**
-     *
-     * @return array Array of Surveys with id and title
-     */
-    public static function loadSurveys() {
-    
-        $surveyDBI = new SurveyCreationDatabaseInterface(null);
-        $surveyIDTitles = $surveyDBI->getExistingSurveys();
-
-        return Loader::load($surveyIDTitles, "Survey");
-    }
-
-    public static function loadApplications() {
-        $applicationDBI = new ApplicationDatabaseInterface(null);
-        $applicationTitles = $applicationDBI->getExistingApplications();
-
-        return Loader::load($applicationTitles, "Application");
-    }
-
-    public static function loadSessions() {
-        $sessionDBI = new SessionCreationDatabaseInterface(null);
-        $sessionTitles = $sessionDBI->getExistingSessions();
-
-        return Loader::load($sessionTitles, "Session");
-    }
-
-    public static function loadQuestions() {
-        $questionDBI = new QuestionCreationDatabaseInterface();
-        $questionCodesAndTitles = $questionDBI->getExistingQuestions();
-
-        return Loader::load($questionCodesAndTitles, "Question");
-    }
-    
-    public static function loadFullQuestions() {
-        $questionDBI = new QuestionCreationDatabaseInterface();
-        $questionCodesAndTitles = $questionDBI->getExistingQuestions();
-        
-        $questions = array();
-        
-        foreach ($questionCodesAndTitles as $code => $title) {
-            $info = $questionDBI->getQuestionInfo($code);
-            $question = Question::getQuestion($code, $info);
-            
-            array_push($questions, $question);
-        }
-        
-        return $questions;
-    }
-
-}
-
-?>
Index: Dev/trunk/classes/Logo.php
===================================================================
--- Dev/trunk/classes/Logo.php	(revision 117)
+++ 	(revision )
@@ -1,21 +1,0 @@
-<?php
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of Logo
- *
- * @author fpvanagthoven
- */
-class Logo {
-
-    public function __construct() {
-        ?>
-        <div id="logo"><a href="index.php">CPSFacilitator Tool</a></div>
-        <?php
-    }
-
-}
-?>
Index: Dev/trunk/classes/Menu.php
===================================================================
--- Dev/trunk/classes/Menu.php	(revision 117)
+++ 	(revision )
@@ -1,25 +1,0 @@
-<?php
-
-/**
- * Description of Menu
- *
- * @author fpvanagthoven
- */
-class Menu {
-
-    private $title;
-
-    public function __construct($title) {
-        $this->title = $title;
-
-        $this->menuTitle();
-    }
-
-    public function menuTitle() {
-        ?>
-        <legend><h2><?php echo $this->title; ?></h2></legend>
-        <?php
-    }
-
-}
-?>
Index: Dev/trunk/classes/Question.php
===================================================================
--- Dev/trunk/classes/Question.php	(revision 117)
+++ Dev/trunk/classes/Question.php	(revision 131)
@@ -11,46 +11,29 @@
  * @author fpvanagthoven
  */
-class Question {    
-    public $code;
+class Question extends ResearchToolObject{    
     public $title;
     public $type;
     public $description;
+    public $category;
     public $answers; // format answers['#']
-    public $category;
     
-    public function __construct($code, $title = null, $type = null, $description = null)
+    /**
+     * Constructor for a Question. $uid equals the corresponding code.
+     * @param type $uid
+     * @param type $title
+     * @param type $type
+     * @param type $description
+     * @param type $category
+     * @param type $answers 
+     */
+    public function __construct($uid, $title = null, $type = null, $description = null, $category = null, $answers = null)
     {
-        $this->code = $code;
+        $this->uid = $uid;
         $this->title = $title;
         $this->type = $type;
         $this->description = $description;
-        $this->answers = array();
+        $this->category =  $category;
+        $this->answers = $answers;
     }
-    
-    /* reminder that constructor doesn't contain category haha */
-    public function setCategory($category)
-    {
-        $this->category = $category;
-    }
-    
-    public static function getQuestion($code, $info)
-    {
-        $question = new Question($code);
-        $question->title = $info['questionTitle'];
-        $question->type = $info['questionType'];
-        if(isset($info['questionDescription']))
-            $question->description = $info['questionDescription'];
-        $question->category = $info['questionCategory'];
-        
-        $i = 1;
-        while (isset($info['ans' . $i]))
-        {
-            array_push($question->answers, $info['ans' . $i]);
-            $i++;
-        }
-        
-        return $question;
-    }
-
 }
 
Index: Dev/trunk/classes/QuestionConnector.php
===================================================================
--- Dev/trunk/classes/QuestionConnector.php	(revision 131)
+++ Dev/trunk/classes/QuestionConnector.php	(revision 131)
@@ -0,0 +1,189 @@
+<?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");
+
+
+/**
+ * Description of QuestionConnector
+ *
+ * @author jkraaijeveld
+ */
+class QuestionConnector implements IConnector {
+    
+    protected $model;
+    protected $fileName = 'data/questions/questions.rdf';
+    
+    /**
+     * Constructor for QuestionConnector
+     */
+    public function __construct()
+    {
+        //Ensure the required folder for this connector exists
+        if (!is_dir('data/questions/'))
+            mkdir('data/questions/');	
+    }
+    
+    /**
+     * function load()
+     * Loads the file into the standard MemModel.
+     */
+    public function load() {
+        //Get the Memory Model from the ModelFactory
+        $this->model = ModelFactory::getDefaultModel();
+        
+        //Ensure the required file exists before loading
+        if(file_exists($this->fileName))
+            $this->model->load($this->fileName);
+    }
+    
+    /**
+     * function save()
+     * Saves the MemModel into the given file.
+     */
+    public function save() {
+        $this->model->saveAs($this->fileName,'rdf'); 
+    }
+    
+    /**
+     * Get the questions corresponding to the arguments.
+     * @param type $arguments 
+     * @return type Array
+     */
+    public function get($arguments)
+    {
+        $this->load();
+        
+        $keys = array_keys($arguments);
+        //Set default values for arguments
+        $uid = "?uid"; $title = "?title"; $type = "?type"; $description = "?description"; $category = "?category";
+        //Set the arguments if they are supplied
+        if(in_array("uid", $keys))
+            $uid = '\''.$arguments["uid"].'\'';
+        if(in_array("title", $keys))
+            $title = '\''.$arguments["title"].'\'';
+        if(in_array("type", $keys))
+            $type = '\''.$arguments["type"].'\'';
+        if(in_array("description", $keys))
+            $description = "\"".$arguments["description"]."\"";
+        if(in_array("category", $keys))
+            $style = "\"".$arguments["category"]."\"";
+           
+        $querystring = '
+         PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT DISTINCT ?uid, ?title, ?type, ?description, ?category
+            WHERE 	
+            {
+                _question	predicates:resource_type	resources:question ;                
+                predicates:question_code ?uid ;
+                predicates:title ?title ;
+                predicates:question_type ?type ;
+                predicates:description ?description ;
+                predicates:question_category ?category ;
+
+                predicates:question_code ' . $uid . '
+                predicates:title ' . $title . '
+                predicates:question_type ' . $type . '
+                predicates:description ' . $description . '
+                predicates:question_category ' . $category . ' 
+            }';
+        //Create the querystring 
+        $results = $this->model->sparqlQuery($querystring);
+        
+        $questions = array();
+        if(!empty($results))
+        {
+            foreach($results as $result)
+            {
+                $answers = $this->getAnswers($result['?uid']->label);
+                $questions[] = new Question($result['?uid']->label, $result['?title']->label, $result['?type']->label, $result['?description']->label, $result['?category']->label, $answers);
+            }
+        }
+        return $questions;
+    }
+    
+    /**
+     * Gets the answers belonging to the given uid.
+     * @param type $uid
+     * @return type Array 
+     */
+    private function getAnswers($uid)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT DISTINCT ?has_answer
+            WHERE
+            {
+                 _question	predicates:resource_type	resources:question ;
+                predicates:has_answer ?has_answer ; 
+                predicates:question_code \'' . $uid . '\'
+            }';
+
+        $answers = $this->model->sparqlQuery($querystring);
+        $returnArray = array();
+        if(!empty($answers))
+        {
+            foreach($answers as $answer)
+            {
+                $returnArray[] = $answer['?has_answer']->label;
+            }
+        }
+        return $returnArray;
+    }
+
+    
+    /**
+     * Save the given ResearchTool object
+     * @param type $rToolObject 
+     */
+    public function set($rToolObject)
+    {
+        $this->load();
+        
+        $resourceQuestion = new Resource(QUESTION.'/'.$rToolObject->uid);        
+        //Remove the old value stored with the given id
+        $this->model->subtract($this->model->find($resourceQuestion, null, null));
+        
+        //Save all the new values
+        $resourceQuestionType = new Resource(QUESTION);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
+        
+        $questionQCode = new Literal($rToolObject->uid);
+        $predicateQCode = new Resource(QCODE);
+        $this->model->add(new Statement($resourceQuestion,$predicateQCode,$questionQCode));
+        
+        $questionTitle = new Literal($rToolObject->title);
+        $predicateTitle = new Resource(TITLE);		
+        $this->model->add(new Statement($resourceQuestion,$predicateTitle,$questionTitle));	
+
+        $questionDescription = new Literal($rToolObject->description);
+        $predicateDescription = new Resource(DESCRIPTION);
+        $this->model->add(new Statement($resourceQuestion,$predicateDescription,$questionDescription));		
+
+        $resourceQuestionType = new Literal($rToolObject->type);
+        $predicateQType = new Resource(QTYPE);
+        $this->model->add(new Statement($resourceQuestion,$predicateQType,$resourceQuestionType));
+        
+        $questionQCategory = new Literal($rToolObject->category);
+        $predicateQCategory = new Resource(QCATEGORY);
+        $this->model->add(new Statement($resourceQuestion,$predicateQCategory,$questionQCategory));
+
+        if(isset($rToolObject->answers))
+        {
+            foreach($rToolObject->answers as $answer)
+            {		
+                $answerValue = new Literal($answer);
+                $predicateAnswer = new Resource(HAS_ANSWER);	
+                $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$answerValue));
+            }
+        }
+        $this->save();
+    }
+}
+
+?>
Index: Dev/trunk/classes/QuestionCreationDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/QuestionCreationDatabaseInterface.php	(revision 117)
+++ 	(revision )
@@ -1,117 +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");
-
-/**
- * Description of QuestionCreationDatabaseInterface
- *
- * @author basvannuland
- */
-class QuestionCreationDatabaseInterface {
-   
-    protected $questionRDFWriter;
-    protected $questionRDFReader;
-    
-    public function __construct()
-    {
-        $this->questionRDFWriter = new QuestionRDFWriter();
-        $this->questionRDFReader = new QuestionRDFReader();
-    }
-    
-    public function setQuestionInfo($question)
-    {
-        $qCode = $question['questionCode'];
-        $qTitle = $question['questionTitle'];
-        $qDescription = $question['questionDescription'];
-        $qType = $question['questionType'];
-        $qCategory = $question['questionCategory'];
-
-        $qAnswers = array();
-        $aNumber = 1;
-        while (isset($question['ans'.$aNumber]))
-        {
-            $qAnswers[] = $question['ans'.$aNumber];
-
-            $aNumber++;
-        }
-
-        if($this->checkQuestionCodeExists($qCode))
-        {
-            return 'Question code (' . $qCode . ') already in use. Please try a new code.';
-        }
-        else {
-            $this->questionRDFWriter->createQuestion($qTitle,$qDescription,$qType,$qCode,$qCategory,$qAnswers);
-            $this->questionRDFWriter->saveQuestions(); 
-            return 'Question saved';
-        }         
-    }
-    
-    public function getQuestionInfo($qCode)
-    {
-        $questionInfo = array();
-        
-        $question = $this->questionRDFReader->readQuestionByCode($qCode);
-        
-        $questionInfo['questionTitle'] = $question['title'][0]['?questionTitle']->label;
-        $questionInfo['questionDescription'] = $question['description'][0]['?questionDescription']->label;
-        $questionInfo['questionType'] = $question['type'][0]['?questionType']->label;
-        $questionInfo['questionCategory'] = $question['category'][0]['?questionCategory']->label;
-        if ($question['answers'] != null)
-        {
-            for($aNumber = 1;$aNumber<=sizeof($question['answers']);$aNumber++)
-            {
-                $questionInfo['ans'.$aNumber] = $question['answers'][$aNumber-1]['?answerDescription']->label;
-            }
-        }
-        
-        return $questionInfo;
-    }
-    
-    public function getExistingQuestions()
-    {
-        $questions = array();
-
-        $resultQuestions = $this->questionRDFReader->readQuestionCodes();
-        $this->questionRDFReader->reloadQuestions();
-        if ($resultQuestions != null)
-        {
-            foreach ($resultQuestions as $questionCodeObject)
-            {
-                $questionCode = $questionCodeObject['?questionCode']->label;
-                $questionTitle = $this->questionRDFReader->readQuestionTitle($questionCode);
-                $questions[$questionCode] = $questionTitle[0]['?questionTitle']->label;
-            }
-        }
-
-        return $questions;
-    }
-    
-    public function checkQuestionCodeExists($qCode)
-    {
-        $result = false;
-
-        $questionCodes = $this->questionRDFReader->readQuestionCodes();
-        
-        if ($questionCodes != null)
-        {
-            foreach($questionCodes as $questionCode)
-            {
-                $code = $questionCode['?questionCode']->label;
-                if(!strcmp($code ,$qCode))
-                {
-                    $result = true;
-                    break;
-                }
-            }
-        }
-
-        return $result;
-    }
-}
-
-?>
Index: Dev/trunk/classes/QuestionCreationTool.php
===================================================================
--- Dev/trunk/classes/QuestionCreationTool.php	(revision 117)
+++ 	(revision )
@@ -1,473 +1,0 @@
-<?php
-
-/**
- * Tool that displays a list and an edit panel
- *
- * @author fpvanagthoven
- */
-class QuestionCreationTool {
-
-    private $questions;
-
-    public function __construct($questions) {
-        $this->questions = $questions;
-
-        $this->loadQuestionsToJavascript();
-        $this->javascript();
-        $this->displayList();
-        $this->displayEditPanel();
-    }
-    
-    /**
-     * Loads the questions that PHP retrieved from database
-     * into javascript. This is done so that the page does not need
-     * to refresh in order to load an entire question in to the form.
-     * 
-     * The javascript array will have question codes as keys.
-     * The value is a javascript Question object that gets created from
-     * the PHP object.
-     */
-    private function loadQuestionsToJavascript()
-    {
-//        ?><script type="text/javascript">
-        document.questions = array();
-        
-        //<?php
-//        foreach ($this->questions as $question) {
-//            ?>
-            
-            
-            
-            //<?php
-//        }
-//        ?></script><?php
-    }
-
-    private function javascript() {
-        ?>
-        <script type="text/javascript">
-            function handleType(select)
-            {
-                var type = select.valueOf().value;
-                clearSpecifications();
-                                                                                                        
-                /* set answerCount for options */
-                document.getElementById("answerSpecifications").answerCount = 1;
-                                                                                                        
-                switch (type) {
-                    case "text":
-                        break;
-                    case "mc":
-                        addOption();
-                        break;
-                    case "int":
-                        minMax();
-                        break;
-                    case "checkboxes":
-                        addOption();
-                        break;
-                    case "scale":
-                        minMaxIncr();
-                        break;
-                    default:
-                                                                                                                
-                        break;
-                }
-
-            }
-                                                                                                    
-            function clearSpecifications()
-            {
-                var specs = document.getElementById("answerSpecifications");
-                specs.innerHTML = "";
-                specs.clicked = null;
-                specs.lastAnswer = null;
-                                                                                        
-                var questionType = document.getElementById("questionType");
-                var buttons = document.getElementById("questionButtons");
-                if(buttons != null)
-                    questionType.removeChild(buttons);
-            }
-                                                                                                    
-            function addOption()
-            {                       
-                var specs = document.getElementById("answerSpecifications");
-                                                                                                        
-                addAddRemoveOptionButtonsOnce(specs);
-                addAnswerInput(specs);
-                                                                                                        
-            }
-                                                                                                    
-            function removeOption()
-            {
-                var specs = document.getElementById("answerSpecifications");
-                                                                                                        
-                if(specs.lastAnswer.prev != null)
-                {
-                    specs.removeChild(specs.lastAnswer);
-                    specs.lastAnswer = specs.lastAnswer.prev;
-                    specs.answerCount--;
-                }
-            }
-                                                                                                    
-            function addAnswerInput(specs)
-            {
-                var answerCount = specs.answerCount;
-                                                                                                        
-                /* set value for option textbox */
-                var optionStr = "Option " + answerCount;
-                                                                                                        
-                /* the input textbox */
-                var answerInput = document.createElement("input");
-                answerInput.setAttribute("type", "text");
-                answerInput.setAttribute("name", "ans" + answerCount);
-                answerInput.setAttribute("value", optionStr);
-                answerInput.className = "answerInput";
-                                                                                                        
-                specs.appendChild(answerInput);
-                                                                                                        
-                /* Singly linked list */
-                answerInput.prev = specs.lastAnswer; // remember last one
-                specs.lastAnswer = answerInput; // new lastAnswer
-                                                                                                        
-                specs.answerCount++;               
-            }
-                                                                                                    
-            function addAddRemoveOptionButtonsOnce(specs)
-            {
-                if (specs.clicked == null)
-                {
-                    var buttonsDiv = document.createElement("div");
-                    buttonsDiv.id = "questionButtons";
-                    buttonsDiv.style.display = "inline";
-                    var typeBox = document.getElementById("questionType");
-                    typeBox.appendChild(buttonsDiv);
-                                                                                            
-                    addAddOptionButton(buttonsDiv);                                  
-                    addRemoveOptionButton(buttonsDiv);
-                                                                                                            
-                    specs.clicked = true;
-                }
-            }
-                                                                                                    
-            function addAddOptionButton(buttonsDiv)
-            {    
-                var addOpt = document.createElement("input");
-                addOpt.setAttribute("type", "button");
-                addOpt.setAttribute("id", "addOpt");
-                addOpt.setAttribute("class", "surveyButton");
-                addOpt.setAttribute("onclick", "addOption()");
-                addOpt.setAttribute("value", "Add Option");
-                buttonsDiv.appendChild(addOpt);                                  
-            }
-                                                                                                    
-            function addRemoveOptionButton(buttonsDiv)
-            {
-                var removeOpt = document.createElement("input");
-                removeOpt.setAttribute("type", "button");
-                removeOpt.className = "surveyButton";
-                removeOpt.setAttribute("onclick", "removeOption()");
-                removeOpt.setAttribute("value", "x");
-                buttonsDiv.appendChild(removeOpt);
-            }
-                                                                                                   
-            function minMax(min, max)
-            {
-                if (min == null)
-                    var min = '';
-                if (max == null)
-                    var max = '';
-                                                                                                                                                                                                                                                                                                                                
-                var specs = document.getElementById("answerSpecifications");
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
-                var answerDiv = document.createElement("div");
-                                                                                                                                                                                                                                                                                                                                                                                                                                        
-                answerDiv.className = "answerDiv";
-                answerDiv.innerHTML = "<label for='min'>Min</label><input type='text' class='intBox' onchange='checkInt(this)' value='" + min + "' name='ans1' />" +
-                    "<label for='max'>Max</label><input type='text' class='intBox' onchange='checkInt(this)' value='" + max + "' name='ans2' />";
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
-                specs.appendChild(answerDiv);
-            }      
-                                                                            
-            function checkInt(input)
-            {
-                input.style.borderWidth = '1px' ;
-                var value = input.value;
-                if (isNaN(value))
-                {
-                    input.style.borderColor = 'red';
-                    input.checkPassed = 'no';
-                }
-                else
-                {
-                    input.style.border = '1px solid #888;';
-                    input.checkPassed = null;
-                }
-            }
-                                                            
-            function minMaxIncr(left, right, incr)
-            {
-                if (left == null)
-                    var left = '';
-                else
-                    left.replace("'", "&#39;");
-                if (right == null)
-                    var right = '';
-                else
-                    right.replace("'", "&#39;");
-                if (incr == null)
-                    var incr = '';
-                                                                                                                                                                                                                                                        
-                var specs = document.getElementById("answerSpecifications");
-                                                                                                                                                                                                                                                                                                                                                                                                                                               
-                var answerDiv = document.createElement("div");
-                answerDiv.className = "answerDiv";
-                                                                                                                                                                               
-                var leftLabel = document.createElement("label");
-                var rightLabel = document.createElement("label");
-                var scaleLabel = document.createElement("label");
-                leftLabel.innerHTML = "Left label";
-                rightLabel.innerHTML = "Right label";
-                scaleLabel.innerHTML = "Scale count";
-                                                                                                                                                                                
-                var leftInput = document.createElement("input");
-                leftInput.type = "text";
-                leftInput.value = left;
-                leftInput.name= "ans1";
-                leftInput.setAttribute("onchange", "handleAnswerChange()");
-                                                                                                                                                                                
-                var rightInput = document.createElement("input");
-                rightInput.type = "text";
-                rightInput.value = right;
-                rightInput.name = "ans2";
-                rightInput.setAttribute("onchange", "handleAnswerChange()");
-                                                                                                                                                                                
-                var scaleInput = document.createElement("input");
-                scaleInput.type = "text";
-                scaleInput.className = "intBox";
-                scaleInput.value = incr;
-                scaleInput.setAttribute("onblur", "checkInt(this)");
-                scaleInput.setAttribute("onchange", "");
-                scaleInput.name = "ans3";
-                                                                                                                                                                                
-                answerDiv.appendChild(leftLabel);
-                answerDiv.appendChild(leftInput);
-                answerDiv.appendChild(rightLabel);
-                answerDiv.appendChild(rightInput);
-                answerDiv.appendChild(scaleLabel);
-                answerDiv.appendChild(scaleInput);
-                                                                                                                                                                                                                                                                                                                                                                                                                           
-                specs.appendChild(answerDiv);
-            }   
-                                            
-            function newCategory()
-            {
-                var categoryBox = document.getElementById("categoryBox");
-                categoryBox.innerHTML = "";
-                                                
-                var categoryInput = document.createElement("input");
-                categoryInput.name = "questionCategory";
-                                                
-                categoryBox.appendChild(categoryInput);
-            }
-                                                       
-            function clearFields()
-            {
-                clearCategory();
-                clearCode();
-                clearTitle();
-                clearDescription();
-                clearType();
-            }
-                                            
-            function clearCategory()
-            {
-                var categoryBox = document.getElementById("categoryBox");
-                categoryBox.innerHTML = "";
-                                                
-                var questionCategorySelect = document.createElement("select");
-                questionCategorySelect.setAttribute("name", "questionCategory");
-                questionCategorySelect.id = "questionCategorySelect";
-                                                
-                var newCategoryButton = document.createElement("input");
-                newCategoryButton.setAttribute("type", "button");
-                newCategoryButton.setAttribute("onclick", "newCategory()");
-                newCategoryButton.setAttribute("value", "New Category");
-                newCategoryButton.className = "surveyButton";
-                                                
-                categoryBox.appendChild(questionCategorySelect);
-                categoryBox.appendChild(newCategoryButton);
-            }
-                                            
-            function clearCode()
-            {
-                var codeInput = document.getElementById("questionCode");
-                codeInput.value = "";
-            }
-                                            
-            function clearTitle()
-            {
-                var titleInput = document.getElementById("questionTitle");
-                titleInput.value ="";
-            }
-                                            
-            function clearDescription()
-            {
-                var descriptionInput = document.getElementById("questionDescription");
-                descriptionInput.value = "";
-            }
-                                            
-            function clearType()
-            {
-                var typeSelect = document.getElementById("questionTypeSelect");
-                typeSelect.selectedIndex = 0;
-                clearSpecifications();
-            }
-                                            
-        </script>
-        <?php
-    }
-
-    private function displayList() {
-        ?>
-        <div id="questionListWrapper">
-            <select id="questionsList" size="9999">
-                <?php $this->populateList(); ?>
-            </select>
-        </div>
-        <?php
-    }
-
-    private function displayEditPanel() {
-        ?>
-        <div id="questionCreation" class="floatLeft">
-            <?php $this->displayForm(); ?>
-        </div>
-        <?php
-    }
-
-    private function displayForm() {
-        ?>
-        <form id="questionEditForm" method="post" action="" onsubmit="">
-            <table class="questionTable">
-                <tr>
-                    <td><label for="questionCategory">Category</label></td>
-                    <td id="categoryBox"><!-- Select should be filled with existing categories-->
-                        <?php $this->questionCategorySelect(); ?>
-                    </td>
-                </tr>
-                <tr>
-                    <td><label for="questionCode">Code</label></td>
-                    <td><input id="questionCode" name="questionCode" size="5" /></td>
-                </tr>
-                <tr>
-                    <td><label for="questionTitle">Title</label></td>
-                    <td><input id="questionTitle" name="questionTitle" size="60" /></td>
-                </tr>
-                <tr>
-                    <td><label for="questionDescription">Description</label></td>
-                    <td><input id="questionDescription" name="questionDescription" size="60" /></td>
-                </tr>
-                <tr>
-                    <td><label for="questionType">Type answer</label></td>
-                    <td id="questionType">
-                        <select id="questionTypeSelect" name="questionType" onchange="handleType(this)">
-                            <option value='text' selected='selected'>Text</option>
-                            <option value='int'>Integer</option>
-                            <option value='mc'>Multiple choice</option>
-                            <option value='checkboxes'>Checkboxes</option>
-                            <option value='scale'>Scale</option>
-                        </select>
-                    </td>
-                </tr>
-            </table>
-            <div id="answerSpecifications"></div>
-            <input id="clearQuestionFields" type="button" onclick="clearFields()" class="surveyButton" value="Clear" />
-            <input id="saveQuestion" type="submit" class="surveyButton" value="Save" />
-        </form>
-        <?php
-    }
-
-    private function questionCategorySelect() {
-        ?>
-        <select id="questionCategorySelect" name="questionCategory">
-            <option value='Uncategorized' selected='selected'>Uncategorized</option>
-            <?php $this->generateCategoryOptions(); ?>
-        </select>
-        <!-- New category button -->
-        <input type="button" class="surveyButton" onclick="newCategory()" value="New Category" />
-        <?php
-    }
-
-    private function generateCategoryOptions() {
-        $categories = array();
-
-        foreach ($this->questions as $question) {
-            $category = $question->category;
-            array_push($categories, $category);
-        }
-        $categories = array_unique($categories);
-
-        // You might want to escape quotes and stuff here
-        foreach ($categories as $category) {
-            ?>
-            <option value="<?php echo $category; ?>"><?php echo $category; ?></option> 
-            <?php
-        }
-    }
-
-    /**
-     * Populates the question list. Sorts the list first by question category.
-     */
-    private function populateList() {
-
-        $this->questions = $this->sortByCategory($this->questions);
-
-        $currentCategory = null;
-
-        foreach ($this->questions as $question) {
-            if (is_null($currentCategory)) {
-                ?> <optgroup label="<?php echo $question->category; ?>"><?php
-                $currentCategory = $question->category;
-            } else if ($currentCategory != $question->category) {
-                /* Next category */
-                ?></optgroup><?php
-                $currentCategory = $question->category;
-                ?> <optgroup label="<?php echo $question->category; ?>"><?php
-            }
-            ?>
-                /* function loadQuestionIn() should still be made */
-                <option value="<?php echo $question->code; ?>" onfocus="loadQuestionIn()">
-                    <?php echo "[" . $question->code . "] " . $question->title; ?>
-                </option>
-
-                <?php
-            }
-            ?></optgroup><?php
-    }
-
-    /**
-     *
-     * @param type $questions 
-     */
-    private function sortByCategory($questions) {
-        usort($questions, "cmp");
-        return $questions;
-    }
-
-}
-
-/* This function is placed outside the class on purpose.
- * It's only used as callback function.
- */
-
-function cmp($q1, $q2) {
-    if ($q1->category == $q2->category) {
-        if($q1->code < $q2->code)
-            return -1;
-        else
-            return 1;
-    }
-    return ($q1->category < $q2->category) ? -1 : 1;
-}
-    ?>
Index: Dev/trunk/classes/QuestionMenu.php
===================================================================
--- Dev/trunk/classes/QuestionMenu.php	(revision 117)
+++ 	(revision )
@@ -1,30 +1,0 @@
-<?php
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of QuestionMenu
- *
- * @author fpvanagthoven
- */
-class QuestionMenu extends Menu {
-
-    public function __construct() {
-        ?> <fieldset class="menu"> <?php
-        parent::__construct('Questions');
-        QuestionMenu::accessDatabaseButton();
-        ?></fieldset> <?php
-    }
-
-    public static function accessDatabaseButton() {
-        ?>
-        <form id="accessDatabase" action="questioncreation.php" method="post">
-            <input type="submit" value="Access Database" class="surveyButton bigSurveyButton" />
-        </form>
-        <?php
-    }
-
-}
-?>
Index: Dev/trunk/classes/QuestionRDFReader.php
===================================================================
--- Dev/trunk/classes/QuestionRDFReader.php	(revision 117)
+++ 	(revision )
@@ -1,162 +1,0 @@
-<?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);	
-        $this->reloadQuestions();
-    }
-    
-    public function reloadQuestions()
-    {
-        // Create empty MemModel   
-        $factory = new ModelFactory();
-        $this->model = $factory->getDefaultModel();
-        
-         if(file_exists($this->filePath.'questions.rdf'))
-        {
-            $this->model->load($this->filePath.'questions.rdf');
-        }
-    }
-    
-    public function readQuestionByCode($questionCode)
-    {        
-        $result = array();
-        $result['title'] = $this->readQuestionTitle($questionCode);				
-        $result['description'] = $this->readQuestionDescription($questionCode);
-        $result['type'] = $this->readQuestionType($questionCode);
-        $result['category'] = $this->readQuestionCategory($questionCode);
-        $result['answers'] = $this->readQuestionAnswers($questionCode);
-
-        return $result;
-    }
-     
-    public function readQuestionCodes()
-    {
-        $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 	?questionCode
-            WHERE 
-            {	
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:question_code        ?questionCode				
-            }';
-            
-            $result = $tempmodel->sparqlQuery($querystring);
-        }
-        return $result; 
-    }
-
-    public function readQuestionTitle($questionCode)
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?questionTitle
-            WHERE 
-            {
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:question_code        "' . $questionCode . '"  ;
-                                predicates:title		?questionTitle 		
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-
-    public function readQuestionDescription($questionCode)
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?questionDescription
-            WHERE 
-            {	
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:question_code        "' . $questionCode . '"  ;
-                                predicates:description		?questionDescription 		
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-
-    public function readQuestionType($questionCode)
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?questionType
-            WHERE 
-            {	
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:question_code	"' . $questionCode . '"  ;
-                                predicates:question_type	?questionType				
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-        
-    public function readQuestionCategory($questionCode)
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?questionCategory
-            WHERE 
-            {	
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:question_code	"' . $questionCode . '"  ;
-                                predicates:question_category	?questionCategory				
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-
-    public function readQuestionAnswers($questionCode)
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?answerDescription
-            WHERE 
-            {
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:question_code	"' . $questionCode . '"  ;
-                                predicates:has_answer		?answerDescription
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-}
-
-?>
Index: Dev/trunk/classes/QuestionRDFWriter.php
===================================================================
--- Dev/trunk/classes/QuestionRDFWriter.php	(revision 117)
+++ 	(revision )
@@ -1,62 +1,0 @@
-<?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,$qCode,$qCategory,$qAnswers)
-    {
-        $resourceQuestion = new Resource(QUESTION.'/'.$qCode);
-
-        $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));
-        
-        $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)
-        {		
-            $answerValue = new Literal($answer);
-            $predicateAnswer = new Resource(HAS_ANSWER);	
-            $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$answerValue));
-        }	
-    }
-}
-?>
Index: Dev/trunk/classes/ResearchToolObject.php
===================================================================
--- Dev/trunk/classes/ResearchToolObject.php	(revision 131)
+++ Dev/trunk/classes/ResearchToolObject.php	(revision 131)
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Description of ResearchToolObject
+ *
+ * @author jkraaijeveld
+ */
+class ResearchToolObject {
+    public $uid;
+}
+
+?>
Index: Dev/trunk/classes/SessionCreationDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/SessionCreationDatabaseInterface.php	(revision 117)
+++ 	(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 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: Dev/trunk/classes/SessionCreationTool.php
===================================================================
--- Dev/trunk/classes/SessionCreationTool.php	(revision 117)
+++ 	(revision )
@@ -1,320 +1,0 @@
-<?php
-
-/**
- * Description of SessionCreationTool
- *
- * @author fpvanagthoven
- */
-class SessionCreationTool {
-
-    private $session;
-    private $surveys;
-    private $applications;
-
-    public function __construct($session = null) {
-        $this->session = $session;
-
-        $this->init();
-
-        $this->javascript();
-        var_dump($_POST);
-        var_dump($session);
-        ?>
-
-        <div id="creation">
-            <form id="sessionCreationForm" action="" onsubmit="submitPipeline()" method="post">
-                <?php
-                $this->title();
-                $this->description();
-                $this->pipeline();
-                $this->surveysApplications();
-
-                $this->makeSessionButton();
-                ?>
-            </form>
-        </div>
-        <?php
-        $this->populatePipeline();
-    }
-
-    private function init() {
-        $this->surveys = Loader::loadSurveys();
-        $this->applications = Loader::loadApplications();
-    }
-
-    private function javascript() {
-        ?>
-        <script type="text/javascript" src="js/creation.js"></script>
-        <script type="text/javascript">
-            var pipelineCount = 0;
-                                                                                                                                                                                                                                                                                                                                                     
-            // =============================================================
-                                                                                                                                                                                                                                                                                                                                                                            
-            function addSurvey(surveyID) {     
-                var surveysList = document.getElementById("surveysList");
-                var entryType = "s";
-                var color = "#00ccff";
-                        
-                addFromList(surveysList, entryType, color, surveyID);
-            }
-                            
-            function addApplication(applicationID)
-            {
-                var applicationsList = document.getElementById("applicationsList");
-                var entryType = "a";
-                var color = "gold";
-                        
-                addFromList(applicationsList, entryType, color, applicationID);
-            }
-                            
-            function addFromList(list, entryType, color, id)
-            {
-                if(list.selectedIndex != -1 || id != null)
-                {
-                    var pipeline = document.getElementById("pipeline");
-                    var entry = document.createElement("option");
-                            
-                    pipelineCount++;
-                            
-                    if (id != null)
-                    {
-                        entry.setAttribute("value", id);
-                        entry.innerHTML = pipelineCount + ". " + list.options.namedItem(id).innerHTML;
-                    }
-                    else
-                    {
-                        entry.setAttribute("value", list.options[list.selectedIndex].value);
-                        entry.innerHTML = pipelineCount + ". " + list.options[list.selectedIndex].innerHTML;
-                    }
-                            
-                            
-                    entry.style.backgroundColor = color;
-                    entry.name = pipelineCount + entryType;
-                    entry.entryType = entryType;
-                            
-                    pipeline.appendChild(entry);
-                }
-            }
-                                                                                                                                                                                                                                                    
-            function addDashboard() {
-                pipelineCount++;
-                var pipeline = document.getElementById("pipeline");
-                                                                                                                                                                                                                                                        
-                var entry = document.createElement("option");
-                entry.setAttribute("value", "dashboard");
-                entry.style.backgroundColor = "#555";
-                entry.style.color = "white";
-                entry.innerHTML = pipelineCount + ". " + "Dashboard";
-                entry.name = pipelineCount + "d";
-                entry.entryType = "d";
-                                                                                                                                                                                                                                                        
-                pipeline.appendChild(entry);
-            }
-                                                                                                    
-            function removeFromPipeline() {
-                var pipeline = document.getElementById("pipeline");
-                if (pipeline.selectedIndex != -1)
-                {
-                    var index = pipeline.selectedIndex;
-                    pipeline.remove(index);
-                    if (pipelineCount > 1 && 
-                        pipeline.options[index] != null)
-                    {
-                        pipeline.options[index].selected = true;
-                    }
-                                                                                           
-                    for(var i = index; i < pipeline.length; i++)
-                    {
-                        var entry = pipeline.options[i];
-                        entry.name = "" + (i+1) + entry.entryType;
-                        var htmlStr = entry.innerHTML;
-                        var dotIndex = htmlStr.indexOf('.');
-                        entry.innerHTML = (i+1) + htmlStr.substr(dotIndex);
-                    }
-                    pipelineCount--;
-                }
-            }
-                                                                                                                                                                                                                                                                     
-            function submitPipeline()
-            {
-                var form = document.getElementById("sessionCreationForm");
-                                                                                                                                                                                                                                        
-                var pipeline = document.getElementById("pipeline").options;
-                                                                                                                                                                                                                                               
-                                                                                                                                                                                                                                                
-                for (var i = 0; i < pipeline.length; i++)
-                {
-                    var pipelineElem = document.createElement("input");
-                    pipelineElem.name = pipeline[i].name;
-                    pipelineElem.value = pipeline[i].value;
-                    pipelineElem.type = "hidden";
-                                                                                                                                                                                                                                            
-                    form.appendChild(pipelineElem);
-                }
-                                                                                                                                                                                                                                
-                var count = document.createElement("input");
-                count.name = "pipelineCount";
-                count.value = pipelineCount;
-                count.type = "hidden";
-                                                                                                                                                                                                                                
-                form.appendChild(count);
-            }
-        </script>
-        <?php
-    }
-
-    private function title() {
-        if (isset($this->session->title))
-            $value = $this->session->title;
-        else
-            $value = 'Untitled Session';
-        ?>
-        <input type="text" id="sessionTitle" class="titleBox" name="sessionTitle" value="<?php echo str_replace("\"", "&quot;", $value); ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
-        <?php
-    }
-
-    private function description() {
-        if (isset($this->session->description))
-            $value = $this->session->description;
-        else
-            $value = 'Write a description for this session here.';
-        ?>
-        <textarea id="sessionDescription" class="descriptionBox" name="sessionDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea>
-        <?php
-    }
-
-    private function pipeline() {
-        ?>
-        <div id="pipelineWrapper">
-            <h2 class="pipelineHead">Pipeline</h2>
-            <?php $this->pipelineSelect(); ?>
-            <div id="pipelineOptions">
-                <?php
-                $this->addDashboardToPipelineButton();
-                $this->removeFromPipelineButton();
-                ?>
-            </div>
-        </div>
-        <?php
-    }
-
-    private function surveysApplications() {
-        ?>
-        <div id="surveysApplicationsWrapper">
-            <div id="surveysForPipelineWrapper">
-                <h2 class="pipelineHead">Surveys</h2>
-                <?php
-                $this->surveysSelect();
-                $this->addSurveyToPipelineButton();
-                ?>
-            </div>
-            <div id="applicationsForPipelineWrapper">
-                <h2 class="pipelineHead">Applications</h2>
-                <?php
-                $this->applicationsSelect();
-                $this->addApplicationToPipelineButton();
-                ?>
-            </div>
-        </div>
-        <?php
-    }
-
-    private function pipelineSelect() {
-        ?>
-        <select id="pipeline" size="1000"></select>
-        <?php
-    }
-
-    private function surveysSelect() {
-        ?>
-        <select id="surveysList" size="5" class="width100p">
-            <?php
-            foreach ($this->surveys as $survey) {
-                ?>
-                <option name="<?php echo $survey->id; ?>" value="<?php echo $survey->id; ?>">
-                    <?php echo $survey->title; ?>
-                </option>
-                <?php
-            }
-            ?>
-        </select>
-        <?php
-    }
-
-    private function applicationsSelect() {
-        ?>
-        <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
-    }
-
-    private function addSurveyToPipelineButton() {
-        ?>
-        <input type="button" id="surveyToPipeline" class="surveyButton pipelineButton leftAlign leftPadding1" value="<=====" onclick="addSurvey()"/>
-        <?php
-    }
-
-    private function addApplicationToPipelineButton() {
-        ?>
-        <input type="button" class="surveyButton pipelineButton leftAlign leftPadding1" value="<=====" onclick="addApplication()"/>
-        <?php
-    }
-
-    private function addDashboardToPipelineButton() {
-        ?>
-        <input type="button" class="surveyButton pipelineButton leftAlign leftPadding1" value="+ Dashboard" onclick="addDashboard()"/>
-        <?php
-    }
-
-    private function removeFromPipelineButton() {
-        ?>
-        <input type="button" class="surveyButton" value="x" onclick="removeFromPipeline()"/>
-        <?php
-    }
-
-    private function makeSessionButton() {
-        ?>
-        <input type="submit" id="makeSessionButton" class="topRight surveyButton" value="Make session" />
-        <?php
-    }
-
-    private function populatePipeline() {
-
-        if (isset($this->session)) {
-            for ($i = 1; $i < $this->session->count + 1; $i++) {
-                if (isset($this->session->pipeline[$i . 's'])) {
-                    ?>
-                    <script type="text/javascript">
-                        addSurvey(<?php echo "'" . $this->session->pipeline[$i . 's'] . "'"; ?>);
-                    </script>
-                    <?php
-                } 
-                else if (isset($this->session->pipeline[$i . 'a'])) {
-                    ?>
-                    <script type="text/javascript">
-                        addApplication(<?php echo "'" . $this->session->pipeline[$i . 'a'] . "'"; ?>);
-                    </script>
-                    <?php
-                }
-                else if (isset($this->session->pipeline[$i . 'd'])) {
-                    ?>
-                    <script type="text/javascript">
-                        addDashboard();
-                    </script>
-                    <?php
-                }
-            }
-        }
-    }
-
-}
-?>
Index: Dev/trunk/classes/SessionMenu.php
===================================================================
--- Dev/trunk/classes/SessionMenu.php	(revision 117)
+++ 	(revision )
@@ -1,65 +1,0 @@
-<?php
-
-/**
- * Description of SessionMenu
- *
- * @author fpvanagthoven
- */
-class SessionMenu extends Menu {
-
-    public function __construct() {
-        ?> <fieldset class="menu"> <?php
-        parent::__construct('Session');
-        ?> <div class="menuButtons"> <?php
-        SessionMenu::createSessionButton();
-        SessionMenu::loadSessionButton();
-        SessionMenu::startSessionButton();
-        ?> </div> <?php
-        SessionMenu::loadSessionList(null);
-        ?></fieldset><?php
-    }
-
-    public static function createSessionButton() {
-        ?>
-
-        <form action="sessioncreation.php" method="post">
-
-            <input type="submit" value="New" class="surveyButton bigSurveyButton" />
-
-        </form>
-
-        <?php
-    }
-
-    public static function loadSessionButton() {
-        ?>
-        <form id="loadSessionForm" action="sessioncreation.php" method="post">
-            <input type="button" onclick="loadSession()" value="Load / Edit" class="surveyButton bigSurveyButton" />
-        </form>
-        <?php
-    }
-
-    public static function startSessionButton() {
-        ?>
-        <form action="session.php" method="post">
-            <input type="button" onclick="startSession()" value="Start" class="surveyButton bigSurveyButton" />
-        </form>
-        <?php
-    }
-
-    public static function loadSessionList($sessions) {
-        ?>
-        <select class="toLoad" size="1000">
-            <?php
-            if (!empty($sessions)) {
-                foreach ($sessions as $session) {
-                    ?><option value='<?php echo $session->id; ?>'><?php echo $session->title; ?></option><?php
-            }
-        }
-            ?>
-        </select>
-        <?php
-    }
-
-}
-?>
Index: Dev/trunk/classes/SessionRDFReader.php
===================================================================
--- Dev/trunk/classes/SessionRDFReader.php	(revision 117)
+++ 	(revision )
@@ -1,138 +1,0 @@
-<?php
-
-class SessionRDFReader
-{
-    protected $model;
-
-    protected $sessionUID;
-    protected $filePath;
-
-    public function __construct($sessionUID)
-    {
-        // Create empty MemModel
-        $factory = new ModelFactory();
-        $this->model = $factory->getDefaultModel();
-
-        $this->sessionUID = $sessionUID;
-        $this->filePath = 'data/sessions/session_'.$this->surveyUID.'.rdf';
-    }
-
-    public function loadSurvey()
-    {
-        $this->model->load($this->filePath);
-    }
-    
-    public function getSessionInfo()
-    {        
-        $results[] = $this->readSessionInfo();
-        $results[] = $this->getPipeline();
-        
-        return $results;
-    }
-    
-    public function readSessionInfo()
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?uid ?title ?description ?creator
-            WHERE 	
-            {
-                    _session	predicates:resource_type	resources:session ;
-                                predicates:uid			?uid	;
-                                predicates:title 		?title 	;
-                                predicates:description		?description 
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-    
-    public function getPipeline()
-    {
-        $results[] = $this->readSurveys();
-        $results[] = $this->readApplications();
-        $results[] = $this->readDashboards();
-        
-        return $results;
-    }
-    
-    public function readSurveys()
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT DISTINCT ?uid ?index
-            WHERE 	
-            {
-                    _survey	predicates:resource_type	resources:survey ;
-                                predicates:uid			?uid	;
-                                predicates:index		?index 
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-    
-    public function readApplications()
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT DISTINCT ?uid ?index
-            WHERE 	
-            {
-                    _application	predicates:resource_type	resources:application ;
-                                predicates:uid			?uid	;
-                                predicates:index		?index 
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-    
-    public function readDashboards()
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT DISTINCT ?uid ?index
-            WHERE 	
-            {
-                    _dashboard	predicates:resource_type	resources:dashboard ;
-                                predicates:uid			?uid	;
-                                predicates:index		?index 
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-    
-    public function getSessionTitleByID($sessionID)
-    {
-        // Create empty MemModel
-        $factory = new ModelFactory();
-        $tempmodel= $factory->getDefaultModel();
-        $tempmodel->load('data/sessions/session_'.$sessionID.'/session_'.$sessionID.'.rdf');
-
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?title 
-            WHERE 	
-            {
-                    _session    predicates:resource_type	resources:session ;
-                                predicates:title 		?title 	
-            }';
-
-        $result = $tempmodel->sparqlQuery($querystring);
-
-        return $result;
-    }
-}
-
-?>
Index: Dev/trunk/classes/SessionRDFWriter.php
===================================================================
--- Dev/trunk/classes/SessionRDFWriter.php	(revision 117)
+++ 	(revision )
@@ -1,98 +1,0 @@
-<?php
-
-class SessionRDFWriter 
-{
-    protected $model;
-
-    protected $sessionUID;
-    protected $resourceSession;
-            
-    protected $filePath;
-
-    public function __construct($sessionUID)
-    {
-        // Create empty MemModel
-        $factory = new ModelFactory();
-        $this->model = $factory->getDefaultModel();
-
-        $this->sessionUID = $sessionUID;	
-        $this->filePath = 'data/sessions/';
-        if (!is_dir($this->filePath))
-            mkdir($this->filePath);	
-    }
-    
-    public function saveAs()
-    {
-        $this->model->saveAs($this->filePath.
-                'session_' . $this->surveyUID . '/.' . 
-                $this->surveyUID  .'.rdf',
-                'rdf');
-    }
-    
-    public function createSession($sTitle,$sDescription)
-    {
-        $this->resourceSession = new Resource(SESSION.'/'.$this->sessionUID);
-
-        $resourceSessionType = new Resource(SESSION);
-        $predicateRType = new Resource(RTYPE);
-        $this->model->add(new Statement($this->resourceSession,$predicateRType,$resourceSessionType));
-
-        $literalSessionID = new Literal($this->sessionUID);
-        $predicateUniqueID = new Resource(UID);
-        $this->model->add(new Statement($this->resourceSession,$predicateUniqueID,$literalSessionID));
-
-        $predicateTitle = new Resource(TITLE);		
-        $sessionTitle = new Literal($sTitle);
-        $this->model->add(new Statement($this->resourceSession,$predicateTitle,$sessionTitle));		
-
-        $predicateDescription = new Resource(DESCRIPTION);
-        $sessionDescription = new Literal($sDescription);
-        $this->model->add(new Statement($this->resourceSession,$predicateDescription,$sessionDescription));
-    }
-    
-    public function addSurveyToPipeline($uid,$index)
-    {
-        $resourceSurvey = new Resource(SURVEY);
-        $predicateHasProcess = new Resource(HAS_PROCESS);
-        $this->model->add(new Statement($this->resourceSession,$predicateHasProcess,$resourceSurvey));
-        
-        $literalSurveyID = new Literal($uid);
-        $predicateUID = new Resource(UID);
-        $this->model->add(new Statement($$resourceSurvey,$predicateUID,$literalSurveyID));        
-        
-        $literalIndex = new Literal($index);
-        $predicateIndex = new Resource(INDEX);        
-        $this->model->add(new Statement($resourceSurvey,$predicateIndex,$literalIndex));
-    }
-    
-    public function addApplicationToPipeline($uid,$index)
-    {
-        $resourceApplication = new Resource(APPLICATION);
-        $predicateHasProcess = new Resource(HAS_PROCESS);
-        $this->model->add(new Statement($this->resourceSession,$predicateHasProcess,$resourceApplication));
-        
-        $literalApplicationID = new Literal($uid,$index);
-        $predicateUID = new Resource(UID);
-        $this->model->add(new Statement($resourceApplication,$predicateUID,$literalApplicationID));        
-        
-        $literalIndex = new Literal($index);
-        $predicateIndex = new Resource(INDEX);        
-        $this->model->add(new Statement($resourceApplication,$predicateIndex,$literalIndex));
-    }
-    
-    public function addDashboardToPipeline($uid,$index)
-    {
-        $resourceDashboard = new Resource(DASHBOARD);
-        $predicateHasProcess = new Resource(HAS_PROCESS);
-        $this->model->add(new Statement($this->resourceSession,$predicateHasProcess,$resourceDashboard));
-        
-        $literalDashboardID = new Literal($uid);
-        $predicateUID = new Resource(UID);
-        $this->model->add(new Statement($resourceDashboard,$predicateUID,$literalDashboardID));        
-        
-        $literalIndex = new Literal($index);
-        $predicateIndex = new Resource(INDEX);        
-        $this->model->add(new Statement($resourceDashboard,$predicateIndex,$literalIndex));
-    }
-}
-?>
Index: Dev/trunk/classes/StyleSheet.php
===================================================================
--- Dev/trunk/classes/StyleSheet.php	(revision 117)
+++ 	(revision )
@@ -1,21 +1,0 @@
-<?php
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of StyleSheet
- *
- * @author fpvanagthoven
- */
-class StyleSheet {
-
-    public function __construct() {
-        ?>
-        <link rel="stylesheet" type="text/css" href="css/awesome.css" />
-        <?php
-    }
-
-}
-?>
Index: Dev/trunk/classes/Survey.php
===================================================================
--- Dev/trunk/classes/Survey.php	(revision 117)
+++ 	(revision )
@@ -1,84 +1,0 @@
-<?php
-
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of Survey
- *
- * @author fpvanagthoven
- */
-class Survey {
-
-    public $id;
-    public $title;
-    public $description;
-    public $questions;
-    public $results;
-    
-    const DEFAULT_DESCRIPTION = "Write a helpful description for this survey here.";
-
-    public function __construct($id, $title, $description = null) {
-        $this->id = $id;
-        $this->title = $title;
-        $this->description = $description;
-        $this->questions = array();
-
-        $this->results = null;
-    }
-
-    public function addQuestion($question) {
-        array_push($this->questions, $question);
-    }
-
-    public function setResults($surveyResults) {
-        $this->results = $surveyResults;
-    }
-
-    public static function getSurvey($info) {
-        $id = $info['surveyID'];
-        $title = $info['surveyTitle'];
-        $description = $info['surveyDescription'];
-
-        $survey = new Survey($id, $title, $description);
-
-        $numQ = 1; //number questions
-        while (isset($info['questionTitle' . $numQ])) {
-            $id = $info['questionID' . $numQ];
-            $code = $info['questionCode' . $numQ];
-            $title = $info['questionTitle' . $numQ];
-            $type = $info['questionType' . $numQ];
-            $description = $info['questionDescription' . $numQ];
-
-            $question = new Question($id, $code, $title, $type, $description);
-
-            $numA = 1; //number answers
-            while (isset($info['q' . $numQ . 'ans' . $numA])) {
-                $answer = $info['q' . $numQ . 'ans' . $numA];
-                $question->answers[$numA] = $answer;
-
-                $numA++;
-            }
-
-
-            $survey->questions[$numQ] = $question;
-
-            $numQ++;
-        }
-
-        return $survey;
-    }
-
-    /**
-     * TODO: Should return Results-object from reading RDF-database
-     * @param type $surveyID 
-     */
-    public static function getResults($surveyID) {
-        
-    }
-
-}
-
-?>
Index: Dev/trunk/classes/SurveyAnswerDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/SurveyAnswerDatabaseInterface.php	(revision 117)
+++ 	(revision )
@@ -1,57 +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 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)
-    {
-        $name = $respondentInfo['username'];
-        $this->surveyAnswerRDFWriter->setRespondentData($name);
-    }
-    
-    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/SurveyAnswerRDFReader.php
===================================================================
--- Dev/trunk/classes/SurveyAnswerRDFReader.php	(revision 117)
+++ 	(revision )
@@ -1,125 +1,0 @@
-<?php
-
-class SurveyAnswerRDFReader
-{	
-    protected $model;
-    protected $respondentID;
-    
-    protected $filePath;
-
-    public function __construct($surveyUID,$sessionID,$respondentID)
-    {
-
-        // Create empty MemModel
-        $factory = new ModelFactory();
-        $this->model = $factory->getDefaultModel();
-        
-        $this->respondentID = $respondentID;
-        
-        $this->filePath = 'data/sessions/' .  $sessionID . '/survey_'.$surveyUID . '/';
-    }
-
-    public function loadAnsers()
-    {
-        if(file_exists($this->filePath.'questions.rdf'))
-        {
-            $this->model->load($this->filePath.'/answer_'.$this->respondentID.'.rdf');
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    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 getAnswersByRespondent($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 117)
+++ 	(revision )
@@ -1,77 +1,0 @@
-<?php
-
-class SurveyAnswerRDFWriter
-{
-    protected $surveyID;
-    protected $respondentID;
-    protected $path;
-
-    public function __construct($surveyID,$sessionID,$respondentID)
-    {
-        // Create empty MemModel
-        $factory = new ModelFactory();
-        $this->model = $factory->getDefaultModel();
-        
-        $basePath = 'data/sessions/';
-        $sessionPath = $basePath . $sessionID . '/';
-        $this->path  = $sessionPath .'survey_'.$surveyID . '/';
-        $this->surveyID = $surveyID;
-        $this->respondentID = $respondentID;
-        
-        if (!is_dir($basePath))
-            mkdir($basePath);
-        if (!is_dir($sessionPath))
-             mkdir($sessionPath);
-        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');
-    }
-
-    public function setRespondentData($name)
-    {				
-        $resourceUser = new Resource(USER . '/' . $this->respondentID);		
-
-        $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($this->respondentID);
-        $predicateUniqueID = new Resource(UID);
-        $this->model->add(new Statement($resourceUser,$predicateUniqueID,$literalUserID));
-
-        $resourceSurvey = new Resource(SURVEY.'/'.$this->surveyID);
-        $predicateRespondent = new Resource(RESPONDENT);
-        $this->model->add(new Statement($resourceSurvey,$predicateRespondent,$resourceUser));
-    }
-
-    public function setAnswers($answers)
-    {
-        foreach($answers as $questionID => $answerValues)
-        {
-            $resourceQuestion = new Resource(QUESTION.'/'.$questionID);
-
-            $resourceQuestionType = new Resource(QUESTION);
-            $predicateRType = new Resource(RTYPE);
-            $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
-            
-            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 117)
+++ 	(revision )
@@ -1,196 +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 SurveyCreationDatabaseInterface
-{		
-    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['questionCode'.$qNumber]))
-        {
-            $qCode = $survey['questionCode'.$qNumber];          
-            $this->surveyRDFWriter->addQuestion($qCode);
-
-            $qNumber++;
-        }
-
-        $this->surveyRDFWriter->saveSurvey();
-        $this->questionRDFWriter->saveQuestions();
-    }
-    
-    public function saveQuestion($questionInfo)
-    {
-        $qCode = $question['questionCode'.$qNumber];
-        $qTitle = $question['questionTitle'.$qNumber];
-        $qDescription = $question['questionDescription'.$qNumber];
-        $qType = $question['questionType'.$qNumber];
-
-        $qAnswers = array();
-        $aNumber = 1;
-        while (isset($question['ans'.$aNumber]))
-        {
-            $qAnswers[] = $question['ans'.$aNumber];
-
-            $aNumber++;
-        }
-        
-        if($this->checkQuestionCodeExists($qCode))
-        {
-            return 'Question code (' . $qCode . ') already in use. Please try a new code.';
-        }
-        else 
-        {
-            $this->questionRDFWriter->createQuestion($qTitle,$qDescription,$qType,$qCode,"null",$qAnswers);
-            return 'Question saved';
-        }
-    }
-
-    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 getExistingQuestions()
-    {
-        $questions = array();
-
-        $resultQuestions = $this->questionRDFReader->readQuestionCodes();
-        foreach ($resultQuestions as $questionCodeObject)
-        {
-            $questionCode = $questionCodeObject[0]['?questionCode']->label;
-            $questionTitle = $this->questionRDFReader->readQuestionTitle($questionCode);
-            $questions[$questionCode] = $questionTitle[0]['?questionTitle']->label;
-        }
-
-        return $questions;
-    }
-    
-    public function getSurveyTitleByID($surveyID)
-    {
-        $surveyTitleLiteral = $this->surveyRDFReader->getSurveyTitleByID($surveyID);
-        $surveyTitle = $surveyTitle[0]['?title']->label;
-        
-        return $surveyTitle;
-    }
-    
-    public function checkQuestionCodeExists($qCode)
-    {
-        $result = false;
-
-        $questionCodes = $this->questionRDFReader->readQuestionCodes();
-        
-        if ($questionCodes != null)
-        {
-            foreach($questionCodes as $questionCode)
-            {
-                $code = $questionCode['?questionCode']->label;
-                if(!strcmp($code ,$qCode))
-                {
-                    $result = true;
-                    break;
-                }
-            }
-        }
-
-        return $result;
-    }
-}
-?>
Index: Dev/trunk/classes/SurveyCreationTool.php
===================================================================
--- Dev/trunk/classes/SurveyCreationTool.php	(revision 117)
+++ 	(revision )
@@ -1,594 +1,0 @@
-<?php
-
-/**
- * Description of SurveyTool
- *
- * SurveyTool is where the survey can be created.
- * 
- */
-class SurveyCreationTool {
-
-    private $survey;
-    private $timeStamp;
-
-    public function __construct($survey = null, $timeStamp = null) {
-        $this->survey = $survey;
-        $this->timeStamp = $timeStamp;
-        if (isset($this->survey->id))
-            SurveyCreationTool::javascript($this->survey->id);
-        else
-            SurveyCreationTool::javascript();
-        ?>
-
-        <div id="creation"><form id="survey" action="surveycreation.php" method="post">
-                <?php
-                $this->surveyHead();
-                $this->questionCreationForm();
-                SurveyCreationTool::addQuestionButton();
-                SurveyCreationTool::removeLastQuestionButton();
-                ?></form></div>
-        <?php
-    }
-
-    private static function javascript($id = null) {
-        ?>
-        <script type="text/javascript" src="js/creation.js"></script>
-        <script type="text/javascript">
-            /* autosave every 5 minutes */
-            setTimeout("save('<?php echo $id; ?>')", 300000);
-                                                                                                                                                                                                                                                                                                                            
-            var questionCount = 1;          
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
-            function getNewQuestion(code, title, description)
-            {
-                if (code == null)
-                    var code = '';
-                        
-                if (title == null)
-                    var title = 'Untitled Question';
-                                                                                                                                                                                                                                                                
-                if (description == null)
-                    var description = 'Write a question description here.';
-                                                                                                                                                                                                                                                 
-                var questionDiv = document.createElement("div");
-                questionDiv.id = "question" + questionCount;
-                questionDiv.className = "question";                                                                            
-                                                                                                
-                var questionTable = document.createElement("table");
-                questionTable.className = "questionTable";
-                                                                                                
-                var th = document.createElement("th");
-                th.innerHTML = "Question " + questionCount;
-
-                var row0 = document.createElement("tr");
-                        
-                var colCodeLabel = document.createElement("td");
-                var codeLabel = document.createElement("label");
-                codeLabel.setAttribute("for", "questionCode");
-                codeLabel.innerHTML = "Code";
-                colCodeLabel.appendChild(codeLabel);
-                        
-                var colCodeInput = document.createElement("td");
-                var codeInput = document.createElement("input");
-                codeInput.id = "questionCode";
-                codeInput.setAttribute("type", "text");
-                codeInput.className = "questionCode";
-                codeInput.setAttribute("name", "questionCode" + questionCount);
-                codeInput.setAttribute("size", "5");
-                codeInput.setAttribute("value", code);
-                colCodeInput.appendChild(codeInput);
-                        
-                row0.appendChild(colCodeLabel);
-                row0.appendChild(colCodeInput);
-
-                var row1 = document.createElement("tr");
-                                                                                                
-                var col1 = document.createElement("td");
-                var titleLabel = document.createElement("label");
-                titleLabel.setAttribute("for", "questionTitle");
-                titleLabel.innerHTML = "Title";
-                col1.appendChild(titleLabel);
-                                                                                        
-                var col2 = document.createElement("td");
-                var titleInput = document.createElement("input");
-                titleInput.id = "questionTitle";
-                titleInput.setAttribute("type", "text");
-                titleInput.className = "questionTitle";
-                titleInput.setAttribute("name", "questionTitle"  + questionCount);
-                titleInput.setAttribute("onfocus", "handleFocus(this)");
-                titleInput.setAttribute("size", "30");
-                titleInput.setAttribute("value", title);
-                col2.appendChild(titleInput);                        
-
-                row1.appendChild(col1);
-                row1.appendChild(col2);
-                                                                                        
-                var row2 = document.createElement("tr");
-                var col3 = document.createElement("td");
-                var descriptionLabel = document.createElement("label");
-                descriptionLabel.setAttribute("for", "questionDescription");
-                descriptionLabel.innerHTML = "Description";
-                col3.appendChild(descriptionLabel);
-                                                                                        
-                var col4 = document.createElement("td");
-                var descriptionInput = document.createElement("input");
-                descriptionInput.type = "text";
-                descriptionInput.className = "questionDescription";
-                descriptionInput.name = "questionDescription" + questionCount;
-                descriptionInput.setAttribute("onfocus", "handleFocus(this)");
-                descriptionInput.setAttribute("size", 40);
-                descriptionInput.setAttribute("value", description);
-                col4.appendChild(descriptionInput);
-                                                                                        
-                row2.appendChild(col3);
-                row2.appendChild(col4);
-                                                                
-                var row3 = document.createElement("tr");
-                var col5 = document.createElement("td");
-                var typeLabel = document.createElement("label");
-                typeLabel.setAttribute("for", "questionType");
-                typeLabel.innerHTML = "Type answer";
-                col5.appendChild(typeLabel);
-                                                                
-                var col6 = document.createElement("td");
-                var select = document.createElement("select");
-                select.id = questionCount;
-                select.setAttribute("name", "questionType" + questionCount);
-                select.setAttribute("onchange", "handleType(this)");
-                select.innerHTML = 
-                    "<option value='text' selected='selected'>Text</option>" +
-                    "<option value='int'>Integer</option>" +
-                    "<option value='mc'>Multiple choice</option>" +
-                    "<option value='checkboxes'>Checkboxes</option>" +
-                    "<option value='scale'>Scale</option>";
-                                                                
-                col6.appendChild(select);
-                                                                
-                row3.appendChild(col5);
-                row3.appendChild(col6);
-                                                                
-                questionTable.appendChild(th);
-                questionTable.appendChild(row0);
-                questionTable.appendChild(row1);
-                questionTable.appendChild(row2);
-                questionTable.appendChild(row3);                         
-                                                                        
-                var answerDiv = document.createElement("div");
-                answerDiv.id = "answersDiv" + questionCount;
-                answerDiv.className = "answersDiv";
-                                                                        
-                questionDiv.appendChild(questionTable);
-                questionDiv.appendChild(answerDiv);
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                
-                return questionDiv;
-            }
-                                                                                                                                                                                                                                                                                                                                                                                                                                                    
-            function handleType(select, answers)
-            {
-                var numQ = select.id; // questionNumber
-                var type = select.valueOf().value;
-                var answersDiv = document.getElementById("answersDiv" + numQ );
-                                                                                                                                                                
-                removeQuestionID(numQ);
-                                                                                                                                                                
-                answersDiv.answerCount = 1;
-                answersDiv.clicked = null;
-                                                                                                                                                                                                                                                                                                                                                                                                        
-                switch (type) {
-                    case 'mc':
-                        answersDiv.innerHTML = "";
-                        if (answers != null)
-                        {
-                            for (var i = 1; i < answers.length; i++)
-                            {
-                                addOption(numQ, answers[i]);
-                            }
-                        }
-                        else
-                            addOption(numQ);
-                                                                                                                                                                                                                                                                                                                                                                                                                                        
-                        break;
-                    case 'text':
-                        answersDiv.innerHTML = "";
-                        break;
-                    case 'int':    
-                        answersDiv.innerHTML = "";
-                                                                                                                                                                                                                                                                
-                        //min max
-                        if (answers != null)
-                            minMax(numQ, answers[1], answers[2]);
-                        else
-                            minMax(numQ);
-                        break;
-                    case 'checkboxes':
-                        answersDiv.innerHTML = "";
-                        if (answers != null)
-                        {
-                            for (var i = 1; i < answers.length; i++)
-                            {
-                                addOption(numQ, answers[i]);
-                            }
-                        }
-                        else
-                            addOption(numQ);
-                        break;
-                    case 'scale':
-                        answersDiv.innerHTML = ""; 
-                        //what scale (min max incr)
-                        if (answers != null)
-                            minMaxIncr(numQ, answers[1], answers[2], answers[3]);
-                        else
-                            minMaxIncr(numQ);
-                        break;
-                    default:
-                        break;
-                }
-
-            }
-                                                                                                                                                            
-            function handleAnswerChange(questionNumber)
-            {
-                removeQuestionID(questionNumber);
-            }
-                                                                                                                                                            
-            function removeQuestionID(questionNumber)
-            {
-                /* When type changes, remove question ID, because question changes */
-                var questionIDInput = document.getElementById("questionID" + questionNumber);
-                if (questionIDInput != null)
-                {
-                    var questionsDiv = document.getElementById("questionsDiv");
-                    questionsDiv.removeChild(questionIDInput);
-                }
-
-            }
-                                                                                                                                                                     
-                                                                                                                                                                                                                                                                                                                                                                                                                            
-            function addOption(questionNumber, optionStr)
-            {        
-                var answersDiv = document.getElementById("answersDiv" + questionNumber);
-                var answerCount = answersDiv.answerCount;
-                var answerDiv = document.createElement("div");
-                                                                                                                                                                                                
-                if (optionStr == null)
-                    var optionStr = "Option " + answerCount;
-                                                                                                                                                                                                
-                                                                                                                                                                                               
-                answerDiv.className = "answerDiv";
-                                                                  
-                var answerInput = document.createElement("input");
-                answerInput.setAttribute("type", "text");
-                answerInput.setAttribute("name", "q" + questionNumber + "ans" + answerCount);
-                answerInput.setAttribute("onchange", "handleAnswerChange(" + questionNumber + ")");
-                answerInput.setAttribute("value", optionStr);
-                                        
-                answerDiv.appendChild(answerInput);
-
-                if (answersDiv.clicked == null)
-                {
-                    var addOpt = document.createElement("input");
-                    addOpt.setAttribute("type", "button");
-                    addOpt.setAttribute("id", "addOpt");
-                    addOpt.setAttribute("class", "surveyButton");
-                    addOpt.setAttribute("onclick", "addOption(" + questionNumber + ")");
-                    addOpt.setAttribute("value", "Add Option");
-                                            
-                    var removeOpt = document.createElement("input");
-                    removeOpt.setAttribute("type", "button");
-                    removeOpt.className = "surveyButton";
-                    removeOpt.setAttribute("onclick", "removeOption(" + questionNumber + ")");
-                    removeOpt.setAttribute("value", "x");
-                                            
-                    answerDiv.appendChild(addOpt);
-                    answerDiv.appendChild(removeOpt);
-                                                                                                                                                                                                                                                                                                                                                        
-                    answersDiv.clicked = true;
-                }
-                                                                                                                                                                                                                                                                                                                                                                        
-                answerDiv.prev = answersDiv.lastAnswer; //singly linked list
-                answersDiv.lastAnswer = answerDiv;
-                                                                                                                                                                                                                                                                                                                                                                                                                                       
-                answersDiv.appendChild(answerDiv);
-                answersDiv.answerCount++;
-                                                                                                                                                                
-                handleAnswerChange(questionNumber);
-            }
-                                                                                                                                                                                                                                                                                                                                                                    
-            function removeOption(questionNumber)
-            {
-                var answersDiv = document.getElementById("answersDiv" + questionNumber);
-                                                                                                                                                                                                                                                                                                                                                                       
-                if (answersDiv.lastAnswer.prev != null)
-                {
-                    answersDiv.removeChild(answersDiv.lastAnswer);
-                    answersDiv.lastAnswer = answersDiv.lastAnswer.prev;
-                    answersDiv.answerCount--;
-                }
-                                                                                                                                                                
-                handleAnswerChange(questionNumber);
-            }
-                                                                                                                                                                                                                                                                                                                                                                                            
-            function minMax(questionNumber, min, max)
-            {
-                if (min == null)
-                    var min = '';
-                if (max == null)
-                    var max = '';
-                                                                                                                                                                                                                                                        
-                var answersDiv = document.getElementById("answersDiv" + questionNumber);
-                                                                                                                                                                                                                                                                                                                                                                                               
-                var answerDiv = document.createElement("div");
-                                                                                                                                                                                                                                                                                                                                                                
-                answerDiv.className = "answerDiv";
-                answerDiv.innerHTML = "<label for='min'>Min</label><input type='text' class='intBox' onchange='checkInt(this)' value='" + min + "' name='q" + questionNumber + "ans1' />" +
-                    "<label for='max'>Max</label><input type='text' class='intBox' onchange='checkInt(this)' value='" + max + "' name='q" + questionNumber + "ans2' />";
-                                                                                                                                                                                                                                                                                                                                                                                           
-                answersDiv.appendChild(answerDiv);
-            }  
-                                                                                                                                                                                                                                                                                                                                                                                            
-            function minMaxIncr(questionNumber, left, right, incr)
-            {
-                if (left == null)
-                    var left = '';
-                else
-                    left.replace("'", "&#39;");
-                if (right == null)
-                    var right = '';
-                else
-                    right.replace("'", "&#39;");
-                if (incr == null)
-                    var incr = '';
-                                                                                                                                                                                                        
-                var answersDiv = document.getElementById("answersDiv" + questionNumber);
-                                                                                                                                                                                                                                                                                                                                                                                               
-                var answerDiv = document.createElement("div");
-                answerDiv.className = "answerDiv";
-                                                                                                                               
-                var leftLabel = document.createElement("label");
-                var rightLabel = document.createElement("label");
-                var scaleLabel = document.createElement("label");
-                leftLabel.innerHTML = "Left label";
-                rightLabel.innerHTML = "Right label";
-                scaleLabel.innerHTML = "Scale count";
-                                                                                                                                
-                var leftInput = document.createElement("input");
-                leftInput.type = "text";
-                leftInput.value = left;
-                leftInput.name= "q" + questionNumber + "ans1";
-                leftInput.setAttribute("onchange", "handleAnswerChange(" 
-                    + questionNumber + ")");
-                                                                                                                                
-                var rightInput = document.createElement("input");
-                rightInput.type = "text";
-                rightInput.value = right;
-                rightInput.name = "q" + questionNumber + "ans2";
-                rightInput.setAttribute("onchange", "handleAnswerChange(" 
-                    + questionNumber + ")");
-                                                                                                                                
-                var scaleInput = document.createElement("input");
-                scaleInput.type = "text";
-                scaleInput.className = "intBox";
-                scaleInput.value = incr;
-                scaleInput.setAttribute("onblur", "checkInt(this)");
-                scaleInput.setAttribute("onchange", "handleAnswerChange(" 
-                    + questionNumber + ")");
-                scaleInput.name = "q" + questionNumber + "ans3";
-                                                                                                                                
-                answerDiv.appendChild(leftLabel);
-                answerDiv.appendChild(leftInput);
-                answerDiv.appendChild(rightLabel);
-                answerDiv.appendChild(rightInput);
-                answerDiv.appendChild(scaleLabel);
-                answerDiv.appendChild(scaleInput);
-                                                                                                                                                                                                                                                                                                                                                                           
-                answersDiv.appendChild(answerDiv);
-            }         
-                                                                                                                                                                                                                                                                                                                                                                                                                                                 
-                                                                                                                                                                                                                                                                                                                                                                                                                                                         
-            function addQuestion(code, title, description)
-            {
-                var questionsDiv = document.getElementById('questionsDiv');
-                var newQuestion = getNewQuestion(code, title, description);
-
-                newQuestion.prev = document.lastQuestion;
-                document.lastQuestion = newQuestion;
-
-                questionsDiv.appendChild(newQuestion);
-                questionCount++;
-            }
-                                                                                                                                                                                                                                                                                                                                                                                    
-            function removeLastQuestion()
-            {
-                var questionsDiv = document.getElementById('questionsDiv');
-                                                                                                                                                                                                                                                                                                                                                                                        
-                if (document.lastQuestion != null)
-                {
-                    questionsDiv.removeChild(document.lastQuestion);
-                    document.lastQuestion = document.lastQuestion.prev;
-                    questionCount--;  
-                }
-                else
-                {
-                    // do nothing
-                }               
-            }
-                                                                                                                                                                                                                                                                                                                                                             
-            function save(surveyID)
-            {
-                if (checksPassed())
-                {
-                    var form = document.getElementById('survey');
-                    var questionsDiv = document.getElementById('questionsDiv');
-                    form.action = "surveycreation.php";
-                                                                                                                                                                                                                                                                                                                                
-                    /* extra time stamp */
-                    var date = new Date();
-                    var minutes = date.getUTCMinutes();
-                    if (minutes < 10)
-                        minutes = "0" + minutes;
-                    var timeStamp = date.getHours() + ":" + minutes;
-                    var timeStampInput = document.createElement("input");
-                    timeStampInput.name = "timeStamp";
-                    timeStampInput.value = timeStamp;
-                    timeStampInput.type = "hidden";
-                                                                                                                                                                                                                                                                                    
-                    var surveyIDInput = document.createElement("input");
-                    surveyIDInput.name = "surveyID";
-                    surveyIDInput.value = surveyID;
-                    surveyIDInput.type = "hidden";
-                                                                                                                                                                                                                                                                                                             
-                    questionsDiv.appendChild(timeStampInput);
-                    questionsDiv.appendChild(surveyIDInput);
-                    form.submit();
-                }
-            }
-                                                                                                                                                            
-            function selectAll(input)
-            {
-                input.select();
-            }
-                                                                                                                                                            
-            /* --- input checking --- */
-            function checksPassed()
-            {
-                var form = document.getElementById('survey');
-                                                                                                                                        
-                for (var i = 0; i < form.length; i++)
-                {
-                    if (form.elements[i].checkPassed == 'no')
-                        return false;
-                }
-                return true;
-            }
-                                                                                                                                    
-
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
-        </script>
-        <?php
-    }
-
-    private function surveyHead() {
-        ?><div id="surveyHead">
-        <?php
-        $this->titleBox();
-        $this->saveSurvey();
-        $this->descriptionBox();
-        $this->surveyLink();
-        ?></div>
-        <?php
-    }
-
-    private function titleBox() {
-        if (isset($this->survey->title))
-            $value = $this->survey->title;
-        else
-            $value = 'Untitled Survey';
-        ?>
-        <input type="text" id="surveyTitle" class="titleBox" name="surveyTitle" value="<?php echo str_replace("\"", "&quot;", $value); ?>" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
-        <?php
-    }
-
-    private function saveSurvey() {
-        if (isset($this->timeStamp))
-            echo "<div id='timeStamp'>Last saved " . $this->timeStamp . '</div>';
-        if (isset($this->survey->id))
-            $id = $this->survey->id;
-        else
-            $id = null;
-        ?>
-        <input id="surveySaveButton" type="button" onclick="save('<?php echo $id; ?>')" class='surveyButton' value='Save' />
-        <?php
-    }
-
-    private function descriptionBox() {
-        if (isset($this->survey->description))
-            $value = $this->survey->description;
-        else
-            $value = 'Write a helpful description for this survey here.';
-        ?>
-        <textarea id="surveyDescription" class="descriptionBox" name="surveyDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea>
-        <?php
-    }
-
-    private function surveyLink() {
-        if (isset($this->survey)) {
-            $surveyID = $this->survey->id;
-
-            $link = $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) .
-                    '/survey.php?id=' . $surveyID;
-            ?>
-            <input type="text" value="<?php echo $link; ?>" id="surveyLink" onclick="selectAll(this)">
-            <?php
-        }
-    }
-
-    private function questionCreationForm() {
-        ?>
-        <div id='questionsDiv'>
-        </div>
-        <?php
-        if (isset($this->survey)) {
-            foreach ($this->survey->questions as $numQ => $question) {
-                ?>
-                <script type="text/javascript">
-                    var answers = new Array();
-                <?php
-                /* Put all answers in js array */
-                foreach ($question->answers as $numA => $answer) {
-                    echo 'answers[' . $numA . '] = "' . addslashes($answer) . '"; ';
-                    ?> 
-                                                                                                                                                                                                                                                                                      
-                    <?php
-                }
-                ?>
-                    var code = "<?php echo addslashes($question->code); ?>";
-                    var title = "<?php echo addslashes($question->title); ?>";
-                    var description = "<?php echo addslashes($question->description); ?>";
-                    addQuestion(code, title, description);
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
-                    var select = document.getElementById('<?php echo $numQ; ?>');
-                    var type = '<?php echo $question->type; ?>';
-
-                    for (var i = 0; i < select.options.length; i++) {
-                        if (select.options[i].value == type)
-                        {
-                            select.options[i].selected = true;
-                            handleType(select, answers);
-                            break;
-                        }
-                    }      
-                                                                                                                                                                                                                                                                                                                                    
-                                                                                                                                                                                                                                                                                                                                    
-                    /* questionID stuff */
-                    var questionIDInput = document.createElement("input");
-                    questionIDInput.id = "questionID<?php echo $numQ; ?>";
-                    questionIDInput.name = "questionID<?php echo $numQ; ?>";
-                    questionIDInput.value = "<?php echo $question->id; ?>";
-                    questionIDInput.type = "hidden";
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
-                    document.getElementById("questionsDiv").appendChild(questionIDInput);
-
-                </script>
-                <?php
-            }
-        } else {
-            ?>
-            <script type="text/javascript"> addQuestion();</script>
-            <?php
-        }
-    }
-
-    private static function addQuestionButton() {
-        ?>
-        <input id="addQuestionButton" type="button" onclick="addQuestion()" value="Add New Question" class="surveyButton" />
-        <?php
-    }
-
-    private static function removeLastQuestionButton() {
-        ?>
-        <input type="button" onclick="removeLastQuestion()" value="x" class="surveyButton" />
-        <?php
-    }
-
-}
-?>
Index: Dev/trunk/classes/SurveyMenu.php
===================================================================
--- Dev/trunk/classes/SurveyMenu.php	(revision 117)
+++ 	(revision )
@@ -1,71 +1,0 @@
-<?php
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- * Description of SurveyMenu
- *
- * @author fpvanagthoven
- */
-class SurveyMenu extends Menu {
-
-    public function __construct($surveys) {
-        ?> <fieldset class="menu"> <?php
-        parent::__construct('Survey');
-        ?> <div class="menuButtons"> <?php
-        SurveyMenu::newSurveyButton();
-        SurveyMenu::loadSurveyButton();
-//        SurveyMenu::deleteSurveyButton();
-        ?> </div> <?php
-        SurveyMenu::loadSurveyList($surveys);
-        ?> </fieldset> <?php
-    }
-
-    public static function newSurveyButton() {
-        ?>
-
-        <form action="surveycreation.php" method="post">
-
-            <input type="submit" value="New" class="surveyButton bigSurveyButton" />
-
-        </form>
-
-        <?php
-    }
-
-    public static function loadSurveyButton() {
-        ?>
-        <form id="loadForm" action="surveycreation.php" method="post">
-            <input type="button" onclick="loadSurvey()" value="Load / Edit" class="surveyButton bigSurveyButton" />
-        </form>
-        <?php
-    }
-
-    public static function deleteSurveyButton() {
-        ?>
-        <form action="" method="post">
-            <input type="button" onclick="delSurvey()" value="Delete survey" class="surveyButton bigSurveyButton" />
-        </form>
-        <?php
-    }
-
-    /**
-     *
-     * @param Survey $surveys An array of surveys
-     */
-    public static function loadSurveyList($surveys) {
-        ?>
-        <select id="surveysToLoad" class="toLoad" size="1000">
-            <?php
-            foreach ($surveys as $survey) {
-                ?><option value='<?php echo $survey->id; ?>'><?php echo $survey->title; ?></option><?php
-        }
-            ?>
-        </select>
-        <?php
-    }
-
-}
-?>
Index: Dev/trunk/classes/SurveyRDFReader.php
===================================================================
--- Dev/trunk/classes/SurveyRDFReader.php	(revision 117)
+++ 	(revision )
@@ -1,103 +1,0 @@
-<?php
-
-class SurveyRDFReader
-{
-    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()
-    {
-        if(file_exists($this->filePath))
-        {
-            $this->model->load($this->filePath);
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    public function getSurveyInfo()
-    {		
-        $this->loadSurvey();
-
-        $result = array();
-        $result['info'] = $this->readSurveyInfo();				
-        $result['questionIDs'] = $this->readSurveyQuestionIDs();
-
-        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 readSurveyQuestionIDs()
-    {
-        $querystring = '
-            PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT 	?questionID
-            WHERE 
-            {	
-                    _survey	predicates:resource_type	resources:survey ;
-                                predicates:has_question		?questionID				
-            }';
-
-        $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;
-    }
-}
-?>
Index: Dev/trunk/classes/SurveyRDFWriter.php
===================================================================
--- Dev/trunk/classes/SurveyRDFWriter.php	(revision 117)
+++ 	(revision )
@@ -1,66 +1,0 @@
-<?php
-
-class SurveyRDFWriter 
-{
-    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/';
-        if (!is_dir($this->filePath))
-            mkdir($this->filePath);	
-    }	
-
-    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($uID)
-    {				
-        $userID = new Literal($uID);
-
-        $predicateCreator = new Resource(CREATOR);
-        $this->model->add(new Statement($this->resourceSurvey,$predicateCreator,$userID));
-    }
-
-    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/SurveyResults.php
===================================================================
--- Dev/trunk/classes/SurveyResults.php	(revision 117)
+++ 	(revision )
@@ -1,59 +1,0 @@
-<?php
-
-class ResultType
-{
-	/* possible types */
-	const TEXT = 0;				// string
-	const INTEGER = 1;			// int
-	const MULTIPLE_CHOICE = 2;  // string
-	const CHECKBOXES = 3;		// array
-	const SCALE = 4;			// int
-}
-
-/**
- * 1 Results per Survey
- *
- * @author Frans
- */
-class SurveyResults
-{
-	private $questionResults; 
-
-	public function __construct()
-	{
-		$this->questionResults = array();
-	}
-
-	public function addQuestionResult($result)
-	{
-		array_push($this->questionResults, $result);
-	}
-	
-	public function getQuestionResults()
-	{
-		return $this->questionResults;
-	}
-	
-}
-
-/**
- * A Result per question
- */
-class QuestionResult
-{
-	private $type;
-	public $answers; // array
-
-	public function __construct($type, $answers)
-	{
-		$this->type = $type;
-		$this->answers = $answers;
-	}
-        
-        public function getType()
-        {
-            return $this->type;
-        }
-}
-
-?>
Index: Dev/trunk/classes/SurveyTool.php
===================================================================
--- Dev/trunk/classes/SurveyTool.php	(revision 117)
+++ 	(revision )
@@ -1,162 +1,0 @@
-<?php
-
-/**
- * Description of SurveyTool
- *
- * @author fpvanagthoven
- */
-class SurveyTool {
-
-    private $survey;
-
-    public function __construct($survey) {
-        $this->survey = $survey;
-
-        $this->javascript();
-        $this->init();
-    }
-
-    private function javascript() {
-        ?>
-        <script type="text/javascript">
-                        /* --- input checking --- */
-            function checksPassed(form)
-            {
-                for (var i = 0; i < form.length; i++)
-                {
-                    if (form.elements[i].checkPassed == 'no')
-                        return false;
-                }
-                return true;
-            }
-                    
-            function checkInt(input)
-            {
-                input.style.borderWidth = '1px' ;
-                var value = input.value;
-                if (isNaN(value))
-                {
-                    input.style.borderColor = 'red';
-                    input.checkPassed = 'no';
-                }
-                else
-                {
-                    input.style.border = '1px solid #abadb3';
-                    input.checkPassed = null;
-                }
-            }
-        </script>
-        <?php
-    }
-
-    private function init() {
-        ?>
-        <form name="survey" action="" onsubmit="return checksPassed(this)" method="post">
-            <?php
-            $this->displayTitle();
-            $this->displayDescription();
-            $this->displayQuestions();
-            $this->submitSurvey();
-            ?>
-        </form>
-        <?php
-    }
-
-    private function displayTitle() {
-        ?>
-        <h1><?php echo $this->survey->title; ?></h1>
-        <?php
-    }
-
-    private function displayDescription() {
-        if ($this->survey->description != Survey::DEFAULT_DESCRIPTION)
-            $description = $this->survey->description;
-        else
-            $description = "";
-        ?>
-        <p class='centerBoxed'><?php echo $description; ?></p>
-        <?php
-    }
-
-    private function displayQuestions() {
-        foreach ($this->survey->questions as $numQ => $question) {
-
-            $this->displayQuestion($question, $numQ);
-        }
-    }
-
-    private function displayQuestion($question, $numQ) {
-        echo "<fieldset>";
-        $this->displayQuestionTitle($question);
-        $this->displayQuestionDescription($question);
-        $this->displayAnswerBox($question, $numQ);
-        echo "</fieldset>";
-    }
-
-    private function displayQuestionTitle($question) {
-        ?>
-        <?php echo "<legend><h2>" . $question->title . "</h2></legend>"; ?>
-        <?php
-    }
-
-    private function displayQuestionDescription($question) {
-        if ($question->description != "Write a question description here.")
-            $description = $question->description;
-        else
-            $description = "";
-        ?>
-        <p><?php echo "<div class='questionDescription noPadding'>" . $description . "</div>"; ?></p>
-        <?php
-    }
-
-    private function displayAnswerBox($question, $numQ) {
-        echo "<div class='answerBox'>";
-        switch ($question->type) {
-            case 'text':
-                ?>
-                <input type="text" name="<?php echo 'q' . $numQ . 'result1' ?>" value="" class="textBox"/>
-                <?php
-                break;
-            case 'int':
-                ?>
-                <input type="text" name="<?php echo 'q' . $numQ . 'result1' ?>" value="" onchange="checkInt(this)" class="intBox"/>
-                <?php
-                break;
-            case 'mc':
-                foreach ($question->answers as $answer) {
-                    ?>
-                    <input type="radio" name="<?php echo 'q' . $numQ . 'result1' ?>" value="<?php echo $answer; ?>" /><?php echo $answer; ?><br />
-                    <?php
-                }
-                break;
-            case 'checkboxes':
-                foreach ($question->answers as $numA => $answer) {
-                    ?>
-                    <input type="checkbox" name="<?php echo 'q' . $numQ . 'result' . $numA; ?>" value="<?php echo $answer; ?>" /><?php echo $answer; ?><br />
-                    <?php
-                }
-
-                break;
-            case 'scale':
-                ?>
-                <div class="scaleLabel"><?php echo $question->answers[1]; ?></div>
-                <?php
-                for ($i = 1; $i < $question->answers[3] + 1; $i++) {
-                    ?><input type="radio" class="scaleRadio" name="<?php echo 'q' . $numQ . 'result1' ?>" value="<?php echo $i; ?>"/><?php } ?>
-                <div class="scaleLabel"><?php echo $question->answers[2]; ?></div>
-                <?php
-                break;
-            default:
-                break;
-        }
-        echo "</div>";
-    }
-
-    private function submitSurvey() {
-        ?>
-        <input type="submit" value="Submit survey!" id="submitSurvey" class="topMargin surveyButton bigSurveyButton"/>
-        <?php
-    }
-
-}
-?>
Index: Dev/trunk/classes/User.php
===================================================================
--- Dev/trunk/classes/User.php	(revision 131)
+++ Dev/trunk/classes/User.php	(revision 131)
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * Description of User
+ *
+ * @author jkraaijeveld
+ */
+
+class User extends ResearchToolObject {
+    
+    public $name;
+    public $password;
+    
+    /**
+     * Constructor of User
+     * If the user does not yet exist in the database, call with null as first parameter
+     */
+    public function __construct($uid = null, $name = null, $password = null) {
+        if(!isset($uid))
+        {
+             $uid = md5(uniqid(rand(), true));
+        }
+        $this->uid = $uid;
+        $this->name = $name;
+        $this->password = $password;
+    }
+}
+
+?>
Index: Dev/trunk/classes/UserConnector.php
===================================================================
--- Dev/trunk/classes/UserConnector.php	(revision 131)
+++ Dev/trunk/classes/UserConnector.php	(revision 131)
@@ -0,0 +1,128 @@
+<?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");
+
+/**
+ * Description of UserConnector
+ *
+ * @author jkraaijeveld
+ */
+class UserConnector implements IConnector{
+    
+    protected $model;
+    protected $fileName = 'data/users/users.rdf';
+    
+    /**
+     * Constructor for ApplicationConnector.
+     */
+    public function __construct()
+    {
+        //Ensure the required folder for this connector exists
+        if (!is_dir('data/users/'))
+            mkdir('data/users/');	
+    }
+    
+    /**
+     * function load()
+     * Loads the file into the standard MemModel.
+     */
+    public function load() {
+        //Get the Memory Model from the ModelFactory
+        $this->model = ModelFactory::getDefaultModel();
+        
+        //Ensure the required file exists before loading
+        if(file_exists($this->fileName))
+            $this->model->load($this->fileName);
+    }
+    
+    /**
+     * function save()
+     * Saves the MemModel into the given file.
+     */
+    public function save() {
+        $this->model->saveAs($this->fileName,'rdf'); 
+    }
+    
+    /**
+     * function get($arguments)
+     * Gets the array of User objects belonging to arguments supplied.
+     * @param type $arguments : An array containing zero or more of the following keys:
+     *                          'uid', 'name', 'password', 'style'
+     */
+    public function get($arguments) {
+        $this->load();
+        //Determine which arguments are supplied
+        $keys = array_keys($arguments);
+        //Set default values for arguments
+        $uid = "?uid"; $name = "?name"; $password = "?password";
+        //Set the arguments if they are supplied
+        if(in_array("uid", $keys))
+            $uid = "\"".$arguments["uid"]."\"";
+        if(in_array("name", $keys))
+            $name = '\''.$arguments["name"].'\'';
+        if(in_array("password", $keys))
+            $password = "\"".$arguments["password"]."\"";
+       
+        //Create the querystring 
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT ?uid, ?name, ?password
+            WHERE 	
+            {
+                    _user	predicates:resource_type	resources:user ;
+					predicates:uid ?uid ;
+					predicates:name ?name ;
+					predicates:password ?password ;
+                     			predicates:uid ' . $uid . ' 
+					predicates:name ' . $name . ' 
+					predicates:password ' . $password . ' 
+            }';
+        echo $querystring;
+        //Query the model
+        $results = $this->model->sparqlQuery($querystring);
+        $users = array();
+        if(!empty($results))
+        {
+            //Run over all results and create appropriate Application objets
+            foreach($results as $result)
+            { 
+                    $users[] = new User($result['?uid']->label, $result['?name']->label, $result['?password']->label);
+            }
+        }
+        return $users;
+    }
+    
+    /**
+     * Save the given User object in the file.
+     * @param type $rToolObject 
+     */
+    public function set($rToolObject)
+    {
+        $this->load();
+        $resourceUser = new Resource(USER . '/' . $rToolObject->uid);
+        //Remove the old value stored with the given id
+        $this->model->subtract($this->model->find($resourceUser, null, null));
+
+        $resourceUserType = new Resource(USER);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceUser,$predicateRType,$resourceUserType));
+
+        $literalUserID = new Literal($rToolObject->uid);
+        $predicateUniqueID = new Resource(UID);
+        $this->model->add(new Statement($resourceUser,$predicateUniqueID,$literalUserID));
+        
+        $literalUserName = new Literal($rToolObject->name);
+        $predicateName = new Resource(NAME);
+        $this->model->add(new Statement($resourceUser,$predicateName,$literalUserName));			
+
+        $literalPassword = new Literal($rToolObject->password);
+        $predicatePassword = new Resource(PASSWORD);
+        $this->model->add(new Statement($resourceUser,$predicatePassword,$literalPassword));
+        $this->save();
+    }
+}
+
+?>
Index: Dev/trunk/classes/UserDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/UserDatabaseInterface.php	(revision 117)
+++ 	(revision )
@@ -1,80 +1,0 @@
-<?php
-
-// Survey 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 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']);
-
-        if(!$this->checkUserName($userName))
-        {
-            $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 = $user['?name']->label;
-                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 = $encryptedPasswordLiteral[0]['?password']->label;
-
-        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 117)
+++ 	(revision )
@@ -1,54 +1,0 @@
-<?php
-
-class UserRDFReader
-{
-    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);
-    }
-
-    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 117)
+++ 	(revision )
@@ -1,48 +1,0 @@
-<?php
-
-class UserRDFWriter
-{
-    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);
-    }
-
-    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));	
-    }
-
-}
-
-?>
