Index: Dev/trunk/classes/SurveyDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/SurveyDatabaseInterface.php	(revision 45)
+++ Dev/trunk/classes/SurveyDatabaseInterface.php	(revision 62)
@@ -10,110 +10,115 @@
 class SurveyDatabaseInterface
 {		
-	protected $surveyRDFWriter;
-	protected $surveyRDFReader;
- 
+    protected $surveyRDFWriter;
+    protected $surveyRDFReader;
+
 
     public function __construct($surveyID)
     {
-		if($surveyID == null)
-			$surveyUID = md5( uniqid(rand(), true) );
-		else
-			$surveyUID = $surveyID;
-					
-		$this->surveyRDFWriter = new SurveyRDFWriter($surveyUID);
-		$this->surveyRDFReader = new SurveyRDFReader($surveyUID);
+        if($surveyID == null)
+            $surveyUID = md5( uniqid(rand(), true) );
+        else
+            $surveyUID = $surveyID;
+
+        $this->surveyRDFWriter = new SurveyRDFWriter($surveyUID);
+        $this->surveyRDFReader = new SurveyRDFReader($surveyUID);
     }
-	
-	public function setSurveyInfo($survey)
-	{
-		$sTitle = $survey['surveyTitle'];
-		$sDescription = $survey['surveyDescription'];
-		
-		$this->surveyRDFWriter->createSurvey($sTitle,$sDescription);
-		
-		$qNumber = 1;
-		while (isset($survey['questionTitle'.$qNumber]))
-		{
-			$qTitle = $survey['questionTitle'.$qNumber];
-			$qDescription = $survey['questionDescription'.$qNumber];
-			$qType = $survey['questionType'.$qNumber];
-			if (isset($survey['questionID'.$qNumber]))
-				$qID = $survey['questionID'.$qNumber];
-			else
-				$qID = md5( uniqid(rand(), true) );
-			
-			$qAnswers = array();
-			$aNumber = 1;
-			while (isset($survey['q'.$qNumber.'ans'.$aNumber]))
-			{
-				$aArray = array();
-				$aArray['Title'] = $survey['q'.$qNumber.'ans'.$aNumber];
-				$aArray['Description'] = 'answerDescription'.$aNumber;
-				$qAnswers[] = $aArray;
-				
-				$aNumber++;
-			}
-			
-			$this->surveyRDFWriter->addQuestion($qTitle,$qDescription,$qType,$qID,$qAnswers);
-			
-			$qNumber++;
-		}
 
-		$this->surveyRDFWriter->saveSurvey();
-	}
-	
-	public function getSurveyInfo()
-	{
-		$surveyInfo = array();
-		
-		$resultSurvey = $this->surveyRDFReader->getSurveyInfo();
-		
-		$surveyInfo['surveyID'] = substr($resultSurvey[0][0]['?uid'],9,strlen($resultSurvey[0][0]['?uid'])-11);
-		$surveyInfo['surveyTitle'] = substr($resultSurvey[0][0]['?title'],9,strlen($resultSurvey[0][0]['?title'])-11);
-		$surveyInfo['surveyDescription'] = substr($resultSurvey[0][0]['?description'],9,strlen($resultSurvey[0][0]['?description'])-11);
-									
-		for($qNumber = 1;$qNumber<=sizeof($resultSurvey[1][0]);$qNumber++)
-		{
-			$surveyInfo['questionID'.$qNumber] = substr($resultSurvey[1][3][$qNumber-1]['?questionID'],9,strlen($resultSurvey[1][3][$qNumber-1]['?questionID'])-11);
-			$surveyInfo['questionTitle'.$qNumber] = substr($resultSurvey[1][0][$qNumber-1]['?questionTitle'],9,strlen($resultSurvey[1][0][$qNumber-1]['?questionTitle'])-11);
-			$surveyInfo['questionDescription'.$qNumber] = substr($resultSurvey[1][1][$qNumber-1]['?questionDescription'],9,strlen($resultSurvey[1][1][$qNumber-1]['?questionDescription'])-11);
-			$surveyInfo['questionType'.$qNumber] = substr($resultSurvey[1][2][$qNumber-1]['?questionType'],9,strlen($resultSurvey[1][2][$qNumber-1]['?questionType'])-11);
-						
-			$resultAnswers = $this->surveyRDFReader->readSurveyAnswers($surveyInfo['questionID'.$qNumber]);
-						
-			if ($resultAnswers != null)
-			{
-				for($aNumber = 1;$aNumber<=sizeof($resultAnswers);$aNumber++)
-				{
-					$surveyInfo['q'.$qNumber.'ans'.$aNumber] = substr($resultAnswers[$aNumber-1]['?answerTitle'],9,strlen($resultAnswers[$aNumber-1]['?answerTitle'])-11);
-				}
-			}
-		}
-		
-		return $surveyInfo;
-	}
+    public function setSurveyInfo($survey)
+    {
+        $sTitle = $survey['surveyTitle'];
+        $sDescription = $survey['surveyDescription'];
 
-	public function getExistingSurveys()
-	{
-		$surveyIDs = array();
-		$surveys = array();
-	
-		if($handle = opendir('data/surveys/'))
-		{
-			while (false !== ($file = readdir($handle))) {
-				if(strstr($file, 'survey_'))
-					$surveyIDs[] = substr($file,7,strlen($file)-11);
-			}
-		}
-		
-		foreach($surveyIDs as $surveyID)
-		{
-			$surveyTitle = $this->surveyRDFReader->getSurveyTitleByID($surveyID);
-			$surveys[$surveyID] = substr($surveyTitle[0]['?title'],9,strlen($surveyTitle[0]['?title'])-11);
-		}
-		
-		return $surveys;
-	}
-	
+        $this->surveyRDFWriter->createSurvey($sTitle,$sDescription);
+
+        $sUserID = "Creator";
+
+        $this->surveyRDFWriter->setUserData($sUserID);
+
+        $qNumber = 1;
+        while (isset($survey['questionTitle'.$qNumber]))
+        {
+            $qTitle = $survey['questionTitle'.$qNumber];
+            $qDescription = $survey['questionDescription'.$qNumber];
+            $qType = $survey['questionType'.$qNumber];
+            if (isset($survey['questionID'.$qNumber]))
+                $qID = $survey['questionID'.$qNumber];
+            else
+                $qID = md5( uniqid(rand(), true) );
+
+            $qAnswers = array();
+            $aNumber = 1;
+            while (isset($survey['q'.$qNumber.'ans'.$aNumber]))
+            {
+                $aArray = array();
+                $aArray['Title'] = 'q'.$qNumber.'ans'.$aNumber;
+                $aArray['Description'] = $survey['q'.$qNumber.'ans'.$aNumber];
+                $qAnswers[] = $aArray;
+
+                $aNumber++;
+            }
+
+            $this->surveyRDFWriter->addQuestion($qTitle,$qDescription,$qType,$qID,$qAnswers);
+
+            $qNumber++;
+        }
+
+        $this->surveyRDFWriter->saveSurvey();
+    }
+
+    public function getSurveyInfo()
+    {
+        $surveyInfo = array();
+
+        $resultSurvey = $this->surveyRDFReader->getSurveyInfo();
+
+        $surveyInfo['surveyID'] = substr($resultSurvey[0][0]['?uid'],9,strlen($resultSurvey[0][0]['?uid'])-11);
+        $surveyInfo['surveyTitle'] = substr($resultSurvey[0][0]['?title'],9,strlen($resultSurvey[0][0]['?title'])-11);
+        $surveyInfo['surveyDescription'] = substr($resultSurvey[0][0]['?description'],9,strlen($resultSurvey[0][0]['?description'])-11);
+        $surveyInfo['surveyCreator'] = substr($resultSurvey[0][0]['?creator'],9,strlen($resultSurvey[0][0]['?creator'])-11);
+
+        for($qNumber = 1;$qNumber<=sizeof($resultSurvey[1][0]);$qNumber++)
+        {
+            $surveyInfo['questionID'.$qNumber] = substr($resultSurvey[1][3][$qNumber-1]['?questionID'],9,strlen($resultSurvey[1][3][$qNumber-1]['?questionID'])-11);
+            $surveyInfo['questionTitle'.$qNumber] = substr($resultSurvey[1][0][$qNumber-1]['?questionTitle'],9,strlen($resultSurvey[1][0][$qNumber-1]['?questionTitle'])-11);
+            $surveyInfo['questionDescription'.$qNumber] = substr($resultSurvey[1][1][$qNumber-1]['?questionDescription'],9,strlen($resultSurvey[1][1][$qNumber-1]['?questionDescription'])-11);
+            $surveyInfo['questionType'.$qNumber] = substr($resultSurvey[1][2][$qNumber-1]['?questionType'],9,strlen($resultSurvey[1][2][$qNumber-1]['?questionType'])-11);
+
+            $resultAnswers = $this->surveyRDFReader->readSurveyAnswers($surveyInfo['questionID'.$qNumber]);
+
+            if ($resultAnswers != null)
+            {
+                for($aNumber = 1;$aNumber<=sizeof($resultAnswers);$aNumber++)
+                {
+                    $surveyInfo['q'.$qNumber.'ans'.$aNumber] = substr($resultAnswers[$aNumber-1]['?answerDescription'],9,strlen($resultAnswers[$aNumber-1]['?answerDescription'])-11);
+                }
+            }
+        }
+
+        return $surveyInfo;
+    }
+
+    public function getExistingSurveys()
+    {
+        $surveyIDs = array();
+        $surveys = array();
+
+        if($handle = opendir('data/surveys/'))
+        {
+            while (false !== ($file = readdir($handle))) {
+                if(strstr($file, 'survey_') && strstr($file, '.rdf'))
+                    $surveyIDs[] = substr($file,7,strlen($file)-11);
+            }
+        }
+
+        foreach($surveyIDs as $surveyID)
+        {
+            $surveyTitle = $this->surveyRDFReader->getSurveyTitleByID($surveyID);
+            $surveys[$surveyID] = substr($surveyTitle[0]['?title'],9,strlen($surveyTitle[0]['?title'])-11);
+        }
+
+        return $surveys;
+    }
+
 }
 ?>
