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

@ -1,24 +0,0 @@
<?php
namespace backend\modules\api;
/**
* api module definition class
*/
class Api extends \yii\base\Module
{
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'backend\modules\api\controllers';
/**
* {@inheritdoc}
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
}

View File

@ -1,20 +0,0 @@
<?php
namespace backend\modules\api\controllers;
use yii\web\Controller;
/**
* Default controller for the `api` module
*/
class DefaultController extends Controller
{
/**
* Renders the index view for the module
* @return string
*/
public function actionIndex()
{
return $this->render('index');
}
}

View File

@ -1,49 +0,0 @@
<?php
namespace backend\modules\api\controllers;
use yii\filters\auth\CompositeAuth;
use yii\filters\auth\HttpBearerAuth;
use yii\rest\Controller;
class UserQuestionnaireController extends Controller
{
public $modelClass = 'backend/modules/api/models/UserQuestionnaire';
public function behaviors()
{
return [
[
'class' => \yii\filters\ContentNegotiator::className(),
'formats' => [
'application/json' => \yii\web\Response::FORMAT_JSON,
],
],
// 'authenticator' => [
// 'class' => CompositeAuth::class,
// 'authMethods' => [
// HttpBearerAuth::class,
// ],
// ]
];
}
public function actionIndex()
{
return ['some' => 'rrr'];
}
// /**
// * @inheritdoc
// */
// protected function verbs()
// {
// return [
// 'index' => ['GET', 'HEAD'],
// ];
// }
}

View File

@ -1,96 +0,0 @@
<?php
namespace backend\modules\api\models;
use Yii;
/**
* This is the model class for table "user".
*
* @property int $id
* @property string $username
* @property string $auth_key
* @property string $password_hash
* @property string $password_reset_token
* @property string $email
* @property int $status
* @property int $created_at
* @property int $updated_at
* @property string $access_token
* @property string $access_token_expired_at
*
* @property UserCard[] $userCards
* @property UserQuestionnaire[] $userQuestionnaires
* @property UserResponse[] $userResponses
*/
class User extends \common\models\User
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'user';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['username', 'auth_key', 'password_hash', 'email', 'created_at', 'updated_at'], 'required'],
[['status', 'created_at', 'updated_at'], 'integer'],
[['access_token_expired_at'], 'safe'],
[['username', 'password_hash', 'password_reset_token', 'email', 'access_token'], 'string', 'max' => 255],
[['auth_key'], 'string', 'max' => 32],
[['username'], 'unique'],
[['email'], 'unique'],
[['password_reset_token'], 'unique'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'username' => 'Username',
'auth_key' => 'Auth Key',
'password_hash' => 'Password Hash',
'password_reset_token' => 'Password Reset Token',
'email' => 'Email',
'status' => 'Status',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'access_token' => 'Access Token',
'access_token_expired_at' => 'Access Token Expired At',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUserCards()
{
return $this->hasMany(UserCard::className(), ['id_user' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUserQuestionnaires()
{
return $this->hasMany(UserQuestionnaire::className(), ['user_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUserResponses()
{
return $this->hasMany(UserResponse::className(), ['user_id' => 'id']);
}
}

View File

@ -1,9 +0,0 @@
<?php
namespace backend\modules\api\models;
class UserQuestionnaire extends \common\models\UserQuestionnaire
{
}

View File

@ -1,12 +0,0 @@
<div class="api-default-index">
<h1><?= $this->context->action->uniqueId ?></h1>
<p>
This is the view content for action "<?= $this->context->action->id ?>".
The action belongs to the controller "<?= get_class($this->context) ?>"
in the "<?= $this->context->module->id ?>" module.
</p>
<p>
You may customize this page by editing the following file:<br>
<code><?= __FILE__ ?></code>
</p>
</div>

View File

@ -1,9 +0,0 @@
<?php
/* @var $this yii\web\View */
?>
<h1>user-questionnaire/index</h1>
<p>
You may change the content of this page by modifying
the file <code><?= __FILE__; ?></code>.
</p>

View File

@ -2,6 +2,7 @@
namespace backend\modules\questionnaire\controllers;
use backend\modules\questionnaire\models\QuestionSearch;
use Yii;
use backend\modules\questionnaire\models\Questionnaire;
use backend\modules\questionnaire\models\QuestionnaireSearch;
@ -9,6 +10,7 @@ use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\Response;
/**
* QuestionnaireController implements the CRUD actions for Questionnaire model.
@ -54,6 +56,7 @@ class QuestionnaireController extends Controller
public function actionView($id)
{
$model = $this->findModel($id);
$questionSearchModel = new QuestionSearch();
$questionDataProvider = new ActiveDataProvider([
'query' => $model->getQuestions(),
'pagination' => [
@ -64,6 +67,7 @@ class QuestionnaireController extends Controller
return $this->render('view', [
'model' => $model,
'questionDataProvider' => $questionDataProvider,
'questionSearchModel' => $questionSearchModel,
]);
}
@ -89,10 +93,10 @@ class QuestionnaireController extends Controller
* Updates an existing Questionnaire model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @return string|Response
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
public function actionUpdate(int $id)
{
$model = $this->findModel($id);
@ -109,10 +113,10 @@ class QuestionnaireController extends Controller
* Deletes an existing Questionnaire model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @return Response
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
public function actionDelete(int $id)
{
$this->findModel($id)->delete();

View File

@ -23,23 +23,19 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'answer_body')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'answer_flag')->dropDownList(
$model->flags,
\common\helpers\AnswerHelper::answerFlagsList(),
[
'prompt' => 'Выберите'
]
) ?>
<?= $form->field($model, 'status')->dropDownList(
$model->statuses,
\common\helpers\StatusHelper::statusList(),
[
'prompt' => 'Выберите'
]
) ?>
<!-- <?//= $form->field($model, 'created_at')->textInput() ?> -->
<!-- <?//= $form->field($model, 'updated_at')->textInput() ?> -->
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>

View File

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

View File

@ -23,8 +23,8 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'id',
[
'filter' => \yii\helpers\ArrayHelper::map(\common\models\Question::find()->where(['!=', 'question_type_id', '1'])->all(), 'id', 'question_body'),
'attribute' => 'question_id',
'value' => function($model){
return $model->getQuestionBody();
@ -34,32 +34,19 @@ $this->params['breadcrumbs'][] = $this->title;
[
'attribute' => 'answer_flag',
'format' => 'raw',
'filter' => \common\helpers\AnswerHelper::answerFlagsList(),
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->answer_flag ? 'Correct' : 'Wrong',
[
'class' => 'label label-' . ($model->answer_flag ? 'success' : 'danger'),
]
);
return \common\helpers\AnswerHelper::statusLabel($model->answer_flag);
},
],
[
'attribute' => 'status',
'format' => 'raw',
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->status ? 'Active' : 'Not Active',
[
'class' => 'label label-' . ($model->status ? 'success' : 'danger'),
]
);
},
'filter' => \common\helpers\StatusHelper::statusList(),
'value' => function($model){
return \common\helpers\StatusHelper::statusLabel($model->status);
}
],
//'created_at',
//'updated_at',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>

View File

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

View File

@ -46,28 +46,18 @@ function cut_title($str)
[
'attribute' => 'answer_flag',
'format' => 'raw',
'filter' => \common\helpers\AnswerHelper::answerFlagsList(),
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->answer_flag ? 'Correct' : 'Wrong',
[
'class' => 'label label-' . ($model->answer_flag ? 'success' : 'danger'),
]
);
return \common\helpers\AnswerHelper::statusLabel($model->status);
},
],
[
'attribute' => 'status',
'format' => 'raw',
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->status ? 'Active' : 'Not Active',
[
'class' => 'label label-' . ($model->status ? 'success' : 'danger'),
]
);
},
'filter' => \common\helpers\StatusHelper::statusList(),
'value' => function($model){
return \common\helpers\StatusHelper::statusLabel($model->status);
}
],
'created_at',
'updated_at',

View File

@ -33,10 +33,6 @@ use yii\widgets\ActiveForm;
]
); ?>
<!-- <?//= $form->field($model, 'question_type_id')->textInput() ?> -->
<!-- <?//= $form->field($model, 'questionnaire_id')->textInput() ?> -->
<?= $form->field($model, 'question_body')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'question_priority')->textInput() ?>
@ -44,16 +40,12 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'next_question')->textInput() ?>
<?= $form->field($model, 'status')->dropDownList(
$model->statuses,
\common\helpers\StatusHelper::statusList(),
[
'prompt' => 'Выберите'
]
) ?>
<!-- <?//= $form->field($model, 'created_at')->textInput() ?> -->
<!-- <?//= $form->field($model, 'updated_at')->textInput() ?> -->
<?= $form->field($model, 'time_limit')->dropDownList(
[
'' => 'Не ограничено',

View File

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

View File

@ -12,12 +12,6 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="question-index">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a('Создать вопрос', ['create'], ['class' => 'btn btn-success']) ?>
</p>
@ -27,8 +21,6 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'id',
'question_body',
[
'attribute' => 'question_type_id',
@ -47,26 +39,18 @@ $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',
//'updated_at',
[
'attribute' => 'time_limit',
'value' => function($model){
return $model->limitTime;
return \common\helpers\TimeHelper::limitTime($model->time_limit);
}
],
'score',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>

View File

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

View File

@ -19,7 +19,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'confirm' => 'Вы уверены, что хотите удалить этот элемент?',
'method' => 'post',
],
]) ?>
@ -47,14 +47,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',
@ -62,7 +57,7 @@ $this->params['breadcrumbs'][] = $this->title;
[
'attribute' => 'time_limit',
'value' => function($model){
return $model->limitTime;
return \common\helpers\TimeHelper::limitTime($model->time_limit);
}
],
'score'

View File

@ -14,19 +14,13 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<!-- <?//= $form->field($model, 'status')->textInput() ?> -->
<?= $form->field($model, 'status')->dropDownList(
$model->statuses,
\common\helpers\StatusHelper::statusList(),
[
'prompt' => 'Выберите'
]
) ?>
<!-- <?//= $form->field($model, 'created_at')->textInput() ?> -->
<!-- <?//= $form->field($model, 'updated_at')->textInput() ?> -->
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>

View File

@ -1,7 +1,5 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\QuestionnaireCategory */
@ -9,11 +7,8 @@ $this->title = 'Создание категории анкеты';
$this->params['breadcrumbs'][] = ['label' => 'Questionnaire Categories', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="questionnaire-categories-create">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<div class="questionnaire-categories-create">
<?= $this->render('_form', [
'model' => $model,

View File

@ -23,25 +23,15 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'id',
'title',
[
'attribute' => 'status',
'format' => 'raw',
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->status ? 'Active' : 'Not Active',
[
'class' => 'label label-' . ($model->status ? 'success' : 'danger'),
]
);
'filter' => \common\helpers\StatusHelper::statusList(),
'value' => function($model) {
return \common\helpers\StatusHelper::statusLabel($model->status);
},
],
// 'created_at',
// 'updated_at',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>

View File

@ -1,7 +1,5 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\QuestionnaireCategory */
@ -12,10 +10,6 @@ $this->params['breadcrumbs'][] = 'Update';
?>
<div class="questionnaire-category-update">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<?= $this->render('_form', [
'model' => $model,
]) ?>

View File

@ -1,6 +1,7 @@
<?php
use yii\helpers\Html;
use yii\web\YiiAsset;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
@ -9,21 +10,17 @@ use yii\widgets\DetailView;
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Questionnaire Categories', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
YiiAsset::register($this);
?>
<div class="questionnaire-categories-view">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<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?',
'confirm' => 'Вы уверены, что хотите удалить этот элемент?',
'method' => 'post',
],
]) ?>
@ -37,14 +34,9 @@ $this->params['breadcrumbs'][] = $this->title;
[
'attribute' => 'status',
'format' => 'raw',
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->status ? 'Active' : 'Not Active',
[
'class' => 'label label-' . ($model->status ? 'success' : 'danger'),
]
);
'filter' => \common\helpers\StatusHelper::statusList(),
'value' => function($model) {
return \common\helpers\StatusHelper::statusLabel($model->status);
},
],
'created_at',

View File

@ -26,7 +26,7 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->dropDownList(
$model->statuses,
\common\helpers\StatusHelper::statusList(),
[
'prompt' => 'Выберите'
]

View File

@ -25,10 +25,6 @@ use yii\widgets\ActiveForm;
<?= $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<?php // echo $form->field($model, 'time_limit') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>

View File

@ -1,7 +1,5 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\Questionnaire */
@ -11,10 +9,6 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="questionnaire-create">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<?= $this->render('_form', [
'model' => $model,
]) ?>

View File

@ -12,9 +12,6 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="questionnaire-index">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
@ -26,22 +23,14 @@ $this->params['breadcrumbs'][] = $this->title;
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
// 'id',
'title',
[
'attribute' => 'status',
'format' => 'raw',
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->status ? 'Active' : 'Not Active',
[
'class' => 'label label-' . ($model->status ? 'success' : 'danger'),
]
);
},
'filter' => \common\helpers\StatusHelper::statusList(),
'value' => function($model){
return \common\helpers\StatusHelper::statusLabel($model->status);
}
],
[
'attribute' => 'category_id',
@ -49,15 +38,12 @@ $this->params['breadcrumbs'][] = $this->title;
return $model->getCategoryTitle();
}
],
// 'created_at',
// 'updated_at',
[
'attribute' => 'time_limit',
'value' => function($model){
return $model->limitTime;
return \common\helpers\TimeHelper::limitTime($model->time_limit);
}
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>

View File

@ -1,7 +1,5 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\Questionnaire */
@ -12,10 +10,6 @@ $this->params['breadcrumbs'][] = 'Update';
?>
<div class="questionnaire-update">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<?= $this->render('_form', [
'model' => $model,
]) ?>

View File

@ -1,6 +1,5 @@
<?php
use yii\data\ActiveDataProvider;
use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\DetailView;
@ -8,6 +7,7 @@ use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\questionnaire\models\Questionnaire */
/* @var $questionDataProvider yii\data\ActiveDataProvider */
/* @var $questionSearchModel backend\modules\questionnaire\models\QuestionSearch */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Questionnaires', 'url' => ['index']];
@ -16,10 +16,6 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<div class="questionnaire-view">
<!-- <h1>-->
<!-- <?//= Html::encode($this->title) ?> -->
<!-- </h1>-->
<p>
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
@ -47,13 +43,7 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'status',
'format' => 'raw',
'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',
@ -61,7 +51,7 @@ $this->params['breadcrumbs'][] = $this->title;
[
'attribute' => 'time_limit',
'value' => function($model){
return $model->limitTime;
return \common\helpers\TimeHelper::limitTime($model->time_limit);
}
]
],
@ -69,7 +59,7 @@ $this->params['breadcrumbs'][] = $this->title;
<div>
<h2>
<?= 'Вопросы анкеты: ' . Html::encode($this->title) ?>
<?= 'Вопросы анкеты: '?>
</h2>
</div>
@ -77,36 +67,27 @@ $this->params['breadcrumbs'][] = $this->title;
echo GridView::widget([
'dataProvider' => $questionDataProvider,
'filterModel' => $questionSearchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'question_type_id',
'questionnaire_id',
'question_body',
[
'attribute' => 'status',
'format' => 'raw',
'value' => function ($model) {
return \yii\helpers\Html::tag(
'span',
$model->status ? 'Active' : 'Not Active',
[
'class' => 'label label-' . ($model->status ? 'success' : 'danger'),
]
);
'filter' => \common\helpers\StatusHelper::statusList(),
'value' => function($model) {
return \common\helpers\StatusHelper::statusLabel($model->status);
},
],
// 'created_at',
// 'updated_at',
[
'attribute' => 'time_limit',
'format' => 'raw',
'value' => function($model){
return $model->limitTime;
return \common\helpers\TimeHelper::limitTime($model->time_limit);
}
],
'score',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update}', // {delete}

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>