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

61 lines
2.0 KiB
PHP
Raw Permalink Normal View History

2021-10-22 17:02:28 +03:00
<?php
use common\helpers\UserQuestionnaireStatusHelper;
2021-11-08 12:41:39 +03:00
use common\models\User;
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',
'filter' => UserQuestionnaireStatusHelper::statusList(),
2021-10-22 17:02:28 +03:00
'value' => function ($model) {
return UserQuestionnaireStatusHelper::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>