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.
59 lines
1.8 KiB
59 lines
1.8 KiB
<?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 = array(
|
|
'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 = array('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);
|
|
}
|
|
|
|
/**
|
|
* @param FormValidator $form
|
|
* @param array $questionData
|
|
* @param array $answers
|
|
*/
|
|
public function render(FormValidator $form, $questionData = array(), $answers = null)
|
|
{
|
|
if (is_array($questionData['options'])) {
|
|
if ($questionData['display'] == 'vertical') {
|
|
$class = '';
|
|
} else {
|
|
$class = 'inline';
|
|
}
|
|
|
|
$name = 'question' . $questionData['question_id'];
|
|
$form->addRadio(
|
|
$name ,
|
|
null,
|
|
$questionData['options'],
|
|
array('label-class' => $class)
|
|
);
|
|
|
|
if (!empty($answers)) {
|
|
$form->setDefaults([$name => $answers]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|