ch_score.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class ch_score
  5. */
  6. class ch_score extends survey_question
  7. {
  8. /**
  9. * @param array $survey_data
  10. * @param $form_content
  11. */
  12. public function createForm($survey_data, $formData)
  13. {
  14. parent::createForm($survey_data, $formData);
  15. $this->getForm()->addText('maximum_score', get_lang('MaximumScore'));
  16. $config = array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '120');
  17. if (is_array($formData['answers'])) {
  18. foreach ($formData['answers'] as $key => $value) {
  19. $this->getForm()->addHtmlEditor('answers['.$key.']', null, false, false, $config);
  20. /*
  21. $this->html .= ' <tr>';
  22. $this->html .= ' <td align="right"><label for="answers['.$key.']">'.($key+1).'</label></td>';
  23. //$this->html .= ' <td><input type="text" name="answers['.$key.']" id="answers['.$key.']" value="'.$form_content['answers'][$key].'" /></td>';
  24. //$this->html .= ' <td width="550">'.api_return_html_area('answers['.$key.']', api_html_entity_decode(stripslashes($form_content['answers'][$key]), ENT_QUOTES), '', '', null, ).'</td>';
  25. $this->html .= ' <td>';
  26. if ($key<$total_number_of_answers-1) {
  27. $this->html .= ' <input style="width:22px" type="image" src="../img/icons/22/down.png" value="move_down['.$key.']" name="move_down['.$key.']"/>';
  28. }
  29. if ($key>0) {
  30. $this->html .= ' <input style="width:22px" type="image" src="../img/icons/22/up.png" value="move_up['.$key.']" name="move_up['.$key.']"/>';
  31. }
  32. if ($total_number_of_answers> 2) {
  33. $this->html .= ' <input style="width:22px" type="image" src="../img/icons/22/delete.png" value="delete_answer['.$key.']" name="delete_answer['.$key.']"/>';
  34. }
  35. $this->html .= ' </td>';
  36. $this->html .= ' </tr>';*/
  37. }
  38. }
  39. parent :: addRemoveButtons($formData);
  40. }
  41. /**
  42. * @param FormValidator $form
  43. * @param array $questionData
  44. * @param array $answers
  45. */
  46. public function render(FormValidator $form, $questionData = array(), $answers = array())
  47. {
  48. foreach ($questionData['options'] as $key => & $value) {
  49. $options = array();
  50. for ($i=1; $i <= $questionData['maximum_score']; $i++) {
  51. $options[$i] = $i;
  52. }
  53. $form->addSelect(
  54. 'question'.$questionData['question_id'].'['.$key.'].', $value, $options
  55. );
  56. /*
  57. $this->html .= '<tr>
  58. <td>'.$value.'</td>';
  59. $this->html .= ' <td>';
  60. $this->html .= '<select name="question'.$form_content['question_id'].'['.$key.']">';
  61. $this->html .= '<option value="--">--</option>';
  62. $this->html .= '</select>';
  63. $this->html .= ' </td>';
  64. $this->html .= '</tr>';*/
  65. }
  66. }
  67. }