ch_personality.php 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 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>';
  58. $this->html .= '<td>';
  59. if ($total_number_of_answers > 2) {
  60. $this->html .= $question_values[$count];
  61. }
  62. if ($key < $total_number_of_answers - 1) {
  63. $this->html .= '<input type="image" style="width:22px" src="'.Display::returnIconPath('down.png').'" value="move_down['.$key.']" name="move_down['.$key.']"/>';
  64. }
  65. if ($key > 0) {
  66. $this->html .= '<input type="image" style="width:22px" src="'.Display::returnIconPath('up.png').'" value="move_up['.$key.']" name="move_up['.$key.']"/>';
  67. }
  68. if ($total_number_of_answers > 2) {
  69. $this->html .= '<input type="image" style="width:22px" src="'.Display::returnIconPath('delete.png').'" value="delete_answer['.$key.']" name="delete_answer['.$key.']"/>';
  70. }
  71. $this->html .= '</td>';
  72. $this->html .= '</tr>';
  73. $count++;
  74. }
  75. }
  76. // The buttons for adding or removing
  77. //$this->html .= parent :: add_remove_buttons($form_content);
  78. }
  79. /**
  80. * @param FormValidator $form
  81. * @param array $questionData
  82. * @param array $answers
  83. */
  84. public function render(FormValidator $form, $questionData = array(), $answers = array())
  85. {
  86. $question = new ch_yesno();
  87. $question->render($form, $questionData, $answers);
  88. }
  89. }