ch_percentage.php 770 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class ch_percentage
  5. */
  6. class ch_percentage extends survey_question
  7. {
  8. /**
  9. * @param FormValidator $form
  10. * @param array $questionData
  11. * @param array $answers
  12. */
  13. public function render(FormValidator $form, $questionData = array(), $answers = '')
  14. {
  15. $options = array(
  16. '--' => '--'
  17. );
  18. foreach ($questionData['options'] as $key => & $value) {
  19. $options[$key] = $value;
  20. }
  21. $name = 'question'.$questionData['question_id'];
  22. $form->addSelect(
  23. $name,
  24. null,
  25. $options
  26. );
  27. if (!empty($answers)) {
  28. $form->setDefaults([$name => $answers]);
  29. }
  30. }
  31. }