Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/public/main/survey/ch_dropdown.php

45 lines
1.2 KiB

<?php
/* For licensing terms, see /license.txt */
/**
* Class ch_dropdown.
*/
class ch_dropdown extends survey_question
{
/**
* @param array $surveyData
* @param $formData
*/
public function createForm($surveyData, $formData)
{
parent::createForm($surveyData, $formData);
if (is_array($formData['answers'])) {
foreach ($formData['answers'] as $key => $value) {
$this->getForm()->addText('answers['.$key.']', $key + 1);
}
}
if (isset($formData['answersid']) && !empty($formData['answersid'])) {
foreach ($formData['answersid'] as $value) {
$this->getForm()->addHidden('answersid[]', $value);
}
}
parent::addRemoveButtons($formData);
}
/**
* @param array $questionData
* @param array $answers
*/
public function render(FormValidator $form, $questionData = [], $answers = [])
{
$name = 'question'.$questionData['question_id'];
$data = [0 => '--'] + $questionData['options'];
$form->addSelect($name, null, $data);
if (!empty($answers)) {
$form->setDefaults([$name => $answers]);
}
}
}