2021-10-22 17:02:28 +03:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use yii\bootstrap\Modal;
|
|
|
|
|
use yii\grid\GridView;
|
|
|
|
|
use yii\helpers\Html;
|
|
|
|
|
use yii\web\YiiAsset;
|
|
|
|
|
use yii\widgets\DetailView;
|
2021-10-29 17:06:09 +03:00
|
|
|
|
use yii\widgets\Pjax;
|
2021-10-22 17:02:28 +03:00
|
|
|
|
|
|
|
|
|
/* @var $this yii\web\View */
|
|
|
|
|
/* @var $model backend\modules\questionnaire\models\UserQuestionnaire */
|
|
|
|
|
/* @var $responseDataProvider yii\data\ActiveDataProvider */
|
|
|
|
|
|
|
|
|
|
$user = $model->getUserName();
|
|
|
|
|
$questionnaire = $model->getQuestionnaireTitle();
|
|
|
|
|
|
|
|
|
|
$this->title = $user . ": " . $questionnaire;
|
|
|
|
|
$this->params['breadcrumbs'][] = ['label' => 'User Questionnaires', 'url' => ['index']];
|
|
|
|
|
$this->params['breadcrumbs'][] = $this->title;
|
|
|
|
|
YiiAsset::register($this);
|
|
|
|
|
?>
|
2021-10-29 17:06:09 +03:00
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
//$this->registerJs(
|
|
|
|
|
// '$("document").ready(function(){
|
|
|
|
|
// $("#new_note").on("pjax:end", function() {
|
|
|
|
|
// $.pjax.reload({container:"#user_responses"}); //Reload GridView
|
|
|
|
|
// });
|
|
|
|
|
// });'
|
|
|
|
|
//);
|
|
|
|
|
?>
|
2021-10-22 17:02:28 +03:00
|
|
|
|
<div class="user-questionnaire-view">
|
|
|
|
|
|
2021-10-25 13:41:12 +03:00
|
|
|
|
<!-- --><?php //var_dump($model->setPercentCorrectAnswers(4)); die();?>
|
|
|
|
|
|
2021-10-22 17:02:28 +03:00
|
|
|
|
<p>
|
|
|
|
|
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
|
|
|
|
|
<?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
|
|
|
|
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
|
|
|
|
|
'class' => 'btn btn-danger',
|
|
|
|
|
'data' => [
|
|
|
|
|
'confirm' => 'Are you sure you want to delete this item?',
|
|
|
|
|
'method' => 'post',
|
|
|
|
|
],
|
|
|
|
|
]) ?>
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<?= DetailView::widget([
|
|
|
|
|
'model' => $model,
|
|
|
|
|
'attributes' => [
|
|
|
|
|
'id',
|
|
|
|
|
[
|
|
|
|
|
'attribute' => 'questionnaires_id',
|
|
|
|
|
'value' => $questionnaire,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'attribute' => 'user_id',
|
|
|
|
|
'value' => $user,
|
|
|
|
|
],
|
|
|
|
|
'uuid',
|
|
|
|
|
'score',
|
2021-10-25 13:41:12 +03:00
|
|
|
|
[
|
|
|
|
|
'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-10-25 13:41:12 +03:00
|
|
|
|
'value' => function($model) {
|
2021-11-02 17:29:15 +03:00
|
|
|
|
return common\helpers\StatusHelper::statusLabel($model->status);
|
2021-10-22 17:02:28 +03:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
'created_at',
|
|
|
|
|
'updated_at',
|
|
|
|
|
],
|
|
|
|
|
]) ?>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
|
|
|
|
<?= Html::a('Проверить ответы', ['rate-responses', 'id' => $model->id], [
|
|
|
|
|
'class' => 'btn btn-primary',
|
|
|
|
|
'data' => [
|
|
|
|
|
'confirm' => 'Проверка ответов пользователя: ' . $user . ". Категория: " . $questionnaire,
|
|
|
|
|
// 'method' => 'post',
|
|
|
|
|
],
|
|
|
|
|
]) ?>
|
|
|
|
|
<?php
|
|
|
|
|
Modal::begin([
|
|
|
|
|
'header' => '<h3>Подсчёт балов</h3>',
|
|
|
|
|
'toggleButton' => [
|
|
|
|
|
'label' => 'Посчитать баллы',
|
|
|
|
|
'tag' => 'button',
|
|
|
|
|
'class' => 'btn btn-success',
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
if($model->checkAnswerFlagsForNull())
|
|
|
|
|
{
|
|
|
|
|
echo 'Ответы проверены. Посчитать баллы?';
|
|
|
|
|
echo Html::a('Посчитать баллы', ['calculate-score', 'id' => $model->id], [
|
|
|
|
|
'class' => 'btn btn-primary'
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
echo 'Не все ответы проверены.';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php Modal::end(); ?>
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<h2>
|
|
|
|
|
<?= 'Ответы пользователя' ?>
|
|
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
|
2021-10-29 17:06:09 +03:00
|
|
|
|
<?php Pjax::begin(['id' => 'user_responses']); ?>
|
|
|
|
|
<?php
|
|
|
|
|
echo GridView::widget([
|
|
|
|
|
'dataProvider' => $responseDataProvider,
|
|
|
|
|
'columns' => [
|
|
|
|
|
['class' => 'yii\grid\SerialColumn'],
|
|
|
|
|
'response_body',
|
|
|
|
|
[
|
|
|
|
|
'attribute' => 'question_id',
|
|
|
|
|
'value' => function($model){
|
|
|
|
|
return $model->getQuestionBody();
|
2021-10-22 17:02:28 +03:00
|
|
|
|
}
|
2021-10-29 17:06:09 +03:00
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'attribute' => 'Тип вопроса',
|
|
|
|
|
'value' => function($model){
|
|
|
|
|
return $model->getQuestionType();
|
2021-10-22 17:02:28 +03:00
|
|
|
|
}
|
2021-10-29 17:06:09 +03:00
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'attribute' => 'answer_flag',
|
|
|
|
|
'format' => 'raw',
|
|
|
|
|
'value' => function ($model) {
|
2021-11-02 17:29:15 +03:00
|
|
|
|
return \common\helpers\AnswerHelper::answerFlagLable($model->answer_flag);
|
2021-10-22 17:02:28 +03:00
|
|
|
|
},
|
2021-11-02 17:29:15 +03:00
|
|
|
|
|
2021-10-22 17:02:28 +03:00
|
|
|
|
],
|
2021-10-29 17:06:09 +03:00
|
|
|
|
[
|
|
|
|
|
'class' => 'yii\grid\ActionColumn',
|
|
|
|
|
'template' => '{update}', // {delete}
|
|
|
|
|
'buttons' => [
|
|
|
|
|
'update' => function ($url,$model) {
|
|
|
|
|
return Html::a(
|
|
|
|
|
'<span class="glyphicon glyphicon-pencil"></span>',
|
|
|
|
|
['user-response/update', 'id' => $model['id']]);
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
],
|
2021-10-22 17:02:28 +03:00
|
|
|
|
],
|
2021-10-29 17:06:09 +03:00
|
|
|
|
]);
|
|
|
|
|
?>
|
|
|
|
|
<?php Pjax::end(); ?>
|
2021-10-22 17:02:28 +03:00
|
|
|
|
|
|
|
|
|
</div>
|