add filters, refactoring
This commit is contained in:
@ -5,7 +5,7 @@ namespace backend\modules\notes\models;
|
||||
use Yii;
|
||||
use common\models\FieldsValueNew;
|
||||
|
||||
class Note extends \common\models\Note
|
||||
class kNote extends \common\models\Note
|
||||
{
|
||||
|
||||
public $fields;
|
||||
|
@ -62,11 +62,16 @@ class AnswerController extends Controller
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
public function actionCreate($question_id = null)
|
||||
{
|
||||
$model = new Answer();
|
||||
$model->question_id = $question_id;
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
if ($question_id !== null)
|
||||
{
|
||||
return $this->redirect(['question/view', 'id' => $question_id]);
|
||||
}
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
@ -82,11 +87,15 @@ class AnswerController extends Controller
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
public function actionUpdate($id, $question_id = null)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
if ($question_id !== null)
|
||||
{
|
||||
return $this->redirect(['question/view', 'id' => $question_id]);
|
||||
}
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
@ -102,9 +111,13 @@ class AnswerController extends Controller
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
public function actionDelete($id, $question_id = null)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
if ($question_id !== null)
|
||||
{
|
||||
return $this->redirect(['question/view', 'id' => $question_id]);
|
||||
}
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use backend\modules\questionnaire\models\AnswerSearch;
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\Question;
|
||||
use backend\modules\questionnaire\models\QuestionSearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
@ -52,8 +54,19 @@ class QuestionController extends Controller
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$answerSearchModel = new AnswerSearch();
|
||||
$answerDataProvider = new ActiveDataProvider([
|
||||
'query' => $model->getAnswers(),
|
||||
'pagination' => [
|
||||
'pageSize' => 20,
|
||||
],
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
'model' => $model,
|
||||
'answerSearchModel' => $answerSearchModel,
|
||||
'answerDataProvider' => $answerDataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -62,11 +75,23 @@ class QuestionController extends Controller
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
public function actionCreate($questionnaire_id = null, $question_type_id = null)
|
||||
{
|
||||
$model = new Question();
|
||||
$model->questionnaire_id = $questionnaire_id;
|
||||
$model->question_type_id = $question_type_id;
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
|
||||
if ($questionnaire_id !== null )
|
||||
{
|
||||
return $this->redirect(['questionnaire/view', 'id' => $questionnaire_id]);
|
||||
}
|
||||
elseif ($question_type_id !== null)
|
||||
{
|
||||
return $this->redirect(['question-type/view', 'id' => $question_type_id]);
|
||||
}
|
||||
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
@ -82,11 +107,21 @@ class QuestionController extends Controller
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
public function actionUpdate(int $id, $questionnaire_id = null, $question_type_id = null)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
|
||||
if ($questionnaire_id !== null)
|
||||
{
|
||||
return $this->redirect(['questionnaire/view', 'id' => $questionnaire_id]);
|
||||
}
|
||||
elseif ($question_type_id !== null)
|
||||
{
|
||||
return $this->redirect(['question-type/view', 'id' => $question_type_id]);
|
||||
}
|
||||
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
@ -102,10 +137,20 @@ class QuestionController extends Controller
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
public function actionDelete(int $id, $questionnaire_id = null, $question_type_id = null)
|
||||
{
|
||||
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
if ($questionnaire_id !== null)
|
||||
{
|
||||
return $this->redirect(['questionnaire/view', 'id' => $questionnaire_id]);
|
||||
}
|
||||
elseif ($question_type_id !== null)
|
||||
{
|
||||
return $this->redirect(['question-type/view', 'id' => $question_type_id]);
|
||||
}
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use backend\modules\questionnaire\models\QuestionSearch;
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\QuestionType;
|
||||
use backend\modules\questionnaire\models\QuestionTypeSearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
@ -52,8 +54,19 @@ class QuestionTypeController extends Controller
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$questionSearchModel = new QuestionSearch();
|
||||
$questionDataProvider = new ActiveDataProvider([
|
||||
'query' => $model->getQuestions(),
|
||||
'pagination' => [
|
||||
'pageSize' => 20,
|
||||
],
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
'questionDataProvider' => $questionDataProvider,
|
||||
'questionSearchModel' => $questionSearchModel,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use backend\modules\questionnaire\models\QuestionnaireSearch;
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategory;
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategorySearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
@ -52,8 +54,20 @@ class QuestionnaireCategoryController extends Controller
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$questionnaireSearchModel = new QuestionnaireSearch();
|
||||
$questionnaireDataProvider = new ActiveDataProvider([
|
||||
'query' => $model->getQuestionnaires(),
|
||||
'pagination' => [
|
||||
'pageSize' => 20,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
'model' => $model,
|
||||
'questionnaireDataProvider' => $questionnaireDataProvider,
|
||||
'questionnaireSearchModel' => $questionnaireSearchModel,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -76,11 +76,16 @@ class QuestionnaireController extends Controller
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
public function actionCreate($category_id = null)
|
||||
{
|
||||
$model = new Questionnaire();
|
||||
$model->category_id = $category_id;
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
if ($category_id !== null)
|
||||
{
|
||||
return $this->redirect(['questionnaire-category/view', 'id' => $model->category_id]);
|
||||
}
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
@ -96,11 +101,15 @@ class QuestionnaireController extends Controller
|
||||
* @return string|Response
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate(int $id)
|
||||
public function actionUpdate(int $id, $category_id = null)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
if ($category_id !== null)
|
||||
{
|
||||
return $this->redirect(['questionnaire-category/view', 'id' => $category_id]);
|
||||
}
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
@ -116,10 +125,15 @@ class QuestionnaireController extends Controller
|
||||
* @return Response
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete(int $id)
|
||||
public function actionDelete(int $id, $category_id = null)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
if ($category_id !== null)
|
||||
{
|
||||
return $this->redirect(['questionnaire-category/view', 'id' => $category_id]);
|
||||
}
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use backend\modules\questionnaire\models\Questionnaire;
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategory;
|
||||
use common\helpers\ScoreCalculatorHelper;
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\UserQuestionnaire;
|
||||
use backend\modules\questionnaire\models\UserQuestionnaireSearch;
|
||||
@ -11,7 +12,7 @@ use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
use yii\web\Response;
|
||||
|
||||
|
||||
/**
|
||||
@ -144,16 +145,22 @@ class UserQuestionnaireController extends Controller
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
public function actionQuestionnaire() {
|
||||
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||
public function actionQuestionnaire(): array
|
||||
{
|
||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
if (isset($_POST['depdrop_parents'])) {
|
||||
$parents = $_POST['depdrop_parents'];
|
||||
if ($parents != null) {
|
||||
$cat_id = $parents[0];
|
||||
$categories = Questionnaire::getQuestionnaireByCategory($cat_id);
|
||||
$categories = Questionnaire::questionnairesOfCategoryArr($cat_id);
|
||||
|
||||
return ['output'=>$categories, 'selected'=>''];
|
||||
$formattedCatArr = array();
|
||||
foreach ($categories as $key => $value){
|
||||
$formattedCatArr[] = array('id' => $key, 'name' => $value);
|
||||
}
|
||||
|
||||
return ['output'=>$formattedCatArr, 'selected'=>''];
|
||||
}
|
||||
}
|
||||
return ['output'=>'', 'selected'=>''];
|
||||
@ -161,15 +168,16 @@ class UserQuestionnaireController extends Controller
|
||||
|
||||
public function actionRateResponses($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$model->rateResponses();
|
||||
$user_questionnaire = $this->findModel($id);
|
||||
ScoreCalculatorHelper::rateResponses($user_questionnaire);
|
||||
|
||||
return $this->actionView($id);
|
||||
}
|
||||
|
||||
public function actionCalculateScore($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$model->getScore();
|
||||
$user_questionnaire = $this->findModel($id);
|
||||
ScoreCalculatorHelper::calculateScore($user_questionnaire);
|
||||
|
||||
return $this->actionView($id);
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use backend\modules\questionnaire\models\Questionnaire;
|
||||
use backend\modules\questionnaire\models\User;
|
||||
use backend\modules\questionnaire\models\UserQuestionnaire;
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\UserResponse;
|
||||
@ -91,11 +90,16 @@ class UserResponseController extends Controller
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
public function actionUpdate(int $id, $user_questionnaire_id = null)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
if ($user_questionnaire_id !== null)
|
||||
{
|
||||
return $this->redirect(['user-questionnaire/view', 'id' => $user_questionnaire_id]);
|
||||
}
|
||||
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class AnswerSearch extends Answer
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Answer::find();
|
||||
$query = Answer::find()->with('question');
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
|
@ -40,7 +40,7 @@ class QuestionSearch extends Question
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Question::find();
|
||||
$query = Question::find()->with(['questionnaire', 'questionType']);
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
|
@ -40,7 +40,7 @@ class QuestionnaireSearch extends Questionnaire
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Questionnaire::find();
|
||||
$query = Questionnaire::find()->with('category');
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
|
@ -41,7 +41,7 @@ class UserQuestionnaireSearch extends UserQuestionnaire
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = UserQuestionnaire::find();
|
||||
$query = UserQuestionnaire::find()->with('questionnaire')->joinWith('user');
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
|
@ -41,7 +41,7 @@ class UserResponseSearch extends UserResponse
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = UserResponse::find();
|
||||
$query = UserResponse::find()->with('user');
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\Question;
|
||||
use common\helpers\AnswerHelper;
|
||||
use common\helpers\StatusHelper;
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
@ -14,23 +17,26 @@ use yii\widgets\ActiveForm;
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'question_id')->widget(Select2::class, [
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\Question::find()->where(['!=', 'question_type_id', '1'])->all(), 'id', 'question_body'),
|
||||
'data' => Question::find()->select(['question_body', 'id'])
|
||||
->where(['!=', 'question_type_id', '1'])
|
||||
->indexBy('id')
|
||||
->column(),
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
'allowClear' => false
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<?= $form->field($model, 'answer_body')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'answer_flag')->dropDownList(
|
||||
\common\helpers\AnswerHelper::answerFlagsList(),
|
||||
AnswerHelper::answerFlagsList(),
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList(
|
||||
\common\helpers\StatusHelper::statusList(),
|
||||
StatusHelper::statusList(),
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\Question;
|
||||
use common\helpers\AnswerHelper;
|
||||
use common\helpers\StatusHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
@ -24,27 +27,25 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
[
|
||||
'filter' => \yii\helpers\ArrayHelper::map(\common\models\Question::find()->where(['!=', 'question_type_id', '1'])->all(), 'id', 'question_body'),
|
||||
'filter' => Question::find()->select(['question_body', 'id'])->where(['!=', 'question_type_id', '1'])->indexBy('id')->column(),
|
||||
'attribute' => 'question_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionBody();
|
||||
}
|
||||
'value' => 'question.question_body'
|
||||
],
|
||||
'answer_body',
|
||||
[
|
||||
'attribute' => 'answer_flag',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\AnswerHelper::answerFlagsList(),
|
||||
'filter' => AnswerHelper::answerFlagsList(),
|
||||
'value' => function ($model) {
|
||||
return \common\helpers\AnswerHelper::answerStatusLabel($model->answer_flag);
|
||||
return AnswerHelper::answerStatusLabel($model->answer_flag);
|
||||
},
|
||||
],
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\StatusHelper::statusList(),
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function($model){
|
||||
return \common\helpers\StatusHelper::statusLabel($model->status);
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
}
|
||||
],
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use common\helpers\AnswerHelper;
|
||||
use common\helpers\StatusHelper;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
@ -39,25 +42,19 @@ function cut_title($str)
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'question_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionBody();
|
||||
}
|
||||
'value' => ArrayHelper::getValue($model, 'question.question_body'),
|
||||
],
|
||||
[
|
||||
'attribute' => 'answer_flag',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\AnswerHelper::answerFlagsList(),
|
||||
'value' => function ($model) {
|
||||
return \common\helpers\AnswerHelper::answerStatusLabel($model->status);
|
||||
},
|
||||
'filter' => AnswerHelper::answerFlagsList(),
|
||||
'value' => AnswerHelper::answerStatusLabel($model->answer_flag),
|
||||
],
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\StatusHelper::statusList(),
|
||||
'value' => function($model){
|
||||
return \common\helpers\StatusHelper::statusLabel($model->status);
|
||||
}
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => StatusHelper::statusLabel($model->status),
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
@ -1,10 +1,16 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\QuestionType;
|
||||
use common\helpers\StatusHelper;
|
||||
use common\helpers\TimeHelper;
|
||||
use kartik\grid\GridView;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionType */
|
||||
/* @var $questionDataProvider yii\data\ActiveDataProvider */
|
||||
/* @var $questionSearchModel backend\modules\questionnaire\models\QuestionSearch */
|
||||
|
||||
$this->title = $model->question_type;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Question Types', 'url' => ['index']];
|
||||
@ -34,4 +40,68 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $questionDataProvider,
|
||||
'filterModel' => $questionSearchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'question_body',
|
||||
[
|
||||
'attribute' => 'question_type_id',
|
||||
'filter' => QuestionType::find()->select(['question_type', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'questionType.question_type'
|
||||
],
|
||||
'question_priority',
|
||||
'next_question',
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function ($model) {
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
},
|
||||
],
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return TimeHelper::limitTime($model->time_limit);
|
||||
}
|
||||
],
|
||||
'score',
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view} {update} {delete}',
|
||||
'controller' => 'question',
|
||||
'buttons' => [
|
||||
|
||||
'update' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-pencil"></span>',
|
||||
['question/update', 'id' => $model['id'], 'question_type_id' => $model['question_type_id']]);
|
||||
},
|
||||
'delete' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-trash"></span>',
|
||||
[
|
||||
'question/delete', 'id' => $model['id'], 'question_type_id' => $model['question_type_id']
|
||||
],
|
||||
[
|
||||
'data' => ['confirm' => 'Вы уверены, что хотите удалить этот вопрос?', 'method' => 'post']
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a(
|
||||
'Добавить новый вопрос',
|
||||
['question/create', 'question_type_id' => $model->id],
|
||||
['class' => 'btn btn-primary']
|
||||
) ?>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
@ -1,7 +1,10 @@
|
||||
<?php
|
||||
|
||||
use backend\components\timepicker\src\TimePicker;
|
||||
use backend\modules\questionnaire\models\Questionnaire;
|
||||
use backend\modules\questionnaire\models\QuestionType;
|
||||
use common\helpers\StatusHelper;
|
||||
use kartik\select2\Select2;
|
||||
use kartik\time\TimePicker;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
@ -16,7 +19,7 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<?= $form->field($model, 'question_type_id')->widget(Select2::class,
|
||||
[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\QuestionType::find()->all(),'id', 'question_type'),
|
||||
'data' => QuestionType::find()->select(['question_type', 'id'])->indexBy('id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
@ -26,7 +29,7 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<?= $form->field($model, 'questionnaire_id')->widget(Select2::class,
|
||||
[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\Questionnaire::find()->all(),'id', 'title'),
|
||||
'data' => Questionnaire::find()->select(['title', 'id'])->indexBy('id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
@ -41,13 +44,13 @@ use yii\widgets\ActiveForm;
|
||||
<?= $form->field($model, 'next_question')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList(
|
||||
\common\helpers\StatusHelper::statusList(),
|
||||
StatusHelper::statusList(),
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'time_limit')->widget(\backend\components\timepicker\src\TimePicker::class,
|
||||
<?= $form->field($model, 'time_limit')->widget(TimePicker::class,
|
||||
[
|
||||
'name' => 'time_limit_picker',
|
||||
'pluginOptions' => [
|
||||
@ -60,8 +63,6 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<?= $form->field($model, 'score')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\Questionnaire;
|
||||
use backend\modules\questionnaire\models\QuestionType;
|
||||
use common\helpers\StatusHelper;
|
||||
use common\helpers\TimeHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
@ -24,33 +28,29 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'question_body',
|
||||
[
|
||||
'attribute' => 'question_type_id',
|
||||
'filter' => \yii\helpers\ArrayHelper::map(\backend\modules\questionnaire\models\QuestionType::find()->all(), 'id', 'question_type'),
|
||||
'value' => function($model){
|
||||
return $model->getQuestionTitle();
|
||||
}
|
||||
'filter' => QuestionType::find()->select(['question_type', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'questionType.question_type'
|
||||
],
|
||||
[
|
||||
'attribute' => 'questionnaire_id',
|
||||
'filter' => \yii\helpers\ArrayHelper::map(\backend\modules\questionnaire\models\Questionnaire::find()->all(), 'id', 'title'),
|
||||
'value' => function($model){
|
||||
return $model->getQuestionnaireTitle();
|
||||
}
|
||||
'filter' => Questionnaire::find()->select(['title', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'questionnaire.title',
|
||||
],
|
||||
'question_priority',
|
||||
'next_question',
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\StatusHelper::statusList(),
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function ($model) {
|
||||
return \common\helpers\StatusHelper::statusLabel($model->status);
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
},
|
||||
],
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return \common\helpers\TimeHelper::limitTime($model->time_limit);
|
||||
return TimeHelper::limitTime($model->time_limit);
|
||||
}
|
||||
],
|
||||
'score',
|
||||
|
@ -1,10 +1,17 @@
|
||||
<?php
|
||||
|
||||
use common\helpers\AnswerHelper;
|
||||
use common\helpers\StatusHelper;
|
||||
use common\helpers\TimeHelper;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Question */
|
||||
/* @var $answerSearchModel backend\modules\questionnaire\models\Question */
|
||||
/* @var $answerDataProvider backend\modules\questionnaire\models\Question */
|
||||
|
||||
$this->title = $model->question_body;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questions', 'url' => ['index']];
|
||||
@ -31,15 +38,11 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'question_type_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionTitle();
|
||||
}
|
||||
'value' => ArrayHelper::getValue($model, 'questionType.question_type'),
|
||||
],
|
||||
[
|
||||
'attribute' => 'questionnaire_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionnaireTitle();
|
||||
}
|
||||
'value' => ArrayHelper::getValue($model,'questionnaire.title'),
|
||||
],
|
||||
'question_body',
|
||||
'question_priority',
|
||||
@ -47,22 +50,81 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\StatusHelper::statusList(),
|
||||
'value' => function ($model) {
|
||||
return \common\helpers\StatusHelper::statusLabel($model->status);
|
||||
},
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => StatusHelper::statusLabel($model->status),
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return \common\helpers\TimeHelper::limitTime($model->time_limit);
|
||||
}
|
||||
'value' => TimeHelper::limitTime($model->time_limit),
|
||||
],
|
||||
'score'
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<div>
|
||||
<h2>
|
||||
<?= 'Ответы: '?>
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $answerDataProvider,
|
||||
'filterModel' => $answerSearchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'answer_body',
|
||||
[
|
||||
'attribute' => 'answer_flag',
|
||||
'format' => 'raw',
|
||||
'filter' => AnswerHelper::answerFlagsList(),
|
||||
'value' => function ($model) {
|
||||
return AnswerHelper::answerStatusLabel($model->answer_flag);
|
||||
},
|
||||
],
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function($model){
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
}
|
||||
],
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view} {update} {delete}',
|
||||
'controller' => 'answer',
|
||||
'buttons' => [
|
||||
|
||||
'update' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-pencil"></span>',
|
||||
['answer/update', 'id' => $model['id'], 'question_id' => $model['question_id']]);
|
||||
},
|
||||
'delete' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-trash"></span>',
|
||||
[
|
||||
'answer/delete', 'id' => $model['id'], 'question_id' => $model['question_id']
|
||||
],
|
||||
[
|
||||
'data' => ['confirm' => 'Вы уверены, что хотите удалить этот вопрос?', 'method' => 'post']
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a(
|
||||
'Добавить новый ответ',
|
||||
['answer/create', 'question_id' => $model->id],
|
||||
['class' => 'btn btn-primary']
|
||||
) ?>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
@ -1,11 +1,17 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategory;
|
||||
use common\helpers\StatusHelper;
|
||||
use common\helpers\TimeHelper;
|
||||
use kartik\grid\GridView;
|
||||
use yii\helpers\Html;
|
||||
use yii\web\YiiAsset;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionnaireCategory */
|
||||
/* @var $questionnaireDataProvider yii\data\ActiveDataProvider */
|
||||
/* @var $questionnaireSearchModel backend\modules\questionnaire\models\QuestionnaireCategory */
|
||||
|
||||
$this->title = $model->title;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questionnaire Categories', 'url' => ['index']];
|
||||
@ -34,9 +40,9 @@ YiiAsset::register($this);
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\StatusHelper::statusList(),
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function($model) {
|
||||
return \common\helpers\StatusHelper::statusLabel($model->status);
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
},
|
||||
],
|
||||
'created_at',
|
||||
@ -44,4 +50,65 @@ YiiAsset::register($this);
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $questionnaireDataProvider,
|
||||
'filterModel' => $questionnaireSearchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'title',
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function($model){
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'category_id',
|
||||
'filter' => QuestionnaireCategory::find()->select(['title', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'category.title'
|
||||
],
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return TimeHelper::limitTime($model->time_limit);
|
||||
}
|
||||
],
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view} {update} {delete}',
|
||||
'controller' => 'questionnaire',
|
||||
'buttons' => [
|
||||
|
||||
'update' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-pencil"></span>',
|
||||
['questionnaire/update', 'id' => $model['id'], 'category_id' => $model['category_id']]);
|
||||
},
|
||||
'delete' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-trash"></span>',
|
||||
[
|
||||
'questionnaire/delete', 'id' => $model['id'], 'category_id' => $model['category_id']
|
||||
],
|
||||
[
|
||||
'data' => ['confirm' => 'Вы уверены, что хотите удалить эту анкету?', 'method' => 'post']
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a(
|
||||
'Создать новую анкету',
|
||||
['questionnaire/create', 'category_id' => $model->id],
|
||||
['class' => 'btn btn-primary']
|
||||
) ?>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
use backend\components\timepicker\src\TimePicker;
|
||||
use common\helpers\StatusHelper;
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategory;
|
||||
use kartik\select2\Select2;
|
||||
use kartik\time\TimePicker;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
@ -16,7 +18,7 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<?= $form->field($model, 'category_id')->widget(Select2::class,
|
||||
[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\QuestionnaireCategory::find()->all(),'id', 'title'),
|
||||
'data' => QuestionnaireCategory::find()->select(['title', 'id'])->indexBy('id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
@ -27,13 +29,13 @@ use yii\widgets\ActiveForm;
|
||||
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList(
|
||||
\common\helpers\StatusHelper::statusList(),
|
||||
StatusHelper::statusList(),
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'time_limit')->widget(\backend\components\timepicker\src\TimePicker::class,
|
||||
<?= $form->field($model, 'time_limit')->widget(TimePicker::class,
|
||||
[
|
||||
'name' => 'time_limit_picker',
|
||||
'pluginOptions' => [
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategory;
|
||||
use common\helpers\StatusHelper;
|
||||
use common\helpers\TimeHelper;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
@ -27,26 +31,25 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\StatusHelper::statusList(),
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function($model){
|
||||
return \common\helpers\StatusHelper::statusLabel($model->status);
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'category_id',
|
||||
'filter' => \yii\helpers\ArrayHelper::map(common\models\QuestionnaireCategory::find()->all(), 'id', 'title'),
|
||||
'value' => function($model){
|
||||
return $model->getCategoryTitle();
|
||||
}
|
||||
'filter' => QuestionnaireCategory::find()->select(['title', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'category.title'
|
||||
],
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return \common\helpers\TimeHelper::limitTime($model->time_limit);
|
||||
return TimeHelper::limitTime($model->time_limit);
|
||||
}
|
||||
],
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
|
@ -1,7 +1,12 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\QuestionType;
|
||||
use common\helpers\StatusHelper;
|
||||
use common\helpers\TimeHelper;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\web\YiiAsset;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
@ -12,7 +17,7 @@ use yii\widgets\DetailView;
|
||||
$this->title = $model->title;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questionnaires', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
\yii\web\YiiAsset::register($this);
|
||||
YiiAsset::register($this);
|
||||
?>
|
||||
<div class="questionnaire-view">
|
||||
|
||||
@ -22,7 +27,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',
|
||||
],
|
||||
]) ?>
|
||||
@ -34,26 +39,20 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'category_id',
|
||||
'value' => function($model){
|
||||
return $model->getCategoryTitle();
|
||||
}
|
||||
'value' => ArrayHelper::getValue($model,'category.title')
|
||||
],
|
||||
'title',
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
return \common\helpers\StatusHelper::statusLabel($model->status);
|
||||
},
|
||||
'value' => StatusHelper::statusLabel($model->status),
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return \common\helpers\TimeHelper::limitTime($model->time_limit);
|
||||
}
|
||||
'value' => TimeHelper::limitTime($model->time_limit),
|
||||
],
|
||||
],
|
||||
]) ?>
|
||||
@ -64,56 +63,68 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
echo GridView::widget([
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $questionDataProvider,
|
||||
'filterModel' => $questionSearchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'question_body',
|
||||
[
|
||||
'attribute' => 'question_type_id',
|
||||
'filter' => \yii\helpers\ArrayHelper::map(\backend\modules\questionnaire\models\QuestionType::find()->all(), 'id', 'question_type'),
|
||||
'value' => function($model){
|
||||
return $model->getQuestionTitle();
|
||||
}
|
||||
'filter' => QuestionType::find()->select(['question_type', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'questionType.question_type'
|
||||
],
|
||||
'question_body',
|
||||
'question_priority',
|
||||
'next_question',
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\StatusHelper::statusList(),
|
||||
'value' => function($model) {
|
||||
return \common\helpers\StatusHelper::statusLabel($model->status);
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function ($model) {
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
},
|
||||
],
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'format' => 'raw',
|
||||
'value' => function($model){
|
||||
return \common\helpers\TimeHelper::limitTime($model->time_limit);
|
||||
return TimeHelper::limitTime($model->time_limit);
|
||||
}
|
||||
],
|
||||
'score',
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view} {update}', // {delete}
|
||||
'template' => '{view} {update} {delete}',
|
||||
'controller' => 'question',
|
||||
'buttons' => [
|
||||
'view' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-eye-open"></span>',
|
||||
['question/view', 'id' => $model['id']]);
|
||||
},
|
||||
|
||||
'update' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-pencil"></span>',
|
||||
['question/update', 'id' => $model['id']]);
|
||||
['question/update', 'id' => $model['id'], 'questionnaire_id' => $model['questionnaire_id']]);
|
||||
},
|
||||
'delete' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-trash"></span>',
|
||||
[
|
||||
'question/delete', 'id' => $model['id'], 'questionnaire_id' => $model['questionnaire_id']
|
||||
],
|
||||
[
|
||||
'data' => ['confirm' => 'Вы уверены, что хотите удалить этот вопрос?', 'method' => 'post']
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
]);
|
||||
?>
|
||||
<p>
|
||||
<?= Html::a(
|
||||
'Добавить новый вопрос',
|
||||
['question/create', 'questionnaire_id' => $model->id],
|
||||
['class' => 'btn btn-primary']
|
||||
) ?>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategory;
|
||||
use common\helpers\StatusHelper;
|
||||
use common\models\User;
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
@ -17,8 +20,11 @@ use kartik\depdrop\DepDrop;
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($modelCategory, 'title')
|
||||
->dropDownList($modelCategory->getIdTitlesArr(),
|
||||
<?= $form->field($modelCategory, 'title')->dropDownList(QuestionnaireCategory::find()
|
||||
->select(['title', 'id'])
|
||||
->where(['status' => '1'])
|
||||
->indexBy('id')
|
||||
->column(),
|
||||
[
|
||||
'id' => 'cat-id',
|
||||
'prompt' => 'Выберите'
|
||||
@ -39,7 +45,7 @@ use kartik\depdrop\DepDrop;
|
||||
|
||||
<?= $form->field($model, 'user_id')->widget(Select2::class,
|
||||
[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\User::find()->all(),'id', 'username'),
|
||||
'data' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
|
||||
'options' => ['placeholder' => 'Выберите пользователя','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'placeholder' => 'Выберите',
|
||||
@ -49,7 +55,7 @@ use kartik\depdrop\DepDrop;
|
||||
); ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList(
|
||||
\common\helpers\StatusHelper::statusList(),
|
||||
StatusHelper::statusList(),
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
|
@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
use common\helpers\StatusHelper;
|
||||
use common\models\User;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use backend\modules\questionnaire\models\Questionnaire;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\questionnaire\models\UserQuestionnaireSearch */
|
||||
@ -23,17 +27,13 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
[
|
||||
'attribute' => 'questionnaire_id',
|
||||
'filter' => \yii\helpers\ArrayHelper::map(backend\modules\questionnaire\models\Questionnaire::find()->all(), 'id', 'title'),
|
||||
'value' => function($model){
|
||||
return $model->getQuestionnaireTitle();
|
||||
}
|
||||
'filter' => Questionnaire::find()->select(['title', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'questionnaire.title'
|
||||
],
|
||||
[
|
||||
'attribute' => 'user_id',
|
||||
'filter' => \yii\helpers\ArrayHelper::map(\common\models\User::find()->all(), 'id', 'username'),
|
||||
'value' => function($model){
|
||||
return $model->getUserName();
|
||||
}
|
||||
'filter' => ArrayHelper::map(User::find()->all(), 'id', 'username'),
|
||||
'value' => 'user.username'
|
||||
],
|
||||
'score',
|
||||
[
|
||||
@ -46,9 +46,9 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'filter' => \common\helpers\StatusHelper::statusList(),
|
||||
'filter' => StatusHelper::statusList(),
|
||||
'value' => function ($model) {
|
||||
return \common\helpers\StatusHelper::statusLabel($model->status);
|
||||
return StatusHelper::statusLabel($model->status);
|
||||
},
|
||||
],
|
||||
'created_at',
|
||||
|
@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
use common\helpers\ScoreCalculatorHelper;
|
||||
use common\helpers\AnswerHelper;
|
||||
use common\helpers\StatusHelper;
|
||||
use yii\bootstrap\Modal;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\web\YiiAsset;
|
||||
use yii\widgets\DetailView;
|
||||
@ -51,11 +55,11 @@ YiiAsset::register($this);
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'questionnaires_id',
|
||||
'value' => $questionnaire,
|
||||
'value' => ArrayHelper::getValue($model, 'questionnaire.title'),
|
||||
],
|
||||
[
|
||||
'attribute' => 'user_id',
|
||||
'value' => $user,
|
||||
'value' => ArrayHelper::getValue($model, 'user.username'),
|
||||
],
|
||||
'uuid',
|
||||
'score',
|
||||
@ -69,9 +73,7 @@ YiiAsset::register($this);
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'value' => function($model) {
|
||||
return common\helpers\StatusHelper::statusLabel($model->status);
|
||||
},
|
||||
'value' => StatusHelper::statusLabel($model->status),
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
@ -96,7 +98,7 @@ YiiAsset::register($this);
|
||||
'class' => 'btn btn-success',
|
||||
],
|
||||
]);
|
||||
if($model->checkAnswerFlagsForNull())
|
||||
if(ScoreCalculatorHelper::checkAnswerFlagsForNull($model))
|
||||
{
|
||||
echo 'Ответы проверены. Посчитать баллы?';
|
||||
echo Html::a('Посчитать баллы', ['calculate-score', 'id' => $model->id], [
|
||||
@ -129,13 +131,11 @@ YiiAsset::register($this);
|
||||
'response_body',
|
||||
[
|
||||
'attribute' => 'question_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionBody();
|
||||
}
|
||||
'value' => 'question.question_body'
|
||||
],
|
||||
[
|
||||
'attribute' => 'Тип вопроса',
|
||||
'value' => function($model){
|
||||
'value' => function($model) {
|
||||
return $model->getQuestionType();
|
||||
}
|
||||
],
|
||||
@ -143,18 +143,20 @@ YiiAsset::register($this);
|
||||
'attribute' => 'answer_flag',
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
return \common\helpers\AnswerHelper::answerFlagLable($model->answer_flag);
|
||||
return AnswerHelper::answerFlagLable($model->answer_flag);
|
||||
},
|
||||
|
||||
],
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{update}', // {delete}
|
||||
'template' => '{view} {update} {delete}',
|
||||
'controller' => 'user-response',
|
||||
'buttons' => [
|
||||
|
||||
'update' => function ($url,$model) {
|
||||
return Html::a(
|
||||
'<span class="glyphicon glyphicon-pencil"></span>',
|
||||
['user-response/update', 'id' => $model['id']]);
|
||||
['user-response/update', 'id' => $model['id'], 'user_questionnaire_id' => $model['user_questionnaire_id']]);
|
||||
},
|
||||
],
|
||||
],
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\Question;
|
||||
use backend\modules\questionnaire\models\UserQuestionnaire;
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
@ -29,7 +31,7 @@ use yii\widgets\ActiveForm;
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'user_id')->widget(Select2::class, [
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\User::find()->all(),'id', 'username'),
|
||||
'data' => \common\models\User::find()->select(['username','id'] )->indexBy('id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
@ -38,16 +40,15 @@ use yii\widgets\ActiveForm;
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'question_id')->widget(Select2::class,[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\Question::find()
|
||||
// ->where('question_type_id != :question_type_id', ['question_type_id' => 1])
|
||||
->all(), 'id', 'question_body'),
|
||||
|
||||
'data' => Question::find()->select(['question_body', 'id'])->indexBy('id')->column(),
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true // 'id != :id', ['id'=>1]
|
||||
],
|
||||
])?>
|
||||
|
||||
<?= $form->field($model, 'user_questionnaire_id')->widget(Select2::class,[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\UserQuestionnaire::find()->all(), 'id', 'id'),
|
||||
'data' => UserQuestionnaire::find()->select(['id', 'id'])->indexBy('id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
|
@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\Questionnaire;
|
||||
use backend\modules\questionnaire\models\UserQuestionnaire;
|
||||
use common\helpers\AnswerHelper;
|
||||
use common\models\User;
|
||||
use kartik\depdrop\DepDrop;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Url;
|
||||
@ -18,63 +22,31 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-responses-index">
|
||||
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Создать новый ответ пользователя', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<!-- --><?php //$form = ActiveForm::begin(); ?>
|
||||
|
||||
<!-- <?//= $form->field($model, 'user_id')->dropDownList(\yii\helpers\ArrayHelper::map(
|
||||
// \common\models\User::find()->all(), 'id', 'username'),
|
||||
// [
|
||||
// 'id'=>'user-id',
|
||||
// 'prompt' => 'Выберите пользователя'
|
||||
// ]
|
||||
// ) ?>
|
||||
-->
|
||||
|
||||
<!-- <?//= $form->field($questionnaire, 'title')->widget(DepDrop::classname(), [
|
||||
// 'options'=>['id'=>'questionnaire-id'],
|
||||
// 'pluginOptions'=>[
|
||||
// 'depends'=>['user-id'],
|
||||
// 'placeholder'=>'Выберите...',
|
||||
// 'url' => Url::to(['/questionnaire/user-response/questionnaire'])
|
||||
// ]
|
||||
// ]);?>
|
||||
-->
|
||||
|
||||
<!-- --><?php //ActiveForm::end(); ?>
|
||||
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
// 'id',
|
||||
// 'user_id',
|
||||
[
|
||||
'attribute' => 'user_questionnaire_id',
|
||||
'filter' => Questionnaire::find()->select(['title', 'id'])->indexBy('id')->column(),
|
||||
'value' => function($model){
|
||||
return $model->getQuestionnaireTitle();
|
||||
}
|
||||
],
|
||||
// 'user_questionnaire_id',
|
||||
|
||||
[
|
||||
'attribute' => 'user_id',
|
||||
'value' => function($model){
|
||||
return $model->getUserName();
|
||||
}
|
||||
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'user.username',
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'question_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionBody();
|
||||
}
|
||||
'value' => 'question.question_body',
|
||||
],
|
||||
|
||||
'response_body',
|
||||
@ -86,15 +58,12 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
],
|
||||
[
|
||||
'attribute' => 'answer_flag',
|
||||
'filter' => AnswerHelper::answerFlagsList(),
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
return \common\helpers\AnswerHelper::answerFlagLable($model->answer_flag);
|
||||
return AnswerHelper::answerFlagLable($model->answer_flag);
|
||||
},
|
||||
],
|
||||
|
||||
// 'created_at',
|
||||
// 'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
use common\helpers\AnswerHelper;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\web\YiiAsset;
|
||||
use yii\widgets\DetailView;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserResponse */
|
||||
@ -11,7 +13,7 @@ use yii\grid\GridView;
|
||||
$this->title =cut_title($model->response_body);
|
||||
$this->params['breadcrumbs'][] = ['label' => 'User Responses', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
\yii\web\YiiAsset::register($this);
|
||||
YiiAsset::register($this);
|
||||
|
||||
function cut_title($str)
|
||||
{
|
||||
@ -41,15 +43,11 @@ function cut_title($str)
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'Пользователь',
|
||||
'value' => function($model){
|
||||
return $model->getUserName();
|
||||
}
|
||||
'value' => ArrayHelper::getValue($model,'user.username'),
|
||||
],
|
||||
[
|
||||
'attribute' => 'Вопрос',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionBody();
|
||||
}
|
||||
'value' => ArrayHelper::getValue($model,'question.question_body'),
|
||||
],
|
||||
'response_body',
|
||||
'created_at',
|
||||
@ -57,9 +55,7 @@ function cut_title($str)
|
||||
[
|
||||
'attribute' => 'answer_flag',
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
return \common\helpers\AnswerHelper::answerFlagLable($model->answer_flag);
|
||||
},
|
||||
'value' => AnswerHelper::answerFlagLable($model->answer_flag),
|
||||
],
|
||||
'user_questionnaires_uuid',
|
||||
],
|
||||
|
Reference in New Issue
Block a user