add answer, time, status helpers
This commit is contained in:
parent
34c2998844
commit
7b8847e1e1
@ -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
|
||||
}
|
||||
}
|
@ -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');
|
||||
}
|
||||
}
|
@ -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'],
|
||||
// ];
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
@ -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']);
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\api\models;
|
||||
|
||||
|
||||
class UserQuestionnaire extends \common\models\UserQuestionnaire
|
||||
{
|
||||
|
||||
}
|
@ -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>
|
@ -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>
|
@ -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();
|
||||
|
||||
|
@ -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>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Answer */
|
||||
|
||||
|
@ -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'],
|
||||
],
|
||||
]); ?>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Answer */
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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(
|
||||
[
|
||||
'' => 'Не ограничено',
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Question */
|
||||
|
||||
|
@ -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'],
|
||||
],
|
||||
]); ?>
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Question */
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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>
|
||||
|
@ -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,
|
||||
|
@ -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'],
|
||||
],
|
||||
]); ?>
|
||||
|
@ -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,
|
||||
]) ?>
|
||||
|
@ -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',
|
||||
|
@ -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' => 'Выберите'
|
||||
]
|
||||
|
@ -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']) ?>
|
||||
|
@ -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,
|
||||
]) ?>
|
||||
|
@ -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'],
|
||||
],
|
||||
]); ?>
|
||||
|
@ -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,
|
||||
]) ?>
|
||||
|
@ -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}
|
||||
|
@ -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>
|
||||
|
42
common/helpers/AnswerHelper.php
Normal file
42
common/helpers/AnswerHelper.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace common\helpers;
|
||||
|
||||
use yii\helpers\ArrayHelper;
|
||||
use Exception;
|
||||
use yii\helpers\Html;
|
||||
|
||||
class AnswerHelper
|
||||
{
|
||||
const FLAG_TRUE = 1;
|
||||
const FLAG_FALSE = 0;
|
||||
|
||||
public static function answerFlagsList(): array
|
||||
{
|
||||
return [
|
||||
self::FLAG_TRUE => 'Верен',
|
||||
self::FLAG_FALSE => 'Ошибочный',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function statusLabel($status): string
|
||||
{
|
||||
switch ($status) {
|
||||
case self::FLAG_FALSE:
|
||||
$class = 'label label-danger';
|
||||
break;
|
||||
case self::FLAG_TRUE:
|
||||
$class = 'label label-success';
|
||||
break;
|
||||
default:
|
||||
$class = 'label label-default';
|
||||
}
|
||||
|
||||
return Html::tag('span', ArrayHelper::getValue(self::answerFlagsList(), $status), [
|
||||
'class' => $class,
|
||||
]);
|
||||
}
|
||||
}
|
50
common/helpers/StatusHelper.php
Normal file
50
common/helpers/StatusHelper.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace common\helpers;
|
||||
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use Exception;
|
||||
|
||||
class StatusHelper
|
||||
{
|
||||
const STATUS_PASSIVE = 0;
|
||||
const STATUS_ACTIVE = 1;
|
||||
|
||||
public static function statusList() :array
|
||||
{
|
||||
return [
|
||||
self::STATUS_PASSIVE => 'Не используется',
|
||||
self::STATUS_ACTIVE => 'Активен'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function statusName($status): string
|
||||
{
|
||||
return ArrayHelper::getValue(self::statusList(), $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function statusLabel($status): string
|
||||
{
|
||||
switch ($status) {
|
||||
case self::STATUS_PASSIVE:
|
||||
$class = 'label label-danger';
|
||||
break;
|
||||
case self::STATUS_ACTIVE:
|
||||
$class = 'label label-success';
|
||||
break;
|
||||
default:
|
||||
$class = 'label label-default';
|
||||
}
|
||||
|
||||
return Html::tag('span', ArrayHelper::getValue(self::statusList(), $status), [
|
||||
'class' => $class,
|
||||
]);
|
||||
}
|
||||
}
|
23
common/helpers/TimeHelper.php
Normal file
23
common/helpers/TimeHelper.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace common\helpers;
|
||||
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
|
||||
class TimeHelper
|
||||
{
|
||||
public static function limitTime($time_limit)
|
||||
{
|
||||
if ($time_limit === null)
|
||||
{
|
||||
return 'Не ограниченоTEST';
|
||||
}
|
||||
|
||||
return date("H:i:s", mktime(null, null, $time_limit)) . ' (HH:mm:ss)';
|
||||
|
||||
// $date
|
||||
// return Html::tag('span', $date, ['class' => 'label label-primary']);
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveQuery;
|
||||
use yii\db\Expression;
|
||||
|
||||
/**
|
||||
@ -78,9 +78,9 @@ class Answer extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getQuestion()
|
||||
public function getQuestion(): ActiveQuery
|
||||
{
|
||||
return $this->hasOne(Question::className(), ['id' => 'question_id']);
|
||||
}
|
||||
@ -91,32 +91,6 @@ class Answer extends \yii\db\ActiveRecord
|
||||
return $this->getQuestion()->one()->question_body;
|
||||
}
|
||||
|
||||
public function getStatuses()
|
||||
{
|
||||
return [
|
||||
self::STATUS_ACTIVE => 'Активен',
|
||||
self::STATUS_PASSIVE => 'Не используется'
|
||||
];
|
||||
}
|
||||
|
||||
public function getStatusText()
|
||||
{
|
||||
return $this->statuses[$this->status];
|
||||
}
|
||||
|
||||
public function getFlags()
|
||||
{
|
||||
return [
|
||||
self::FLAG_TRUE => 'Правильный',
|
||||
self::FLAG_FALSE => 'Ошибочный',
|
||||
];
|
||||
}
|
||||
|
||||
public function getFlagText()
|
||||
{
|
||||
return $this->flags[$this->status];
|
||||
}
|
||||
|
||||
static function getCorrectAnswersNum($question_id)
|
||||
{
|
||||
return Answer::find()
|
||||
@ -126,7 +100,7 @@ class Answer extends \yii\db\ActiveRecord
|
||||
->count();
|
||||
}
|
||||
|
||||
public static function getActiveAnswers($question_id)
|
||||
public static function getActiveAnswers($question_id): array
|
||||
{
|
||||
return self::find()->where(['question_id' => $question_id])
|
||||
->andWhere(['status' => '1'])
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use phpDocumentor\Reflection\Types\This;
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
@ -112,38 +110,15 @@ class Questionnaire extends \yii\db\ActiveRecord
|
||||
return $this->hasMany(UserQuestionnaire::className(), ['questionnaire_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getStatuses()
|
||||
{
|
||||
return [
|
||||
self::STATUS_ACTIVE => 'Активна',
|
||||
self::STATUS_PASSIVE => 'Не используется'
|
||||
];
|
||||
}
|
||||
|
||||
public function getStatusText()
|
||||
{
|
||||
return $this->statuses[$this->status];
|
||||
}
|
||||
|
||||
public function getCategoryTitle()
|
||||
{
|
||||
return $this->getCategory()->one()->title;
|
||||
}
|
||||
|
||||
public function getLimitTime()
|
||||
{
|
||||
if ($this->time_limit === null)
|
||||
{
|
||||
return 'Не ограничено';
|
||||
}
|
||||
|
||||
return date("H:i:s", mktime(null, null, $this->time_limit));
|
||||
}
|
||||
|
||||
public static function getQuestionnaireByCategory($category_id)
|
||||
{
|
||||
$categories = self::find()->where(['category_id' => $category_id, 'status' => '1'])->all();
|
||||
$catArr = \yii\helpers\ArrayHelper::map($categories, 'id', 'title');
|
||||
$catArr = ArrayHelper::map($categories, 'id', 'title');
|
||||
|
||||
$formattedCatArr = array();
|
||||
foreach ($catArr as $key => $value){
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
@ -79,22 +78,6 @@ class QuestionnaireCategory extends \yii\db\ActiveRecord
|
||||
return $this->hasMany(Questionnaire::className(), ['category_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getStatuses()
|
||||
{
|
||||
return [
|
||||
self::STATUS_PASSIVE => 'Не используется',
|
||||
self::STATUS_ACTIVE => 'Активна'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string status text label
|
||||
*/
|
||||
public function getStatusText()
|
||||
{
|
||||
return $this->statuses[$this->status];
|
||||
}
|
||||
|
||||
public function getIdTitlesArr()
|
||||
{
|
||||
$categories = self::find()->select(['id', 'title'])->where(['status' => '1'])->all();
|
||||
|
2253
frontend-access.log
2253
frontend-access.log
File diff suppressed because it is too large
Load Diff
@ -651,3 +651,8 @@ Stack trace:
|
||||
2021/10/28 10:38:26 [error] 728#728: *28 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/create HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||
2021/10/28 10:38:37 [error] 728#728: *28 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/create HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||
2021/10/28 10:41:06 [error] 728#728: *33 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/create HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||
2021/10/28 10:52:32 [error] 728#728: *40 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/user/login/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||
2021/10/28 12:07:33 [error] 728#728: *363 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/question/get-questions?questionnaire_id=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||
2021/10/28 12:07:50 [error] 728#728: *363 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/user-questionnaire/questionnaires-list?user_id=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||
2021/10/28 12:07:59 [error] 728#728: *363 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 101PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 102" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /api/answer/get-answers?question_id=7 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||
2021/10/29 16:02:38 [error] 712#712: *805 FastCGI sent in stderr: "PHP message: PHP Fatal error: Declaration of backend\modules\questionnaire\models\AnswerSearch::rules() must be compatible with common\models\Answer::rules(): array in /var/www/guild.loc/backend/modules/questionnaire/models/AnswerSearch.php on line 17" while reading response header from upstream, client: 127.0.0.1, server: backend.guild.loc, request: "GET /questionnaire/answer/index?AnswerSearch%5Bquestion_id%5D=&AnswerSearch%5Banswer_body%5D=&AnswerSearch%5Banswer_flag%5D=&AnswerSearch%5Bstatus%5D=0 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "backend.guild.loc", referrer: "http://backend.guild.loc/questionnaire/answer/index?AnswerSearch%5Bquestion_id%5D=&AnswerSearch%5Banswer_body%5D=&AnswerSearch%5Banswer_flag%5D=&AnswerSearch%5Bstatus%5D="
|
||||
|
Loading…
Reference in New Issue
Block a user