<?php
/* @var $this QuestionnaireController */
/* @var $model Questionnaire */

$baseUrl = Yii::app()->getBaseUrl();
/* @var $cs CClientScript */
$cs = Yii::app()->clientScript;
$cs->registerCoreScript('jquery');
$cs->registerCssFile($baseUrl . '/css/questionnaire.css');

$cs->registerCssFile($baseUrl . '/js/ion.rangeSlider-1.9.3/css/ion.rangeSlider.css');
$cs->registerCssFile($baseUrl . '/js/ion.rangeSlider-1.9.3/css/ion.rangeSlider.skinFlat.css');
$cs->registerscriptfile($baseUrl . '/js/ion.rangeSlider-1.9.3/js/ion-rangeSlider/ion.rangeSlider.min.js');
?>
<h1><?php echo $model->title; ?></h1>
<p>
    <?php echo $model->intro; ?>
</p>

<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id' => 'questionnaire-form',
    'enableAjaxValidation' => false,
        ));
?>

<!--<p class="note">Fields with <span class="required">*</span> are required.</p>-->

<?php // echo $form->errorSummary($model);     ?>

<?php
foreach ($model->questionnaireQuestions as $question) {
    $question->options = CJSON::decode($question->options);
    $types = QuestionnaireQuestion::getTypes();

    if (isset($types[$question->type])) {
        switch ($question->type) {
            case QuestionnaireQuestion::TYPE_TEXT:
                $this->renderPartial('types/_text', array('question' => $question), false, true);
                break;
            case QuestionnaireQuestion::TYPE_RANGE:
                $this->renderPartial('types/_range', array('question' => $question), false, true);
                break;
            case QuestionnaireQuestion::TYPE_MULTIPLE_CHOICES:
                $this->renderPartial('types/_multiple_choices', array('question' => $question), false, true);
                break;
            case QuestionnaireQuestion::TYPE_CHECKBOXES:
                $this->renderPartial('types/_checkboxes', array('question' => $question), false, true);
                break;
        }
    }
}
?>


<?php
echo TbHtml::formActions(array(TbHtml::submitButton($model->isNewRecord ? Yii::t('admin', 'Create') : Yii::t('admin', 'Save'), array('color' => TbHtml::BUTTON_COLOR_PRIMARY)),));
?>

<?php $this->endWidget(); ?>
<br/><br/><br/>
<div class="clear"></div>