Changeset 36
- Timestamp:
- 07/21/11 20:04:58 (14 years ago)
- Location:
- Dev/trunk
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/SurveyButton.php
r32 r36 10 10 * @author fpvanagthoven 11 11 */ 12 class NewSurveyButton {12 class SurveyButton { 13 13 14 14 public function __construct() { 15 16 } 17 18 public static function newSurveyButton() { 15 19 ?> 16 20 17 21 <form action="surveycreation.php" method="post"> 18 22 19 <input id="newSurveyButton" type="submit" name="btnlogin" value="Create new survey" class="surveyButton" /> 23 <input type="submit" value="Create new survey" class="surveyButton bigSurveyButton" /> 24 25 </form> 26 27 <?php 28 } 29 30 public static function loadSurveyButton() { 31 ?> 32 33 <form action="surveycreation.php" method="post"> 34 35 <input type="submit" value="Load survey" class="surveyButton bigSurveyButton" /> 20 36 21 37 </form> -
Dev/trunk/classes/SurveyCreationTool.php
r35 r36 38 38 /* autosave every 3 minutes */ 39 39 setTimeout("save('<?php echo $id; ?>')", 180000); 40 40 41 41 var questionCount = 1; 42 42 43 43 function getNewQuestion(title, description) 44 44 { 45 45 if (title == null) 46 46 var title = 'Untitled Question'; 47 47 48 48 if (description != null) 49 49 var description = description; 50 50 else 51 51 var description = 'Write a question description here.'; 52 52 53 53 var questionDiv = document.createElement("div"); 54 54 var htmlStr = … … 71 71 "<div id='answersDiv" + questionCount + "' class='answersDiv'></div>" + 72 72 "</div>"; 73 73 74 74 questionDiv.innerHTML = htmlStr; 75 75 76 76 return questionDiv; 77 77 } 78 78 79 79 function handleFocus(input) 80 80 { … … 91 91 } 92 92 } 93 93 94 94 function handleBlur(input) 95 95 { 96 96 var surveyTitle = document.getElementById('surveyTitle'); 97 97 var surveyDescription = document.getElementById('surveyDescription'); 98 98 99 99 if (input.value == "") 100 100 { 101 101 input.style.color = "gray"; 102 102 input.clicked = null; 103 103 104 104 if (input == surveyTitle) 105 105 { … … 112 112 } 113 113 } 114 114 115 115 function handleType(select, answers) 116 116 { … … 118 118 var type = select.valueOf().value; 119 119 var answersDiv = document.getElementById("answersDiv" + numQ ); 120 121 /* When type changes, remove question ID, because question changes */ 122 var questionIDInput = document.getElementById("questionID" + numQ); 123 if (questionIDInput != null) 124 { 125 var questionsDiv = document.getElementById("questionsDiv"); 126 questionsDiv.removeChild(questionIDInput); 127 } 128 120 129 answersDiv.answerCount = 1; 121 130 answersDiv.clicked = null; 122 131 123 132 switch (type) { 124 133 case 'mc': … … 133 142 else 134 143 addOption(numQ); 135 144 136 145 break; 137 146 case 'text': … … 140 149 case 'int': 141 150 answersDiv.innerHTML = ""; 142 151 143 152 //min max 144 153 if (answers != null) … … 172 181 173 182 } 174 175 183 184 176 185 function addOption(questionNumber, optionStr) 177 186 { … … 179 188 var answerCount = answersDiv.answerCount; 180 189 var answerDiv = document.createElement("div"); 181 190 182 191 if (optionStr == null) 183 192 var optionStr = "Option " + answerCount; 184 185 193 194 186 195 answerDiv.className = "answerDiv"; 187 196 188 197 var htmlStr = "<input type='text' name='q" + 189 198 questionNumber + "ans" + answerCount + "' value='" + optionStr + "' />"; 190 199 191 200 if (answersDiv.clicked == null) 192 201 { … … 194 203 + " class='surveyButton' onclick='addOption(" + questionNumber + ")' value='Add Option' />" + 195 204 "<input type='button' class='surveyButton' onclick='removeOption(" + questionNumber + ")' value='x' />"; 196 205 197 206 answersDiv.clicked = true; 198 207 } 199 208 200 209 answerDiv.innerHTML = htmlStr; 201 210 202 211 answerDiv.prev = answersDiv.lastAnswer; //singly linked list 203 212 answersDiv.lastAnswer = answerDiv; 204 213 205 214 answersDiv.appendChild(answerDiv); 206 215 answersDiv.answerCount++; 207 216 } 208 217 209 218 function removeOption(questionNumber) 210 219 { 211 220 var answersDiv = document.getElementById("answersDiv" + questionNumber); 212 221 213 222 if (answersDiv.lastAnswer.prev != null) 214 223 { … … 218 227 } 219 228 } 220 229 221 230 function minMax(questionNumber, min, max) 222 231 { … … 225 234 if (max == null) 226 235 var max = ''; 227 236 228 237 var answersDiv = document.getElementById("answersDiv" + questionNumber); 229 238 230 239 var answerDiv = document.createElement("div"); 231 240 232 241 answerDiv.className = "answerDiv"; 233 242 answerDiv.innerHTML = "<label for='min'>Min</label><input type='text' value='" + min + "' name='q" + questionNumber + "ans1' />" + 234 243 "<label for='max'>Max</label><input type='text' value='" + max + "' name='q" + questionNumber + "ans2' />"; 235 244 236 245 answersDiv.appendChild(answerDiv); 237 246 } 238 247 239 248 function minMaxIncr(questionNumber, left, right, incr) 240 249 { … … 245 254 if (incr == null) 246 255 var incr = ''; 247 256 248 257 var answersDiv = document.getElementById("answersDiv" + questionNumber); 249 258 250 259 var answerDiv = document.createElement("div"); 251 260 answerDiv.className = "answerDiv"; … … 254 263 "<label>Scale count</label><input type='text' value='" + incr + "' name='q" + questionNumber + "ans3' />" + 255 264 "<div id='inputCheckFeedback'" + questionNumber + ""; 256 265 257 266 answersDiv.appendChild(answerDiv); 258 267 } 259 260 268 269 261 270 function addQuestion(title, description) 262 271 { 263 272 var questionsDiv = document.getElementById('questionsDiv'); 264 273 var newQuestion = getNewQuestion(title, description); 265 274 266 275 267 276 newQuestion.prev = document.lastQuestion; … … 271 280 questionCount++; 272 281 } 273 282 274 283 function removeLastQuestion() 275 284 { 276 285 var questionsDiv = document.getElementById('questionsDiv'); 277 286 278 287 if (document.lastQuestion.prev != null) 279 288 { … … 287 296 } 288 297 } 289 298 290 299 function save(surveyID) 291 300 { … … 293 302 var questionsDiv = document.getElementById('questionsDiv'); 294 303 form.action = "surveycreation.php"; 295 304 296 305 /* extra time stamp */ 297 306 var date = new Date(); … … 304 313 timeStampInput.value = timeStamp; 305 314 timeStampInput.type = "hidden"; 306 315 307 316 var surveyIDInput = document.createElement("input"); 308 317 surveyIDInput.name = "surveyID"; 309 318 surveyIDInput.value = surveyID; 310 319 surveyIDInput.type = "hidden"; 311 320 312 321 questionsDiv.appendChild(timeStampInput); 313 322 questionsDiv.appendChild(surveyIDInput); 314 323 form.submit(); 315 324 } 316 317 325 326 318 327 </script> 319 328 <?php … … 370 379 foreach ($this->survey->questions as $numQ => $question) { 371 380 ?> 372 <script type="text/javascript"> 373 var questionIDInput = document.createElement("input"); 374 questionIDInput.name = "questionID<?php echo $numQ; ?>"; 375 questionIDInput.value = "<?php echo $question->id; ?>"; 376 questionIDInput.type = "hidden"; 377 378 document.getElementById("questionsDiv").appendChild(questionIDInput); 379 380 381 <script type="text/javascript"> 381 382 var answers = new Array(); 382 383 <?php … … 386 387 } 387 388 ?> 388 389 389 390 addQuestion('<?php echo $question->title; ?>', '<?php echo $question->description; ?>'); 390 391 391 392 var select = document.getElementById('<?php echo $numQ; ?>'); 392 393 var type = '<?php echo $question->type; ?>'; … … 399 400 break; 400 401 } 401 } 402 } 403 404 405 /* questionID stuff */ 406 var questionIDInput = document.createElement("input"); 407 questionIDInput.id = "questionID<?php echo $numQ; ?>"; 408 questionIDInput.name = "questionID<?php echo $numQ; ?>"; 409 questionIDInput.value = "<?php echo $question->id; ?>"; 410 questionIDInput.type = "hidden"; 411 412 document.getElementById("questionsDiv").appendChild(questionIDInput); 402 413 403 414 </script> -
Dev/trunk/css/style.css
r29 r36 61 61 /* ################################################################## 62 62 ===================== STYLESHEET OF GLORY ======================== */ 63 64 #newSurveyButton{65 height: 3em;66 width: 10em;67 }68 63 69 64 #surveyCreation { … … 155 150 } 156 151 152 .bigSurveyButton { 153 margin-top: 1px; 154 height: 3em; 155 width: 12em; 156 } 157 157 158 .surveyButton:hover { 158 159 background-color: white; -
Dev/trunk/index.php
r11 r36 17 17 <div id="content"> 18 18 <div id="menu"> 19 <?php new NewSurveyButton(); ?> 19 <?php 20 SurveyButton::newSurveyButton(); 21 SurveyButton::loadSurveyButton(); 22 ?> 20 23 </div> 21 24 </div> -
Dev/trunk/surveycreation.php
r35 r36 8 8 $timeStamp = $_POST['timeStamp']; 9 9 10 //echo 'This is what gets sent:';11 //var_dump($_POST);12 //echo '<br/><br/>';10 echo 'This is what gets sent:'; 11 var_dump($_POST); 12 echo '<br/><br/>'; 13 13 $surveyDBI = new SurveyDatabaseInterface(); 14 14 $surveyDBI->setSurveyInfo($_POST); 15 15 $info = $surveyDBI->getSurveyInfo(); 16 //echo '<br/><br/>';17 //echo 'This is what I get back:';18 //var_dump($info);16 echo '<br/><br/>'; 17 echo 'This is what I get back:'; 18 var_dump($info); 19 19 20 20 $savedSurvey = Survey::getSurvey($info);
Note: See TracChangeset
for help on using the changeset viewer.