ch_percentage.php 748 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 = 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, null, $options
  24. );
  25. if (!empty($answers)) {
  26. $form->setDefaults([$name => $answers]);
  27. }
  28. }
  29. }