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

61 lines
1.9 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-08 12:41:39 +03:00
'filter' => ArrayHelper::map(User::find()->all(), 'id', 'username'),
'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',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>