Files
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

89 lines
2.4 KiB
PHP

<?php
/* For licensing terms, see /license.txt */
/**
* Class ch_yesno.
*/
class ch_yesno extends survey_question
{
/**
* @param array $surveyData
* @param array $formData
*/
public function createForm($surveyData, $formData)
{
parent::createForm($surveyData, $formData);
$options = [
'horizontal' => get_lang('Horizontal'),
'vertical' => get_lang('Vertical'),
];
$this->getForm()->addRadio('horizontalvertical', get_lang('DisplayAnswersHorVert'), $options);
$formData['horizontalvertical'] = isset($formData['horizontalvertical']) ? $formData['horizontalvertical'] : 'horizontal';
$this->getForm()->setDefaults($formData);
// The options
$config = [
'ToolbarSet' => 'Survey',
'Width' => '100%',
'Height' => '120',
];
$this->getForm()->addHtmlEditor(
'answers[0]',
get_lang('AnswerOptions'),
true,
false,
$config
);
$this->getForm()->addHtmlEditor(
'answers[1]',
null,
true,
false,
$config
);
if (isset($formData['answersid']) && !empty($formData['answersid'])) {
foreach ($formData['answersid'] as $value) {
$this->getForm()->addHidden('answersid[]', $value);
}
}
}
/**
* @param array $questionData
* @param array $answers
*/
public function render(FormValidator $form, $questionData = [], $answers = null)
{
if (is_array($questionData['options'])) {
$class = 'radio-inline';
$labelClass = 'radio-inline';
if ('vertical' === $questionData['display']) {
$class = 'radio-vertical';
}
$name = 'question'.$questionData['question_id'];
$radioAttributes = ['radio-class' => $class, 'label-class' => $labelClass];
if (!empty($questionData['is_required'])) {
$radioAttributes['required'] = 'required';
}
$form->addRadio(
$name,
null,
$questionData['options'],
$radioAttributes
);
if (!empty($answers)) {
$form->setDefaults([$name => is_array($answers) ? current($answers) : $answers]);
}
}
}
}