Ignore:
Timestamp:
09/14/11 14:56:19 (14 years ago)
Author:
fpvanagthoven
Message:

Revised layout questioncreation.php

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/QuestionCreationTool.php

    r103 r104  
    2424                var type = select.valueOf().value;
    2525                clearSpecifications();
    26                                                        
     26                                                                       
    2727                /* set answerCount for options */
    2828                document.getElementById("answerSpecifications").answerCount = 1;
    29                                                        
     29                                                                       
    3030                switch (type) {
    3131                    case "text":
     
    4444                        break;
    4545                    default:
    46                                                                
    47                         break;
    48                 }
    49 
    50             }
    51                                                    
     46                                                                               
     47                        break;
     48                }
     49
     50            }
     51                                                                   
    5252            function clearSpecifications()
    5353            {
     
    5656                specs.clicked = null;
    5757                specs.lastAnswer = null;
    58                                        
     58                                                       
    5959                var questionType = document.getElementById("questionType");
    6060                var buttons = document.getElementById("questionButtons");
     
    6262                    questionType.removeChild(buttons);
    6363            }
    64                                                    
     64                                                                   
    6565            function addOption()
    6666            {                       
    6767                var specs = document.getElementById("answerSpecifications");
    68                                                        
     68                                                                       
    6969                addAddRemoveOptionButtonsOnce(specs);
    7070                addAnswerInput(specs);
    71                                                        
    72             }
    73                                                    
     71                                                                       
     72            }
     73                                                                   
    7474            function removeOption()
    7575            {
    7676                var specs = document.getElementById("answerSpecifications");
    77                                                        
     77                                                                       
    7878                if(specs.lastAnswer.prev != null)
    7979                {
     
    8383                }
    8484            }
    85                                                    
     85                                                                   
    8686            function addAnswerInput(specs)
    8787            {
    8888                var answerCount = specs.answerCount;
    89                                                        
     89                                                                       
    9090                /* set value for option textbox */
    9191                var optionStr = "Option " + answerCount;
    92                                                        
     92                                                                       
    9393                /* the input textbox */
    9494                var answerInput = document.createElement("input");
     
    9797                answerInput.setAttribute("value", optionStr);
    9898                answerInput.className = "answerInput";
    99                                                        
     99                                                                       
    100100                specs.appendChild(answerInput);
    101                                                        
     101                                                                       
    102102                /* Singly linked list */
    103103                answerInput.prev = specs.lastAnswer; // remember last one
    104104                specs.lastAnswer = answerInput; // new lastAnswer
    105                                                        
     105                                                                       
    106106                specs.answerCount++;               
    107107            }
    108                                                    
     108                                                                   
    109109            function addAddRemoveOptionButtonsOnce(specs)
    110110            {
     
    116116                    var typeBox = document.getElementById("questionType");
    117117                    typeBox.appendChild(buttonsDiv);
    118                                            
     118                                                           
    119119                    addAddOptionButton(buttonsDiv);                                 
    120120                    addRemoveOptionButton(buttonsDiv);
    121                                                            
     121                                                                           
    122122                    specs.clicked = true;
    123123                }
    124124            }
    125                                                    
     125                                                                   
    126126            function addAddOptionButton(buttonsDiv)
    127127            {   
     
    134134                buttonsDiv.appendChild(addOpt);                                 
    135135            }
    136                                                    
     136                                                                   
    137137            function addRemoveOptionButton(buttonsDiv)
    138138            {
     
    144144                buttonsDiv.appendChild(removeOpt);
    145145            }
    146                                                    
     146                                                                  
    147147            function minMax(min, max)
    148148            {
     
    151151                if (max == null)
    152152                    var max = '';
    153                                                                                                                                                                                                                                                                                
    154                 var specs = document.getElementById("answerSpecifications");
    155                                                                                                                                                                                                                                                                                                                                                                                                                        
     153                                                                                                                                                                                                                                                                                               
     154                var specs = document.getElementById("answerSpecifications");
     155                                                                                                                                                                                                                                                                                                                                                                                                                                      
    156156                var answerDiv = document.createElement("div");
    157                                                                                                                                                                                                                                                                                                                                                                                        
     157                                                                                                                                                                                                                                                                                                                                                                                                       
    158158                answerDiv.className = "answerDiv";
    159159                answerDiv.innerHTML = "<label for='min'>Min</label><input type='text' class='intBox' onchange='checkInt(this)' value='" + min + "' name='ans1' />" +
    160160                    "<label for='max'>Max</label><input type='text' class='intBox' onchange='checkInt(this)' value='" + max + "' name='ans2' />";
    161                                                                                                                                                                                                                                                                                                                                                                                                                    
     161                                                                                                                                                                                                                                                                                                                                                                                                                                  
    162162                specs.appendChild(answerDiv);
    163163            }     
    164                            
     164                                           
    165165            function checkInt(input)
    166166            {
     
    178178                }
    179179            }
    180            
     180                           
    181181            function minMaxIncr(left, right, incr)
    182182            {
     
    191191                if (incr == null)
    192192                    var incr = '';
    193                                                                                                                                                                                                        
    194                 var specs = document.getElementById("answerSpecifications");
    195                                                                                                                                                                                                                                                                                                                                                                                                
     193                                                                                                                                                                                                                       
     194                var specs = document.getElementById("answerSpecifications");
     195                                                                                                                                                                                                                                                                                                                                                                                                              
    196196                var answerDiv = document.createElement("div");
    197197                answerDiv.className = "answerDiv";
    198                                                                                                                                
     198                                                                                                                                              
    199199                var leftLabel = document.createElement("label");
    200200                var rightLabel = document.createElement("label");
     
    203203                rightLabel.innerHTML = "Right label";
    204204                scaleLabel.innerHTML = "Scale count";
    205                                                                                                                                
     205                                                                                                                                               
    206206                var leftInput = document.createElement("input");
    207207                leftInput.type = "text";
     
    209209                leftInput.name= "ans1";
    210210                leftInput.setAttribute("onchange", "handleAnswerChange()");
    211                                                                                                                                
     211                                                                                                                                               
    212212                var rightInput = document.createElement("input");
    213213                rightInput.type = "text";
     
    215215                rightInput.name = "ans2";
    216216                rightInput.setAttribute("onchange", "handleAnswerChange()");
    217                                                                                                                                
     217                                                                                                                                               
    218218                var scaleInput = document.createElement("input");
    219219                scaleInput.type = "text";
     
    223223                scaleInput.setAttribute("onchange", "");
    224224                scaleInput.name = "ans3";
    225                                                                                                                                
     225                                                                                                                                               
    226226                answerDiv.appendChild(leftLabel);
    227227                answerDiv.appendChild(leftInput);
     
    230230                answerDiv.appendChild(scaleLabel);
    231231                answerDiv.appendChild(scaleInput);
    232                                                                                                                                                                                                                                                                                                                                                                            
     232                                                                                                                                                                                                                                                                                                                                                                                          
    233233                specs.appendChild(answerDiv);
    234234            }         
    235                                                    
     235                                                                   
    236236        </script>
    237237        <?php
     
    249249    private function displayEditPanel() {
    250250        ?>
    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(); ?>
    281253        </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>
    282289        <?php
    283290    }
Note: See TracChangeset for help on using the changeset viewer.