ch_percentage.php 775 B

123456789101112131415161718192021222324252627282930313233343536
  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 = [], $answers = '')
  14. {
  15. $options = [
  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. }