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

@ -49,7 +49,7 @@ use kartik\depdrop\DepDrop;
); ?>
<?= $form->field($model, 'status')->dropDownList(
$model->statuses,
\common\helpers\StatusHelper::statusList(),
[
'prompt' => 'Выберите'
]

View File

@ -1,7 +1,5 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\UserQuestionnaire */
/* @var $modelCategory backend\modules\questionnaire\models\QuestionnaireCategory */

View File

@ -12,8 +12,6 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-questionnaire-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Назначить анкету пользователю', ['create'], ['class' => 'btn btn-success']) ?>
</p>
@ -23,8 +21,6 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'id',
[
'attribute' => 'questionnaire_id',
'value' => function($model){
@ -37,7 +33,6 @@ $this->params['breadcrumbs'][] = $this->title;
return $model->getUserName();
}
],
// 'UUID',
'score',
[
'attribute' => 'percent_correct_answers',
@ -49,14 +44,9 @@ $this->params['breadcrumbs'][] = $this->title;
[
'attribute' => 'status',
'format' => 'raw',
'filter' => \common\helpers\StatusHelper::statusList(),
'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',

View File

@ -1,7 +1,5 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\UserQuestionnaire */

View File

@ -5,6 +5,7 @@ use yii\grid\GridView;
use yii\helpers\Html;
use yii\web\YiiAsset;
use yii\widgets\DetailView;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\UserQuestionnaire */
@ -18,6 +19,16 @@ $this->params['breadcrumbs'][] = ['label' => 'User Questionnaires', 'url' => ['i
$this->params['breadcrumbs'][] = $this->title;
YiiAsset::register($this);
?>
<?php
//$this->registerJs(
// '$("document").ready(function(){
// $("#new_note").on("pjax:end", function() {
// $.pjax.reload({container:"#user_responses"}); //Reload GridView
// });
// });'
//);
?>
<div class="user-questionnaire-view">
<!-- --><?php //var_dump($model->setPercentCorrectAnswers(4)); die();?>
@ -115,72 +126,68 @@ YiiAsset::register($this);
</h2>
</div>
<?php
echo GridView::widget([
'dataProvider' => $responseDataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'response_body',
[
'attribute' => 'question_id',
'value' => function($model){
return $model->getQuestionBody();
}
],
[
'attribute' => 'Тип вопроса',
'value' => function($model){
return $model->getQuestionType();
}
],
[
'attribute' => 'answer_flag',
'format' => 'raw',
'value' => function ($model) {
$answerFlag = $model->answer_flag;
$class = 'label label-warning';
$content = 'Not verified';
if ($answerFlag > 0)
{
$class = 'label label-success';
$answerFlag < 1 ? $content = $answerFlag *100 . '%' : $content = 'True';
<?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();
}
else if ($answerFlag === 0.0)
{
$class = 'label label-danger';
$content = 'Wrong';
],
[
'attribute' => 'Тип вопроса',
'value' => function($model){
return $model->getQuestionType();
}
],
[
'attribute' => 'answer_flag',
'format' => 'raw',
'value' => function ($model) {
$answerFlag = $model->answer_flag;
return Html::tag(
'span',
$content,
[
'class' => $class,
]
);
},
],
$class = 'label label-warning';
$content = 'Not verified';
// 'created_at',
// 'updated_at',
if ($answerFlag > 0)
{
$class = 'label label-success';
$answerFlag < 1 ? $content = $answerFlag *100 . '%' : $content = 'True';
}
else if ($answerFlag === 0.0)
{
$class = 'label label-danger';
$content = 'Wrong';
}
[
'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']]);
return Html::tag(
'span',
$content,
[
'class' => $class,
]
);
},
],
[
'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']]);
},
],
],
],
],
]);
?>
]);
?>
<?php Pjax::end(); ?>
</div>