Index: Dev/trunk/classes/Question.php
===================================================================
--- Dev/trunk/classes/Question.php	(revision 29)
+++ Dev/trunk/classes/Question.php	(revision 29)
@@ -0,0 +1,29 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of Question
+ *
+ * @author fpvanagthoven
+ */
+class Question {
+    public $title;
+    public $type;
+    public $description;
+    public $answers;
+    
+    public function __construct($title, $type, $description = null)
+    {
+        $this->title = $title;
+        $this->type = $type;
+        $this->description = $description;
+        $this->answers = array();
+    }
+
+}
+
+?>
Index: Dev/trunk/classes/Survey.php
===================================================================
--- Dev/trunk/classes/Survey.php	(revision 29)
+++ Dev/trunk/classes/Survey.php	(revision 29)
@@ -0,0 +1,64 @@
+<?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 function __construct($id, $title, $description = null)
+    {
+        $this->id = $id;
+        $this->title = $title;
+        $this->description = $description;
+        $this->questions = array();
+    }
+   
+    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]))
+        {
+            $title = $info['questionTitle' . $numQ];
+            $type = $info['questionType' . $numQ];
+            $description = $info['questionDescription' . $numQ];
+                    
+            $question = new Question($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;
+    }
+    
+}
+
+?>
Index: Dev/trunk/classes/SurveyCreationTool.php
===================================================================
--- Dev/trunk/classes/SurveyCreationTool.php	(revision 28)
+++ Dev/trunk/classes/SurveyCreationTool.php	(revision 29)
@@ -9,5 +9,11 @@
 class SurveyCreationTool {
 
+    private $survey;
+    private $timeStamp;
+
     public function __construct($survey = null, $timeStamp = null) {
+        $this->survey = $survey;
+        $this->timeStamp = $timeStamp;
+
         SurveyCreationTool::javascript();
         ?>
@@ -15,6 +21,6 @@
         <div id="surveyCreation"><form id="survey" action="submitsurvey.php" method="post">
                 <?php
-                SurveyCreationTool::surveyHead($timeStamp);
-                SurveyCreationTool::questionCreationForm();
+                $this->surveyHead();
+                $this->questionCreationForm();
                 SurveyCreationTool::addQuestionButton();
                 SurveyCreationTool::removeLastQuestionButton();
@@ -29,9 +35,10 @@
             /* autosave every 3 minutes */
         setTimeout("save()", 180000);
-                    
+                                                    
         var questionCount = 1;          
-                                                                                                                                                            
+                                                                                                                                                                                            
         function getNewQuestion()
         {
+                        
             var questionDiv = document.createElement("div");
             var htmlStr = 
@@ -40,5 +47,5 @@
                 "<th>Question " + questionCount + "</th>" +
                 "<tr><td><label for='questionTitle'>Title</label></td>" + 
-                "<td><input type='text' class='questionTitle' name='questionTitle" + questionCount + "' onfocus='handleFocus(this)' size='30' value='Untitled Question' /></td></tr>" +
+                "<td><input type='text' class='questionTitle' name='questionTitle" + questionCount + "' onfocus='handleFocus(this)' size='30' value='' /></td></tr>" +
                 "<tr><td><label for='questionDescription'>Description</label></td>" + 
                 "<td><input type='text' class='questionDescription' name='questionDescription" + questionCount + "' onfocus='handleFocus(this)' size='60' value='Write a question description here.' /></td>" +
@@ -54,10 +61,10 @@
                 "<div id='answersDiv" + questionCount + "' class='answersDiv'></div>" +
                 "</div>";
-                                                                                                                                                        
+                                                                                                                                                                                        
             questionDiv.innerHTML = htmlStr;
-                                                                                                                                                        
+                                                                                                                                                                                        
             return questionDiv;
         }
-                                                                                                                                                            
+                                                                                                                                                                                            
         function handleFocus(input)
         {
@@ -69,15 +76,15 @@
             }
         }
-                                                                                                                                                                                            
+                                                                                                                                                                                                                            
         function handleBlur(input)
         {        
             var surveyTitle = document.getElementById('surveyTitle');
             var surveyDescription = document.getElementById('surveyDescription');
-                                                                                                                                                                            
+                                                                                                                                                                                                            
             if (input.value == "")
             {
                 input.style.color = "gray";
                 input.clicked = null;
-                                                                                                                                                                                                    
+                                                                                                                                                                                                                                    
                 if (input == surveyTitle)
                 {
@@ -90,5 +97,5 @@
             }                           
         }
-                                                                                                                                            
+                                                                                                                                                                            
         function handleType(select)
         {
@@ -97,10 +104,10 @@
             answersDiv.answerCount = 1;
             answersDiv.clicked = null;
-                                                                                                
+                                                                                                                                
             switch (type) {
                 case 'mc':
                     answersDiv.innerHTML = "";
                     addOption(select.id);
-                                                                                                                                
+                                                                                                                                                                
                     break;
                 case 'text':
@@ -126,6 +133,6 @@
 
         }
-                                                                                                                            
-                                                                                                                    
+                                                                                                                                                            
+                                                                                                                                                    
         function addOption(questionNumber)
         {        
@@ -134,8 +141,8 @@
             var answerDiv = document.createElement("div");
             answerDiv.className = "answerDiv";
-                                                                                                                        
+                                                                                                                                                        
             var htmlStr = "<input type='text' name='q" + 
                 questionNumber + "ans" + answerCount + "' value='Option " + answerCount + "' />";
-                                                                                                
+                                                                                                                                
             if (answersDiv.clicked == null)
             {
@@ -143,21 +150,21 @@
                     + " class='surveyButton' onclick='addOption(" + questionNumber + ")' value='Add Option' />" +
                     "<input type='button' class='surveyButton' onclick='removeOption(" + questionNumber + ")' value='x' />";
-                                                                    
+                                                                                                    
                 answersDiv.clicked = true;
             }
-                                                                                                                               
+                                                                                                                                                               
             answerDiv.innerHTML = htmlStr;
-                                                                
+                                                                                                
             answerDiv.prev = answersDiv.lastAnswer; //singly linked list
             answersDiv.lastAnswer = answerDiv;
-                                                                                                                               
+                                                                                                                                                               
             answersDiv.appendChild(answerDiv);
             answersDiv.answerCount++;
         }
-                                                            
+                                                                                            
         function removeOption(questionNumber)
         {
             var answersDiv = document.getElementById("answersDiv" + questionNumber);
-                                                               
+                                                                                               
             if (answersDiv.lastAnswer.prev != null)
             {
@@ -167,37 +174,38 @@
             }
         }
-                                                                                    
+                                                                                                                    
         function minMax(questionNumber)
         {
             var answersDiv = document.getElementById("answersDiv" + questionNumber);
-                                                                                       
+                                                                                                                       
             var answerDiv = document.createElement("div");
-                                                        
+                                                                                        
             answerDiv.className = "answerDiv";
             answerDiv.innerHTML = "<label for='min'>Min</label><input type='text' name='q" + questionNumber + "ans1' />" +
                 "<label for='max'>Max</label><input type='text' name='q" + questionNumber + "ans2' />";
-                                                                                   
+                                                                                                                   
             answersDiv.appendChild(answerDiv);
         }  
-                                                                                    
+                                                                                                                    
         function minMaxIncr(questionNumber)
         {
             var answersDiv = document.getElementById("answersDiv" + questionNumber);
-                                                                                       
+                                                                                                                       
             var answerDiv = document.createElement("div");
             answerDiv.className = "answerDiv";
             answerDiv.innerHTML = "<label>Left label</label><input type='text' name='q" + questionNumber + "ans1' />" +
                 "<label>Right label</label><input type='text' name='q" + questionNumber + "ans2' />" +
-                "<label>Scale count</label><input type='text' name='q" + questionNumber + "ans3' />";
-                                                                                   
+                "<label>Scale count</label><input type='text' name='q" + questionNumber + "ans3' />" +
+                "<div id='inputCheckFeedback'" + questionNumber + "";
+                                                                                                                   
             answersDiv.appendChild(answerDiv);
         }         
-                                                                                                                                         
-                                                                                                                                                 
-        function addQuestion()
+                                                                                                                                                                         
+                                                                                                                                                                                 
+        function addQuestion(title, description)
         {
             var questionsDiv = document.getElementById('questionsDiv');
-            var newQuestion = getNewQuestion();
-                                                                                
+            var newQuestion = getNewQuestion(title, description);
+                                                                                                                
 
             newQuestion.prev = document.lastQuestion;
@@ -207,9 +215,9 @@
             questionCount++;
         }
-                                                                            
+                                                                                                            
         function removeLastQuestion()
         {
             var questionsDiv = document.getElementById('questionsDiv');
-                                                                                
+                                                                                                                
             if (document.lastQuestion.prev != null)
             {
@@ -223,11 +231,11 @@
             }               
         }
-                                                     
-        function save()
+                                                                                     
+        function save(surveyID)
         {
             var form = document.getElementById('survey');
             var questionsDiv = document.getElementById('questionsDiv');
             form.action = "surveycreation.php";
-                        
+                                                        
             /* extra time stamp */
             var date = new Date();
@@ -240,48 +248,67 @@
             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();
         }
-                                                                                    
-                                                                                                                                                                                                                                                                    
+                                                                                                                    
+                                                                                                                                                                                                                                                                                                    
         </script>
         <?php
     }
 
-    private static function surveyHead($timeStamp = null) {
+    private function surveyHead() {
         ?><div id="surveyHead">
         <?php
-        SurveyCreationTool::titleBox();
-        SurveyCreationTool::saveSurvey($timeStamp);
-        SurveyCreationTool::descriptionBox();
+        $this->titleBox();
+        $this->saveSurvey();
+        $this->descriptionBox();
         ?></div>
         <?php
     }
 
-    private static function titleBox() {
-        ?>
-        <input type="text" id="surveyTitle" name="surveyTitle" value="Untitled Survey" onblur="handleBlur(this)" onfocus="handleFocus(this)" />
-        <?php
-    }
-
-    private static function saveSurvey($timeStamp = null) {
-        if (isset($timeStamp))
-            echo "<div id='timeStamp'>Last saved " . $timeStamp . '</div>';
-        ?>
-        <input id="surveySaveButton" type="button" onclick="save()" class='surveyButton' value='Save' />
-        <?php
-    }
-
-    private static function descriptionBox() {
-        ?>
-        <textarea id="surveyDescription" name="surveyDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)">Write a helpful description for this survey here.</textarea>
-        <?php
-    }
-
-    private static function questionCreationForm() {
+    private function titleBox() {
+        if (isset($this->survey->title))
+            $value = $this->survey->title;
+        else
+            $value = 'Untitled Survey';
+        ?>
+        <input type="text" id="surveyTitle" name="surveyTitle" value="<?php echo $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" name="surveyDescription" onblur="handleBlur(this)" onfocus="handleFocus(this)"><?php echo $value; ?></textarea>
+        <?php
+    }
+
+    private function questionCreationForm() {
         ?>
         <div id='questionsDiv'>
         </div>
+
         <script type="text/javascript"> addQuestion(); </script>
         <?php
