guild/backend/modules/questionnaire/views/user-questionnaire/index.php

62 lines
2.0 KiB
PHP
Raw Normal View History

2021-10-22 17:02:28 +03:00
<?php
2021-11-08 12:41:39 +03:00
use common\helpers\StatusHelper;
use common\models\User;
use yii\helpers\ArrayHelper;
2021-10-22 17:02:28 +03:00
use yii\helpers\Html;
use yii\grid\GridView;
2021-11-08 12:41:39 +03:00
use backend\modules\questionnaire\models\Questionnaire;
2021-10-22 17:02:28 +03:00
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\questionnaire\models\UserQuestionnaireSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Анкеты пользователей';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-questionnaire-index">
<p>
<?= Html::a('Назначить анкету пользователю', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'questionnaire_id',
2021-11-08 12:41:39 +03:00
'filter' => Questionnaire::find()->select(['title', 'id'])->indexBy('id')->column(),
'value' => 'questionnaire.title'
2021-10-22 17:02:28 +03:00
],
[
'attribute' => 'user_id',
2021-11-25 12:33:08 +03:00
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
2021-11-08 12:41:39 +03:00
'value' => 'user.username'
2021-10-22 17:02:28 +03:00
],
'score',
[
'attribute' => 'percent_correct_answers',
'value' => function($model) {
$percent = $model->percent_correct_answers * 100;
return $percent . '%';
}
],
2021-10-22 17:02:28 +03:00
[
'attribute' => 'status',
'format' => 'raw',
2021-11-08 12:41:39 +03:00
'filter' => StatusHelper::statusList(),
2021-10-22 17:02:28 +03:00
'value' => function ($model) {
2021-11-08 12:41:39 +03:00
return StatusHelper::statusLabel($model->status);
2021-10-22 17:02:28 +03:00
},
],
'created_at',
'updated_at',
'testing_date',
2021-10-22 17:02:28 +03:00
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>