Ejemplo n.º 1
0
 function displayAnswers($questions_id)
 {
     $psQuestion = new PluginSurveyticketQuestion();
     $psAnswer = new PluginSurveyticketAnswer();
     $a_answers = $psAnswer->find("`plugin_surveyticket_questions_id`='" . $questions_id . "'");
     $psQuestion->getFromDB($questions_id);
     switch ($psQuestion->fields['type']) {
         case 'dropdown':
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='2' align='center'>";
             echo "<select name='question" . $questions_id . "' id='question" . $questions_id . "' >";
             echo "<option>" . Dropdown::EMPTY_VALUE . "</option>";
             foreach ($a_answers as $data_answer) {
                 echo "<option value='" . $data_answer['id'] . "'>" . $psAnswer->getAnswer($data_answer) . "</option>";
             }
             echo "</select>";
             echo "</td>";
             echo "</tr>";
             break;
         case 'checkbox':
             $i = 0;
             foreach ($a_answers as $data_answer) {
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='40' align='center'>";
                 echo "<input type='checkbox' name='question" . $questions_id . "[]' id='question" . $questions_id . "-" . $i . "' \n                  value='" . $data_answer['id'] . "' />";
                 echo "</td>";
                 echo "<td>";
                 echo $psAnswer->getAnswer($data_answer);
                 echo "</td>";
                 $this->displayAnswertype($data_answer['answertype'], "text-" . $questions_id . "-" . $data_answer['id']);
                 echo "</tr>";
                 $i++;
             }
             break;
         case 'radio':
         case 'yesno':
             $i = 0;
             foreach ($a_answers as $data_answer) {
                 echo "<tr class='tab_bg_1'>";
                 echo "<td width='40' align='center'>";
                 echo "<input type='radio' name='question" . $questions_id . "' id='question" . $questions_id . "-" . $i . "' \n                  value='" . $data_answer['id'] . "' />";
                 echo "</td>";
                 echo "<td>";
                 echo $psAnswer->getAnswer($data_answer);
                 echo "</td>";
                 $this->displayAnswertype($data_answer['answertype'], "text-" . $questions_id . "-" . $data_answer['id']);
                 echo "</tr>";
                 $i++;
             }
             break;
         case 'date':
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='2' align='center'>";
             $data_answer = current($a_answers);
             Html::showDateTimeField("question" . $questions_id, array('rand' => "question" . $questions_id));
             echo '<input type="hidden" name="realquestion' . $questions_id . '" id="realquestion' . $questions_id . '" value="' . $data_answer['id'] . '" />';
             echo "</td>";
             echo "</tr>";
             break;
         case 'input':
             echo "<tr class='tab_bg_1'>";
             echo "<td colspan='2' align='center'>";
             $data_answer = current($a_answers);
             echo '<input type="text" name="question' . $questions_id . '" id="question' . $questions_id . '" value="" size="71" />';
             echo '<input type="hidden" name="realquestion' . $questions_id . '" id="realquestion' . $questions_id . '" value="' . $data_answer['id'] . '" />';
             echo "</td>";
             echo "</tr>";
             break;
     }
     return count($a_answers);
 }