ch_personality.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class ch_personality
  5. */
  6. class ch_personality extends survey_question
  7. {
  8. /**
  9. * This function creates the form elements for the multiple response questions
  10. *
  11. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  12. * @version January 2007
  13. */
  14. public function createForm($survey_data, $form_content)
  15. {
  16. parent::createForm($survey_data, $form_content);
  17. $this->html .= ' <tr>';
  18. $this->html .= ' <td colspan="2"><strong>'.get_lang('DisplayAnswersHorVert').'</strong></td>';
  19. $this->html .= ' </tr>';
  20. // Horizontal or vertical
  21. $this->html .= ' <tr>';
  22. $this->html .= ' <td align="right" valign="top">&nbsp;</td>';
  23. $this->html .= ' <td>';
  24. $this->html .= ' <input name="horizontalvertical" type="radio" value="horizontal" ';
  25. if (empty($form_content['horizontalvertical']) || $form_content['horizontalvertical'] == 'horizontal') {
  26. $this->html .= 'checked="checked"';
  27. }
  28. $this->html .= '/>'.get_lang('Horizontal').'</label><br />';
  29. $this->html .= ' <input name="horizontalvertical" type="radio" value="vertical" ';
  30. if (isset($form_content['horizontalvertical']) && $form_content['horizontalvertical'] == 'vertical') {
  31. $this->html .= 'checked="checked"';
  32. }
  33. $this->html .= ' />'.get_lang('Vertical').'</label>';
  34. $this->html .= ' </td>';
  35. $this->html .= ' <td>&nbsp;</td>';
  36. $this->html .= ' </tr>';
  37. $this->html .= ' <tr>
  38. <td colspan="">&nbsp;</td>
  39. </tr>';
  40. // The options
  41. $this->html .= ' <tr>';
  42. $this->html .= ' <td colspan="3"><strong>'.get_lang('AnswerOptions').'</strong></td>';
  43. $this->html .= ' </tr>';
  44. $total_number_of_answers = count($form_content['answers']);
  45. $question_values = array();
  46. // Values of question options
  47. if (is_array($form_content['values'])) { // Check if data is correct
  48. foreach ($form_content['values'] as $key => & $value) {
  49. $question_values [] = '<input size="3" type="text" id="values['.$key.']" name="values['.$key.']" value="'.$value.'" />';
  50. }
  51. }
  52. $count = 0;
  53. if (is_array($form_content['answers'])) {
  54. foreach ($form_content['answers'] as $key => & $value) {
  55. $this->html .= ' <tr>';
  56. $this->html .= ' <td align="right"><label for="answers['.$key.']">'.($key+1).'</label></td>';
  57. //$this->html .= ' <td><input type="text" name="answers['.$key.']" id="answers['.$key.']" value="'.$form_content['answers'][$key].'" /></td>';
  58. $this->html .= ' <td width="550">'.api_return_html_area('answers['.$key.']', api_html_entity_decode(stripslashes($form_content['answers'][$key])), '', '', null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120')).'</td>';
  59. $this->html .= ' <td>';
  60. if ($total_number_of_answers > 2) {
  61. $this->html .= $question_values[$count];
  62. }
  63. if ($key < $total_number_of_answers - 1) {
  64. $this->html .= ' <input type="image" style="width:22px" src="../img/icons/22/down.png" value="move_down['.$key.']" name="move_down['.$key.']"/>';
  65. }
  66. if ($key > 0) {
  67. $this->html .= ' <input type="image" style="width:22px" src="../img/icons/22/up.png" value="move_up['.$key.']" name="move_up['.$key.']"/>';
  68. }
  69. if ($total_number_of_answers > 2) {
  70. $this->html .= ' <input type="image" style="width:22px" src="../img/icons/22/delete.png" value="delete_answer['.$key.']" name="delete_answer['.$key.']"/>';
  71. }
  72. $this->html .= ' </td>';
  73. $this->html .= ' </tr>';
  74. $count++;
  75. }
  76. }
  77. // The buttons for adding or removing
  78. //$this->html .= parent :: add_remove_buttons($form_content);
  79. }
  80. /**
  81. * @param FormValidator $form
  82. * @param array $questionData
  83. * @param array $answers
  84. */
  85. public function render(FormValidator $form, $questionData = array(), $answers = array())
  86. {
  87. $question = new ch_yesno();
  88. $question->render($form, $questionData, $answers);
  89. }
  90. }