Index: Dev/branches/jos-branch/classes/AnswerConnector.php
===================================================================
--- Dev/branches/jos-branch/classes/AnswerConnector.php	(revision 141)
+++ Dev/branches/jos-branch/classes/AnswerConnector.php	(revision 143)
@@ -12,5 +12,6 @@
 class AnswerConnector implements IConnector{
     protected $model;
-    protected $fileName = 'data/users/users.rdf';
+	protected $fileName = 'data/answers/answers.rdf';
+	protected $db;
     
     /**
@@ -44,16 +45,123 @@
     }
     
+	/**
+	 * Function get()
+	 * Get the answers corresponding to the arguments
+	 * 'Question' argument is supposed to be the question ID
+	 * 'Values' has to be an array to make sure multiple answers can be selected.
+	 */
     public function get($arguments)
-    {
-        
-    }
-    
+	{
+		$this->load();
+		$keys = array_keys($arguments);
+		$uid = "?uid"; $question = "?question_code"; $value	= ""; 
+		if(in_array("uid", $keys))
+			$uid = '\''.$arguments["uid"].'\'';
+		if(in_array("question", $keys))
+			$question = '\''.$arguments["question"].'\'';
+		if(in_array("values", $keys))
+		{
+			foreach ($arguments["values"] as $val)
+			{
+				$value = $value . 'predicates:answered \'' . $val . '\' ';
+			}
+		}
+		//Create the querystring
+		$querystring = '
+			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+			SELECT DISTINCT ?uid, ?question_code
+			WHERE
+			{
+				_answer predicates:resource_type resources:answer;
+
+				predicates:uid ?uid ;
+				predicates:question_code ?question_code;
+
+				predicates:uid ' . $uid . '
+				predicates:question_code ' . $question . '	
+				' . $value . '
+			}';
+
+		//Query the model
+		$results = $this->model->sparqlQuery($querystring);	
+		//An answer can have multiple values, get all these values for the answer instances found.
+		$answers = array();
+		if(!empty($results))
+		{
+            $this->db = new DatabaseInterface();
+			foreach($results as $result)
+			{
+				$values = $this->getValues($result['?uid']->label);
+				$questionResult = $this->db->get("question", array("uid" => $result['?question_code']->label));
+				$answers[] = new Answer($result['?uid']->label, $questionResult[0], $values);
+			}
+		}
+		return $answers;
+
+	}
+	/**
+	 * Gets the values that belong to the answer
+	 * specified by the UID
+	 */
+	private function getValues($uid)
+	{
+		$querystring = '
+			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+			SELECT DISTINCT ?answered
+			WHERE 
+			{
+				_answer predicates:resource_type resources:answer ;
+				predicates:answered ?answered ;
+				predicates:uid \''. $uid . '\'
+		}';
+		$values = $this->model->sparqlQuery($querystring);
+		$returnArray = array();
+		if(!empty($values))
+		{
+			foreach($values as $value)
+			{
+				$returnArray[] = $value['?answered']->label;
+			}
+		}
+		return $returnArray;
+	} 
+
     /**
-     *
+     * Saves the answer Object to the RDF file.
      * @param type $rToolObject
      */
     public function set($rToolObject)
     {
+        $this->load();
         
+        $resourceAnswer = new Resource(ANSWER.'/'.$rToolObject->uid);        
+        //Remove the old value stored with the given id
+        $this->model->subtract($this->model->find($resourceAnswer, null, null));
+        
+        //Save all the new values
+        $resourceAnswerType = new Resource(ANSWER);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceAnswer,$predicateRType,$resourceAnswerType));
+        
+		$answerId = new Literal($rToolObject->uid);
+		$predicateId = new Resource(UID);
+		$this->model->add(new Statement($resourceAnswer, $predicateId, $answerId));
+
+		$questionId = new Literal($rToolObject->question->uid);
+		$predicateQId = new Resource(QCODE);
+		$this->model->add(new Statement($resourceAnswer, $predicateQId, $questionId));
+
+		if(isset($rToolObject->values))
+		{
+			foreach($rToolObject->values as $value)
+			{
+				$answerValue = new Literal($value);
+				$predicateAnswer = new Resource(ANSWERED);
+				$this->model->add(new Statement($resourceAnswer, $predicateAnswer, $answerValue));
+			}
+		}
+        $this->save();
     }
 }
Index: Dev/branches/jos-branch/classes/AnswerSet.php
===================================================================
--- Dev/branches/jos-branch/classes/AnswerSet.php	(revision 143)
+++ Dev/branches/jos-branch/classes/AnswerSet.php	(revision 143)
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * AnswerSet is a collection of answers corresponding to a Session
+ *
+ */
+class AnswerSet extends ResearchToolObject{
+	public $survey;
+	public $respondent;
+	public $answers;
+
+	/**
+	 * Constructor for an AnswerSet object
+	 * @param type $uid
+	 * @param type $question
+	 * @param type $values
+	 */
+	public function __construct($uid=null, $survey=null, $respondent=null, $answers=null)
+	{
+		if(!isset($uid))
+		{
+			$uid = md5(uniqid(rand(), true));
+		}
+		$this->uid = $uid;
+		$this->survey = $survey;
+		$this->respondent = $respondent;
+		$this->answers = $answers;
+	}
+}
+
Index: Dev/branches/jos-branch/classes/AnswerSetConnector.php
===================================================================
--- Dev/branches/jos-branch/classes/AnswerSetConnector.php	(revision 143)
+++ Dev/branches/jos-branch/classes/AnswerSetConnector.php	(revision 143)
@@ -0,0 +1,170 @@
+<?php
+
+/**
+ * Description of AnswerSetConnector
+ *
+ * @author jkraaijeveld
+ */
+class AnswerSetConnector implements IConnector{
+    protected $model;
+    protected $fileName = 'data/answers/answersets.rdf';
+    protected $db;
+
+	/**
+	 * Constructor for the AnswerSetConnector
+	 */
+	public function __construct()
+	{
+		//Ensure the required folder for this connector exists
+		if(!is_dir('data/answers'))
+			mkdir('data/answers');
+	}
+
+	/**
+	 * 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 AnswerSets corresponding to the arguments
+	 * Arguments can be one or more of the following:
+	 * uid, survey, respondent, answers
+	 * Where answers is an array of answer ids
+	 */
+	public function get($arguments)
+	{
+		$this->load();
+		
+		$keys = array_keys($arguments);
+		$uid = ""; $survey = ""; $respondent = ""; $answers = "";
+		if(in_array("uid", $keys))
+			$uid = 'predicates:uid \''.$arguments["uid"].'\' ';
+		if(in_array("survey", $keys))
+			$survey = 'predicates:for_survey \''.$arguments["survey"].'\' ';
+		if(in_array("respondent", $keys))
+			$respondent = 'predicates:by_respondent \''.$arguments["respondent"].'\' ';
+		if(in_array("answers", $keys))
+		{
+			foreach ($arguments["answers"] as $answer)
+			{
+				$answers = $answers . 'predicates:given_answer \'' . $answer . '\' ';
+			}
+		}
+
+		//Build the query string
+		$querystring = '
+			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+			SELECT DISTINCT ?uid, ?for_survey, ?by_respondent
+			WHERE
+			{
+				_answerset	predicates:resource_type	resources:answerset ;
+				predicates:uid ?uid ;
+				predicates:for_survey ?for_survey ;
+				predicates:by_respondent ?by_respondent ;
+				' . $uid . $survey . $respondent . $answers . '
+			}';
+
+		//Query the model
+		$results = $this->model->sparqlQuery($querystring);
+		$answerSets = array();
+		if(!empty($results))
+		{
+			$this->db = new DatabaseInterface();
+			foreach($results as $result)
+			{
+				$survey = $this->db->get("survey", array("uid" => $result['?for_survey']->label));
+				$respondent = $this->db->get("respondent", array("uid" => $result['?by_respondent']->label));
+				$answers = 	$this->getAnswers($result['?uid']->label);
+				$answerSets[] = new AnswerSet($result['?uid']->label, $survey[0], $respondent[0], $answers);
+			}
+		}
+		return $answerSets;
+	}
+
+	/**
+	 * function getAnswers()
+	 * Gets the answers corresponding to the given answerset uid
+	 */
+	private function getAnswers($uid)
+	{
+		$querystring = '
+			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE .'>
+			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE .'>
+			SELECT DISTINCT ?given_answer
+			WHERE
+			{
+				_answerset predicates:resource_type resources:answerset ;
+				predicates:given_answer ?given_answer ;
+				predicates:uid \'' . $uid . '\'
+			}';
+		$answers = $this->model->sparqlQuery($querystring);
+		$returnArray = array();
+		if(!empty($answers))
+		{
+			foreach($answers as $answer)
+			{
+				$answerR = $this->db->get("answer", array("uid" => $answer["?given_answer"]->label));
+				$returnArray[] = $answerR[0];
+			}
+		}
+		return $returnArray;
+	}
+
+	/**
+	 * Save the given AnswerSet in the file.
+	 * @param type $rToolObject
+	 */
+	public function set($rToolObject)
+	{
+		$this->load();
+		$resourceAnswerSet = new Resource(ANSWERSET . '/' . $rToolObject->uid);
+		//Remove the old value stored with the given id
+		$this->model->subtract($this->model->find($resourceAnswerSet, null, null));
+
+		//Set the new values
+		$resourceAnswerSetType = new Resource(ANSWERSET);
+		$predicateRType = new Resource(RTYPE);
+		$this->model->add(new Statement($resourceAnswerSet, $predicateRType, $resourceAnswerSetType));
+
+		$answerSetId = new Literal($rToolObject->uid);
+		$predicateId = new Resource(UID);
+		$this->model->add(new Statement($resourceAnswerSet, $predicateId, $answerSetId));
+
+		$surveyId = new Literal($rToolObject->survey->uid);
+		$predicateSurvey = new Resource(FOR_SURVEY);
+		$this->model->add(new Statement($resourceAnswerSet, $predicateSurvey, $surveyId));
+
+		$respondentId = new Literal($rToolObject->respondent->uid);
+		$predicateRespondent = new Resource(BY_RESPONDENT);
+		$this->model->add(new Statement($resourceAnswerSet, $predicateRespondent, $respondentId));
+		
+		if(isset($rToolObject->answers))
+		{
+			foreach($rToolObject->answers as $answer)
+			{
+				$answerId = new Literal($answer->uid);
+				$predicateAnswer = new Resource(GIVEN_ANSWER);
+				$this->model->add(new Statement($resourceAnswerSet, $predicateAnswer, $answerId));
+			}
+		}
+		$this->save();
+	}
+}
Index: Dev/branches/jos-branch/classes/DatabaseInterface.php
===================================================================
--- Dev/branches/jos-branch/classes/DatabaseInterface.php	(revision 141)
+++ Dev/branches/jos-branch/classes/DatabaseInterface.php	(revision 143)
@@ -22,5 +22,7 @@
     private $surveyConnector;
     private $respondentConnector;
-    private $answerConnector;
+	private $answerConnector;
+	private $answerSetConnector;
+	private $sessionConnector;
     
     /**
@@ -34,5 +36,7 @@
         $this->surveyConnector = new SurveyConnector();
         $this->respondentConnector = new RespondentConnector();
-        $this->answerConnector = new AnswerConnector();
+		$this->answerConnector = new AnswerConnector();
+		$this->answerSetConnector = new AnswerSetConnector();
+		$this->sessionConnector = new SessionConnector();
     }
     
@@ -64,6 +68,10 @@
             case "answer":
                 return $this->answerConnector->get($arguments);
-                break;
-               
+				break;
+			case "answerset":
+				return $this->answerSetConnector->get($arguments);
+			case "session":
+				return $this->sessionConnector->get($arguments);
+
         }
     }
@@ -87,9 +95,19 @@
                 break;
             case "Survey":
-                $this->surveyConnector->set($rToolObject);
+				$this->surveyConnector->set($rToolObject);
+				break;
             case "Respondent":
-                $this->respondentConnector->set($rToolObject);
+				$this->respondentConnector->set($rToolObject);
+				break;
             case "Answer":
-                $this->answerConnector->set($rToolObject);
+				$this->answerConnector->set($rToolObject);
+				break;
+			case "AnswerSet":
+				$this->answerSetConnector->set($rToolObject);
+				break;
+			case "Session":
+				$this->sessionConnector->set($rToolObject);
+				break;
+
         }
     }
Index: Dev/branches/jos-branch/classes/Question.php
===================================================================
--- Dev/branches/jos-branch/classes/Question.php	(revision 141)
+++ Dev/branches/jos-branch/classes/Question.php	(revision 143)
@@ -29,4 +29,8 @@
     public function __construct($uid, $title = null, $type = null, $description = null, $category = null, $answers = null)
     {
+		if(!isset($uid))
+		{
+			$uid = md5(uniqid(rand(), true));
+		}
         $this->uid = $uid;
         $this->title = $title;
Index: Dev/branches/jos-branch/classes/QuestionConnector.php
===================================================================
--- Dev/branches/jos-branch/classes/QuestionConnector.php	(revision 141)
+++ Dev/branches/jos-branch/classes/QuestionConnector.php	(revision 143)
@@ -59,5 +59,5 @@
         $keys = array_keys($arguments);
         //Set default values for arguments
-        $uid = "?uid"; $title = "?title"; $type = "?type"; $description = "?description"; $category = "?category";
+        $uid = "?uid"; $title = "?title"; $type = "?type"; $description = "?description"; $category = "?category"; $has_answer = "";
         //Set the arguments if they are supplied
         if(in_array("uid", $keys))
@@ -70,5 +70,12 @@
             $description = "\"".$arguments["description"]."\"";
         if(in_array("category", $keys))
-            $style = "\"".$arguments["category"]."\"";
+			$style = "\"".$arguments["category"]."\"";
+		if(in_array("answers", $keys))
+		{
+			foreach($arguments["answers"] as $answer)
+			{
+				$has_answer = $has_answer . 'predicates:has_answer \'' . $answer . '\' ';
+			}
+		}
            
         $querystring = '
@@ -89,5 +96,6 @@
                 predicates:question_type ' . $type . '
                 predicates:description ' . $description . '
-                predicates:question_category ' . $category . ' 
+				predicates:question_category ' . $category . ' 
+				' . $has_answer . '
             }';
         //Create the querystring 
Index: Dev/branches/jos-branch/classes/RespondentConnector.php
===================================================================
--- Dev/branches/jos-branch/classes/RespondentConnector.php	(revision 141)
+++ Dev/branches/jos-branch/classes/RespondentConnector.php	(revision 143)
@@ -73,16 +73,15 @@
             WHERE 	
             {
-                    _user	predicates:resource_type	resources:user ;
+                    _respondent	predicates:resource_type	resources:respondent ;
 					predicates:uid ?uid ;
 					predicates:name ?name ;
 					predicates:password ?password ;
-                     			predicates:uid ' . $uid . ' 
+          			predicates:uid ' . $uid . ' 
 					predicates:name ' . $name . ' 
 					predicates:password ' . $password . ' 
             }';
-        echo $querystring;
         //Query the model
         $results = $this->model->sparqlQuery($querystring);
-        $respondents = array();
+		$respondents = array();
         if(!empty($results))
         {
@@ -107,4 +106,5 @@
         $this->model->subtract($this->model->find($resourceRespondent, null, null));
 
+		//Set the new values
         $resourceRespondentType = new Resource(RESPONDENT);
         $predicateRType = new Resource(RTYPE);
Index: Dev/branches/jos-branch/classes/Session.php
===================================================================
--- Dev/branches/jos-branch/classes/Session.php	(revision 143)
+++ Dev/branches/jos-branch/classes/Session.php	(revision 143)
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Description of Session
+ *
+ * @author jkraaijeveld
+ */
+
+class Session extends ResearchToolObject
+{
+	public $title;
+	public $datetime;
+	public $pipeline;
+	public $answersets;
+
+	
+	/**
+	 * Constructor for a Session object
+	 * @param type $uid
+	 * @param type $title
+	 * @param type $datetime
+	 * @param type $pipeline
+	 */
+	public function __construct($uid = null, $title = null, $datetime = null, $pipeline = null, $answersets = null)
+	{
+		if(!isset($uid))
+		{
+			$uid = md5(uniqid(rand(), true));
+		}
+		$this->uid = $uid;
+		$this->title = $title;
+		$this->datetime = $datetime;
+		$this->pipeline = $pipeline;
+		$this->answersets = $answersets;
+	}
+}	
+
+
+?>
Index: Dev/branches/jos-branch/classes/SessionConnector.php
===================================================================
--- Dev/branches/jos-branch/classes/SessionConnector.php	(revision 143)
+++ Dev/branches/jos-branch/classes/SessionConnector.php	(revision 143)
@@ -0,0 +1,206 @@
+<?php
+/**
+ * Description of SessionConnector
+ *
+ * @author jkraaijeveld
+ */
+class SessionConnector implements IConnector
+{
+	protected $model;
+	protected $fileName = 'data/sessions/sessions.rdf';
+	protected $db;
+
+	/**
+	 * Constructor for the SessionConnector
+	 */
+	public function __construct()
+	{
+		//Ensure the required folder for this connector exists
+		if(!is_dir('data/sessions'))
+			mkdir('data/sessions');
+	}
+
+	/**
+	 * function load()
+	 * Loads the file into the standard MemModel
+	 */
+	public function load()
+	{
+		$this->model = ModelFactory::getDefaultModel();
+		if(file_exists($this->fileName))
+			$this->model->load($this->fileName);
+	}
+
+	/**
+	 * fucntion save()
+	 * Saves the MemModel into the given file.
+	 */
+	public function save()
+	{
+		$this->model->saveAs($this->fileName,'rdf');
+	}
+
+	/**
+	 * Get the Sessions corresponding to the arguments
+	 * @ param type $arguments
+	 * Arguments can be one or more of the following:
+	 * uid, title, datetime, applications, surveys, answersets
+	 * Where applications, surveys and answersets are arrays containing ids
+	 */
+	public function get($arguments)
+	{
+		$this->load();
+
+		$keys = array_keys($arguments);
+		$uid = ""; $title = ""; $datetime = ""; $applications = ""; $surveys = ""; $answersets = "";
+		if(in_array("uid", $keys))
+			$uid = 'predicates:uid \''.$arguements["uid"].'\' ';
+		if(in_array("title", $keys))
+			$title = 'predicates:title \''.$arguments["title"].'\' ';
+		if(in_array("datetime", $keys))
+			$datetime = 'predicates:datetime \''.$arguments["datetime"].'\' ';
+		if(in_array("applications", $keys))
+		{
+			foreach($arguments["applications"] as $application)
+			{
+				$applications = $applications . 'predicates:has_application \'' . $application . '\' ';
+			}
+		}
+		if(in_array("surveys", $keys))
+		{
+			foreach($arguments["surveys"] as $survey)
+			{
+				$surveys = $surveys . 'predicates:has_survey \'' . $survey . '\' ';
+			}
+		}
+		if(in_array("answersets", $keys))
+		{
+			foreach($arguments["answersets"] as $answerset)
+			{
+				$answersets = $answersets . 'predicates:has_answerset \'' . $answerset . '\' ';
+			}
+		}
+	
+		//Build the query string
+		$querystring = '
+			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+			SELECT DISTINCT ?uid, ?title, ?datetime
+			WHERE
+			{
+				_session predicates:resource_type resources:session ;
+				predicates:uid ?uid ;
+				predicates:title ?title ;
+				' . $uid . $title . $datetime . $applications . $surveys . $answersets . '
+			}';
+		//Query the model
+		$results = $this->model->sparqlQuery($querystring);
+
+		$sessions = array();
+		if(!empty($results))
+		{
+			$this->db = new DatabaseInterface();
+			foreach($results as $result)
+			{
+				$pipeline = $this->getPipeline($result['?uid']->label);
+				$answersets = $this->getAnswerSets($result['?uid']->label);
+				$datetime = new DateTime();
+				$datetime->setTimestamp(intval($result['?datetime']));
+				$sessions[] = new Session($result['?uid']->label, $result['?title']->label, $datetime, $pipeline, $answersets);
+			}
+		}
+		return $sessions;
+	}
+	/**
+	 * function getPipeline
+	 * Get the application and survey objects of the Session in order
+	 */
+	private function getPipeline($uid)
+	{
+		$querystring = '
+			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE .'>
+			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE .'>
+			SELECT DISTINCT ?object 
+			WHERE
+			{
+				_session predicates:resource_type resources:session .
+				?x predicates:uid \'' . $uid . '\' .
+				{ ?x predicates:has_application ?object .}
+				UNION
+				{ ?x predicates:has_survey ?object .}
+
+			
+		}';	
+		$result = $this->model->sparqlQuery($querystring);
+		print_r($result);
+	}
+
+	/**
+	 * function getAnswerSets
+	 * Get the answersets belonging to the given session
+	 */
+	private function getAnswerSets($uid)
+	{
+	}
+
+	/**
+	 * Save the given Session object in the file.
+	 * @param type $rToolObjects
+	 */
+	public function set($rToolObject)
+	{
+		$this->load();
+		$resourceSession = new Resource(SESSION . '/' . $rToolObject->uid);
+		//Remove the old value stored with the given id
+		$this->model->subtract($this->model->find($resourceSession, null, null));
+
+		//Set the new values
+		$resourceSessionType = new Resource(SESSION);
+		$predicateType = new Resource(RTYPE);
+		$this->model->add(new Statement($resourceSession, $predicateType, $resourceSessionType));
+
+		$sessionId = new Literal($rToolObject->uid);
+		$predicateId = new Resource(UID);
+		$this->model->add(new Statement($resourceSession, $predicateId, $sessionId));
+
+		$sessionTitle = new Literal($rToolObject->title);
+		$predicateTitle = new Resource(TITLE);
+		$this->model->add(new Statement($resourceSession, $predicateTitle, $sessionTitle));
+
+		$sessionTimestamp = new Literal($rToolObject->datetime->getTimestamp());
+		$predicateTimestamp = new Resource(DATETIME);
+		$this->model->add(new Statement($resourceSession, $predicateTimestamp, $sessionTimestamp));
+
+		if(isset($rToolObject->pipeline))
+		{
+			foreach($rToolObject->pipeline as $element)
+			{
+				$sessionObject = new Literal($element->uid);
+				$predicateObject = null;
+				if(get_class($element) == "Application")
+					$predicateObject = new Resource(HAS_APPLICATION);
+				else if(get_class($element) == "Survey")
+					$predicateObject = new Resource(HAS_SURVEY);
+				if(isset($predicateObject))
+					$this->model->add(new Statement($resourceSession, $predicateObject, $sessionObject));
+			}
+		}
+
+		if(isset($rToolObjects->answerSets))
+		{
+			foreach($rToolObject->answersets as $answerset)
+			{
+				$sessionAnswerSet = new Literal($answerset->uid);
+				$predicateAnswerSet = new Resource(HAS_ANSWERSET);
+				$this->model->add(new Statement($resourceSession, $predicateAnswerSet, $sessionAnswerSet));
+			}
+		}
+
+		$this->save();
+	}
+
+
+
+}
+?>
+
Index: Dev/branches/jos-branch/classes/SurveyConnector.php
===================================================================
--- Dev/branches/jos-branch/classes/SurveyConnector.php	(revision 141)
+++ Dev/branches/jos-branch/classes/SurveyConnector.php	(revision 143)
@@ -95,5 +95,4 @@
         if(!empty($results))
         {
-            $this->db = new DatabaseInterface();
             foreach($results as $result)
             {
@@ -128,4 +127,5 @@
         if(!empty($results))
         {
+            $this->db = new DatabaseInterface();
             foreach($results as $questionId)
             {
