add answer, time, status helpers
This commit is contained in:
@ -49,7 +49,7 @@ use kartik\depdrop\DepDrop;
|
||||
); ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList(
|
||||
$model->statuses,
|
||||
\common\helpers\StatusHelper::statusList(),
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
|
@ -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 */
|
||||
|
@ -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',
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserQuestionnaire */
|
||||
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user