Changeset 104 for Dev/trunk/classes
- Timestamp:
- 09/14/11 14:56:19 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/QuestionCreationTool.php
r103 r104 24 24 var type = select.valueOf().value; 25 25 clearSpecifications(); 26 26 27 27 /* set answerCount for options */ 28 28 document.getElementById("answerSpecifications").answerCount = 1; 29 29 30 30 switch (type) { 31 31 case "text": … … 44 44 break; 45 45 default: 46 47 break; 48 } 49 50 } 51 46 47 break; 48 } 49 50 } 51 52 52 function clearSpecifications() 53 53 { … … 56 56 specs.clicked = null; 57 57 specs.lastAnswer = null; 58 58 59 59 var questionType = document.getElementById("questionType"); 60 60 var buttons = document.getElementById("questionButtons"); … … 62 62 questionType.removeChild(buttons); 63 63 } 64 64 65 65 function addOption() 66 66 { 67 67 var specs = document.getElementById("answerSpecifications"); 68 68 69 69 addAddRemoveOptionButtonsOnce(specs); 70 70 addAnswerInput(specs); 71 72 } 73 71 72 } 73 74 74 function removeOption() 75 75 { 76 76 var specs = document.getElementById("answerSpecifications"); 77 77 78 78 if(specs.lastAnswer.prev != null) 79 79 { … … 83 83 } 84 84 } 85 85 86 86 function addAnswerInput(specs) 87 87 { 88 88 var answerCount = specs.answerCount; 89 89 90 90 /* set value for option textbox */ 91 91 var optionStr = "Option " + answerCount; 92 92 93 93 /* the input textbox */ 94 94 var answerInput = document.createElement("input"); … … 97 97 answerInput.setAttribute("value", optionStr); 98 98 answerInput.className = "answerInput"; 99 99 100 100 specs.appendChild(answerInput); 101 101 102 102 /* Singly linked list */ 103 103 answerInput.prev = specs.lastAnswer; // remember last one 104 104 specs.lastAnswer = answerInput; // new lastAnswer 105 105 106 106 specs.answerCount++; 107 107 } 108 108 109 109 function addAddRemoveOptionButtonsOnce(specs) 110 110 { … … 116 116 var typeBox = document.getElementById("questionType"); 117 117 typeBox.appendChild(buttonsDiv); 118 118 119 119 addAddOptionButton(buttonsDiv); 120 120 addRemoveOptionButton(buttonsDiv); 121 121 122 122 specs.clicked = true; 123 123 } 124 124 } 125 125 126 126 function addAddOptionButton(buttonsDiv) 127 127 { … … 134 134 buttonsDiv.appendChild(addOpt); 135 135 } 136 136 137 137 function addRemoveOptionButton(buttonsDiv) 138 138 { … … 144 144 buttonsDiv.appendChild(removeOpt); 145 145 } 146 146 147 147 function minMax(min, max) 148 148 { … … 151 151 if (max == null) 152 152 var max = ''; 153 154 var specs = document.getElementById("answerSpecifications"); 155 153 154 var specs = document.getElementById("answerSpecifications"); 155 156 156 var answerDiv = document.createElement("div"); 157 157 158 158 answerDiv.className = "answerDiv"; 159 159 answerDiv.innerHTML = "<label for='min'>Min</label><input type='text' class='intBox' onchange='checkInt(this)' value='" + min + "' name='ans1' />" + 160 160 "<label for='max'>Max</label><input type='text' class='intBox' onchange='checkInt(this)' value='" + max + "' name='ans2' />"; 161 161 162 162 specs.appendChild(answerDiv); 163 163 } 164 164 165 165 function checkInt(input) 166 166 { … … 178 178 } 179 179 } 180 180 181 181 function minMaxIncr(left, right, incr) 182 182 { … … 191 191 if (incr == null) 192 192 var incr = ''; 193 194 var specs = document.getElementById("answerSpecifications"); 195 193 194 var specs = document.getElementById("answerSpecifications"); 195 196 196 var answerDiv = document.createElement("div"); 197 197 answerDiv.className = "answerDiv"; 198 198 199 199 var leftLabel = document.createElement("label"); 200 200 var rightLabel = document.createElement("label"); … … 203 203 rightLabel.innerHTML = "Right label"; 204 204 scaleLabel.innerHTML = "Scale count"; 205 205 206 206 var leftInput = document.createElement("input"); 207 207 leftInput.type = "text"; … … 209 209 leftInput.name= "ans1"; 210 210 leftInput.setAttribute("onchange", "handleAnswerChange()"); 211 211 212 212 var rightInput = document.createElement("input"); 213 213 rightInput.type = "text"; … … 215 215 rightInput.name = "ans2"; 216 216 rightInput.setAttribute("onchange", "handleAnswerChange()"); 217 217 218 218 var scaleInput = document.createElement("input"); 219 219 scaleInput.type = "text"; … … 223 223 scaleInput.setAttribute("onchange", ""); 224 224 scaleInput.name = "ans3"; 225 225 226 226 answerDiv.appendChild(leftLabel); 227 227 answerDiv.appendChild(leftInput); … … 230 230 answerDiv.appendChild(scaleLabel); 231 231 answerDiv.appendChild(scaleInput); 232 232 233 233 specs.appendChild(answerDiv); 234 234 } 235 235 236 236 </script> 237 237 <?php … … 249 249 private function displayEditPanel() { 250 250 ?> 251 <div id="creation"> 252 <form id="questionEditForm" action=""> 253 <table class="questionTable"> 254 <tr> 255 <td><label for="questionCode">Code</label></td> 256 <td><input id="questionCode" name="questionCode" size="5" /></td> 257 </tr> 258 <tr> 259 <td><label for="questionTitle">Title</label></td> 260 <td><input id="questionTitle" name="questionTitle" size="30" /></td> 261 </tr> 262 <tr> 263 <td><label for="questionDescription">Description</label></td> 264 <td><input id="questionDescription" name="questionDescription" size="60" /></td> 265 </tr> 266 <tr> 267 <td><label for="questionType">Type answer</label></td> 268 <td id="questionType"> 269 <select name="questionType" onchange="handleType(this)"> 270 <option value='text' selected='selected'>Text</option> 271 <option value='int'>Integer</option> 272 <option value='mc'>Multiple choice</option> 273 <option value='checkboxes'>Checkboxes</option> 274 <option value='scale'>Scale</option> 275 </select> 276 </td> 277 </tr> 278 </table> 279 <div id="answerSpecifications"></div> 280 </form> 251 <div id="questionCreation" class="floatLeft"> 252 <?php $this->displayForm(); ?> 281 253 </div> 254 <?php 255 } 256 257 private function displayForm() { 258 ?> 259 <form id="questionEditForm" method="post" action="" onsubmit=""> 260 <table class="questionTable"> 261 <tr> 262 <td><label for="questionCode">Code</label></td> 263 <td><input id="questionCode" name="questionCode" size="5" /></td> 264 </tr> 265 <tr> 266 <td><label for="questionTitle">Title</label></td> 267 <td><input id="questionTitle" name="questionTitle" size="30" /></td> 268 </tr> 269 <tr> 270 <td><label for="questionDescription">Description</label></td> 271 <td><input id="questionDescription" name="questionDescription" size="60" /></td> 272 </tr> 273 <tr> 274 <td><label for="questionType">Type answer</label></td> 275 <td id="questionType"> 276 <select name="questionType" onchange="handleType(this)"> 277 <option value='text' selected='selected'>Text</option> 278 <option value='int'>Integer</option> 279 <option value='mc'>Multiple choice</option> 280 <option value='checkboxes'>Checkboxes</option> 281 <option value='scale'>Scale</option> 282 </select> 283 </td> 284 </tr> 285 </table> 286 <div id="answerSpecifications"></div> 287 <input id="saveQuestion" type="submit" class="surveyButton" value="Save" /> 288 </form> 282 289 <?php 283 290 }
Note: See TracChangeset
for help on using the changeset viewer.