add answer, time, status helpers

This commit is contained in:
iIronside
2021-10-29 17:06:09 +03:00
parent 34c2998844
commit 7b8847e1e1
42 changed files with 2505 additions and 570 deletions

View File

@ -26,7 +26,7 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->dropDownList(
$model->statuses,
\common\helpers\StatusHelper::statusList(),
[
'prompt' => 'Выберите'
]

View File

@ -25,10 +25,6 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<?php // echo $form->field($model, 'time_limit') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>

View File

@ -1,7 +1,5 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\Questionnaire */
@ -11,10 +9,6 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="questionnaire-create">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<?= $this->render('_form', [
'model' => $model,
]) ?>

View File

@ -12,9 +12,6 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="questionnaire-index">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
@ -26,22 +23,14 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'id',
'title',
[
'attribute' => 'status',
'format' => 'raw',
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->status ? 'Active' : 'Not Active',
[
'class' => 'label label-' . ($model->status ? 'success' : 'danger'),
]
);
},
'filter' => \common\helpers\StatusHelper::statusList(),
'value' => function($model){
return \common\helpers\StatusHelper::statusLabel($model->status);
}
],
[
'attribute' => 'category_id',
@ -49,15 +38,12 @@ $this->params['breadcrumbs'][] = $this->title;
return $model->getCategoryTitle();
}
],
// 'created_at',
// 'updated_at',
[
'attribute' => 'time_limit',
'value' => function($model){
return $model->limitTime;
return \common\helpers\TimeHelper::limitTime($model->time_limit);
}
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>

View File

@ -1,7 +1,5 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\Questionnaire */
@ -12,10 +10,6 @@ $this->params['breadcrumbs'][] = 'Update';
?>
<div class="questionnaire-update">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<?= $this->render('_form', [
'model' => $model,
]) ?>

View File

@ -1,6 +1,5 @@
<?php
use yii\data\ActiveDataProvider;
use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\DetailView;
@ -8,6 +7,7 @@ use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\Questionnaire */
/* @var $questionDataProvider yii\data\ActiveDataProvider */
/* @var $questionSearchModel backend\modules\questionnaire\models\QuestionSearch */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Questionnaires', 'url' => ['index']];
@ -16,10 +16,6 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="questionnaire-view">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<p>
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
@ -47,13 +43,7 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'status',
'format' => 'raw',
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->status ? 'Active' : 'Not Active',
[
'class' => 'label label-' . ($model->status ? 'success' : 'danger'),
]
);
return \common\helpers\StatusHelper::statusLabel($model->status);
},
],
'created_at',
@ -61,7 +51,7 @@ $this->params['breadcrumbs'][] = $this->title;
[
'attribute' => 'time_limit',
'value' => function($model){
return $model->limitTime;
return \common\helpers\TimeHelper::limitTime($model->time_limit);
}
]
],
@ -69,7 +59,7 @@ $this->params['breadcrumbs'][] = $this->title;
<div>
<h2>
<?= 'Вопросы анкеты: ' . Html::encode($this->title) ?>
<?= 'Вопросы анкеты: '?>
</h2>
</div>
@ -77,36 +67,27 @@ $this->params['breadcrumbs'][] = $this->title;
echo GridView::widget([
'dataProvider' => $questionDataProvider,
'filterModel' => $questionSearchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'question_type_id',
'questionnaire_id',
'question_body',
[
'attribute' => 'status',
'format' => 'raw',
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->status ? 'Active' : 'Not Active',
[
'class' => 'label label-' . ($model->status ? 'success' : 'danger'),
]
);
'filter' => \common\helpers\StatusHelper::statusList(),
'value' => function($model) {
return \common\helpers\StatusHelper::statusLabel($model->status);
},
],
// 'created_at',
// 'updated_at',
[
'attribute' => 'time_limit',
'format' => 'raw',
'value' => function($model){
return $model->limitTime;
return \common\helpers\TimeHelper::limitTime($model->time_limit);
}
],
'score',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update}', // {delete}