adding forgotten files
This commit is contained in:
24
backend/modules/questionnaire/Questionnaire.php
Normal file
24
backend/modules/questionnaire/Questionnaire.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire;
|
||||
|
||||
/**
|
||||
* questionnaire module definition class
|
||||
*/
|
||||
class Questionnaire extends \yii\base\Module
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $controllerNamespace = 'backend\modules\questionnaire\controllers';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
}
|
127
backend/modules/questionnaire/controllers/AnswerController.php
Normal file
127
backend/modules/questionnaire/controllers/AnswerController.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\Answer;
|
||||
use backend\modules\questionnaire\models\AnswerSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* AnswerController implements the CRUD actions for Answer model.
|
||||
*/
|
||||
class AnswerController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Answer models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new AnswerSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single Answer model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Answer model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new Answer();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Answer model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Answer model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Answer model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return Answer the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Answer::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use yii\web\Controller;
|
||||
|
||||
/**
|
||||
* Default controller for the `questionnaire` module
|
||||
*/
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
/**
|
||||
* Renders the index view for the module
|
||||
* @return string
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
}
|
127
backend/modules/questionnaire/controllers/QuestionController.php
Normal file
127
backend/modules/questionnaire/controllers/QuestionController.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\Question;
|
||||
use backend\modules\questionnaire\models\QuestionSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* QuestionController implements the CRUD actions for Question model.
|
||||
*/
|
||||
class QuestionController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Question models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new QuestionSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single Question model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Question model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new Question();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Question model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Question model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Question model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return Question the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Question::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\QuestionType;
|
||||
use backend\modules\questionnaire\models\QuestionTypeSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* QuestionTypeController implements the CRUD actions for QuestionType model.
|
||||
*/
|
||||
class QuestionTypeController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all QuestionType models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new QuestionTypeSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single QuestionType model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new QuestionType model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new QuestionType();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing QuestionType model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing QuestionType model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the QuestionType model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return QuestionType the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = QuestionType::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategory;
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategorySearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* QuestionnaireCategoryController implements the CRUD actions for QuestionnaireCategory model.
|
||||
*/
|
||||
class QuestionnaireCategoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all QuestionnaireCategory models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new QuestionnaireCategorySearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single QuestionnaireCategory model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new QuestionnaireCategory model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new QuestionnaireCategory();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing QuestionnaireCategory model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing QuestionnaireCategory model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the QuestionnaireCategory model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return QuestionnaireCategory the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = QuestionnaireCategory::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\Questionnaire;
|
||||
use backend\modules\questionnaire\models\QuestionnaireSearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* QuestionnaireController implements the CRUD actions for Questionnaire model.
|
||||
*/
|
||||
class QuestionnaireController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Questionnaire models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new QuestionnaireSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single Questionnaire model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$questionDataProvider = new ActiveDataProvider([
|
||||
'query' => $model->getQuestions(),
|
||||
'pagination' => [
|
||||
'pageSize' => 20,
|
||||
],
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $model,
|
||||
'questionDataProvider' => $questionDataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Questionnaire model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new Questionnaire();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Questionnaire model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Questionnaire model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Questionnaire model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return Questionnaire the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Questionnaire::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\controllers;
|
||||
|
||||
use backend\modules\questionnaire\models\Questionnaire;
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategory;
|
||||
use Yii;
|
||||
use backend\modules\questionnaire\models\UserQuestionnaire;
|
||||
use backend\modules\questionnaire\models\UserQuestionnaireSearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* UserQuestionnaireController implements the CRUD actions for UserQuestionnaire model.
|
||||
*/
|
||||
class UserQuestionnaireController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all UserQuestionnaire models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new UserQuestionnaireSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single UserQuestionnaire model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$responseDataProvider = new ActiveDataProvider([
|
||||
'query' => $model->getUserResponses(),
|
||||
'pagination' => [
|
||||
'pageSize' => 20,
|
||||
],
|
||||
]);
|
||||
|
||||
return $this->render('view', [
|
||||
'model' => $model,
|
||||
'responseDataProvider' => $responseDataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new UserQuestionnaire model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new UserQuestionnaire();
|
||||
$modelCategory = new QuestionnaireCategory();
|
||||
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
'modelCategory' => $modelCategory,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing UserQuestionnaire model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$modelCategory = new QuestionnaireCategory();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
'modelCategory' => $modelCategory,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing UserQuestionnaire model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the UserQuestionnaire model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return UserQuestionnaire the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = UserQuestionnaire::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
public function actionQuestionnaire() {
|
||||
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||
|
||||
if (isset($_POST['depdrop_parents'])) {
|
||||
$parents = $_POST['depdrop_parents'];
|
||||
if ($parents != null) {
|
||||
$cat_id = $parents[0];
|
||||
$categories = Questionnaire::getQuestionnaireByCategory($cat_id);
|
||||
|
||||
return ['output'=>$categories, 'selected'=>''];
|
||||
}
|
||||
}
|
||||
return ['output'=>'', 'selected'=>''];
|
||||
}
|
||||
|
||||
public function actionRateResponses($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$model->rateResponses();
|
||||
|
||||
return $this->actionView($id);
|
||||
}
|
||||
public function actionCalculateScore($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$model->getScore();
|
||||
|
||||
return $this->actionView($id);
|
||||
}
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
use backend\modules\questionnaire\models\UserResponseSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* UserResponseController implements the CRUD actions for UserResponse model.
|
||||
*/
|
||||
class UserResponseController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all UserResponse models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$questionnaire = new Questionnaire();
|
||||
$model = new UserResponse();
|
||||
|
||||
$searchModel = new UserResponseSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
|
||||
'model' => $model,
|
||||
'questionnaire' => $questionnaire
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single UserResponse model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new UserResponse model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new UserResponse();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing UserResponse model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing UserResponse model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the UserResponse model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return UserResponse the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = UserResponse::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
|
||||
public function actionQuestionnaire()
|
||||
{
|
||||
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||
|
||||
if (isset($_POST['depdrop_parents'])) {
|
||||
$parents = $_POST['depdrop_parents'];
|
||||
if ($parents != null) {
|
||||
$user_id = $parents[0];
|
||||
|
||||
$questionnairesArr = UserQuestionnaire::getQuestionnaireByUser($user_id);
|
||||
|
||||
return ['output'=>$questionnairesArr, 'selected'=>''];
|
||||
}
|
||||
}
|
||||
return ['output'=>'', 'selected'=>''];
|
||||
}
|
||||
|
||||
public function actionTest()
|
||||
{
|
||||
return $this->render('update', [
|
||||
'model' => new UserQuestionnaire(),
|
||||
]);
|
||||
}
|
||||
}
|
9
backend/modules/questionnaire/models/Answer.php
Normal file
9
backend/modules/questionnaire/models/Answer.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
|
||||
class Answer extends \common\models\Answer
|
||||
{
|
||||
|
||||
}
|
73
backend/modules/questionnaire/models/AnswerSearch.php
Normal file
73
backend/modules/questionnaire/models/AnswerSearch.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\questionnaire\models\Answer;
|
||||
|
||||
/**
|
||||
* AnswerSearch represents the model behind the search form of `backend\modules\questionnaire\models\Answer`.
|
||||
*/
|
||||
class AnswerSearch extends Answer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'question_id', 'answer_flag', 'status'], 'integer'],
|
||||
[['answer_body', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Answer::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'question_id' => $this->question_id,
|
||||
'answer_flag' => $this->answer_flag,
|
||||
'status' => $this->status,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'answer_body', $this->answer_body]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
8
backend/modules/questionnaire/models/Question.php
Normal file
8
backend/modules/questionnaire/models/Question.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
class Question extends \common\models\Question
|
||||
{
|
||||
|
||||
}
|
77
backend/modules/questionnaire/models/QuestionSearch.php
Normal file
77
backend/modules/questionnaire/models/QuestionSearch.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\questionnaire\models\Question;
|
||||
|
||||
/**
|
||||
* QuestionSearch represents the model behind the search form of `backend\modules\questionnaire\models\Question`.
|
||||
*/
|
||||
class QuestionSearch extends Question
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'question_type_id', 'questionnaire_id', 'question_priority', 'next_question', 'status', 'score', 'time_limit'], 'integer'],
|
||||
[['question_body', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Question::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'question_type_id' => $this->question_type_id,
|
||||
'questionnaire_id' => $this->questionnaire_id,
|
||||
'question_priority' => $this->question_priority,
|
||||
'next_question' => $this->next_question,
|
||||
'status' => $this->status,
|
||||
'score' => $this->score,
|
||||
'time_limit' => $this->time_limit,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'question_body', $this->question_body]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
9
backend/modules/questionnaire/models/QuestionType.php
Normal file
9
backend/modules/questionnaire/models/QuestionType.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
|
||||
class QuestionType extends \common\models\QuestionType
|
||||
{
|
||||
|
||||
}
|
69
backend/modules/questionnaire/models/QuestionTypeSearch.php
Normal file
69
backend/modules/questionnaire/models/QuestionTypeSearch.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\questionnaire\models\QuestionType;
|
||||
|
||||
/**
|
||||
* QuestionTypeSearch represents the model behind the search form of `backend\modules\questionnaire\models\QuestionType`.
|
||||
*/
|
||||
class QuestionTypeSearch extends QuestionType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id'], 'integer'],
|
||||
[['question_type', 'slug'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = QuestionType::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'question_type', $this->question_type])
|
||||
->andFilterWhere(['like', 'slug', $this->slug]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
9
backend/modules/questionnaire/models/Questionnaire.php
Normal file
9
backend/modules/questionnaire/models/Questionnaire.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
|
||||
class Questionnaire extends \common\models\Questionnaire
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
|
||||
class QuestionnaireCategory extends \common\models\QuestionnaireCategory
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\questionnaire\models\QuestionnaireCategory;
|
||||
|
||||
/**
|
||||
* QuestionnaireCategorySearch represents the model behind the search form of `backend\modules\questionnaire\models\QuestionnaireCategory`.
|
||||
*/
|
||||
class QuestionnaireCategorySearch extends QuestionnaireCategory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'status'], 'integer'],
|
||||
[['title', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = QuestionnaireCategory::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'status' => $this->status,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'title', $this->title]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
73
backend/modules/questionnaire/models/QuestionnaireSearch.php
Normal file
73
backend/modules/questionnaire/models/QuestionnaireSearch.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\questionnaire\models\Questionnaire;
|
||||
|
||||
/**
|
||||
* QuestionnaireSearch represents the model behind the search form of `backend\modules\questionnaire\models\Questionnaire`.
|
||||
*/
|
||||
class QuestionnaireSearch extends Questionnaire
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'category_id', 'status', 'time_limit'], 'integer'],
|
||||
[['title', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Questionnaire::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'category_id' => $this->category_id,
|
||||
'status' => $this->status,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'time_limit' => $this->time_limit,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'title', $this->title]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
|
||||
class UserQuestionnaire extends \common\models\UserQuestionnaire
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\questionnaire\models\UserQuestionnaire;
|
||||
|
||||
/**
|
||||
* UserQuestionnaireSearch represents the model behind the search form of `backend\modules\questionnaire\models\UserQuestionnaire`.
|
||||
*/
|
||||
class UserQuestionnaireSearch extends UserQuestionnaire
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'questionnaire_id', 'user_id', 'score', 'status'], 'integer'],
|
||||
[['uuid', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = UserQuestionnaire::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'questionnaire_id' => $this->questionnaire_id,
|
||||
'user_id' => $this->user_id,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'score' => $this->score,
|
||||
'status' => $this->status,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'uuid', $this->uuid]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
9
backend/modules/questionnaire/models/UserResponse.php
Normal file
9
backend/modules/questionnaire/models/UserResponse.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
|
||||
class UserResponse extends \common\models\UserResponse
|
||||
{
|
||||
|
||||
}
|
75
backend/modules/questionnaire/models/UserResponseSearch.php
Normal file
75
backend/modules/questionnaire/models/UserResponseSearch.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\questionnaire\models;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use backend\modules\questionnaire\models\UserResponse;
|
||||
|
||||
/**
|
||||
* UserResponseSearch represents the model behind the search form of `backend\modules\questionnaire\models\UserResponse`.
|
||||
*/
|
||||
class UserResponseSearch extends UserResponse
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'user_id', 'question_id', 'user_questionnaire_id'], 'integer'],
|
||||
[['response_body', 'created_at', 'updated_at'], 'safe'],
|
||||
[['answer_flag'], 'number'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = UserResponse::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'user_id' => $this->user_id,
|
||||
'question_id' => $this->question_id,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'answer_flag' => $this->answer_flag,
|
||||
'user_questionnaire_id' => $this->user_questionnaire_id,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'response_body', $this->response_body]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
49
backend/modules/questionnaire/views/answer/_form.php
Normal file
49
backend/modules/questionnaire/views/answer/_form.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Answer */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="answer-form">
|
||||
|
||||
<?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'),
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<?= $form->field($model, 'answer_body')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'answer_flag')->dropDownList(
|
||||
$model->flags,
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList(
|
||||
$model->statuses,
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
|
||||
<!-- <?//= $form->field($model, 'created_at')->textInput() ?> -->
|
||||
|
||||
<!-- <?//= $form->field($model, 'updated_at')->textInput() ?> -->
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
39
backend/modules/questionnaire/views/answer/_search.php
Normal file
39
backend/modules/questionnaire/views/answer/_search.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\AnswerSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="answer-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'question_id') ?>
|
||||
|
||||
<?= $form->field($model, 'answer_body') ?>
|
||||
|
||||
<?= $form->field($model, 'answer_flag') ?>
|
||||
|
||||
<?= $form->field($model, 'status') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'created_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
18
backend/modules/questionnaire/views/answer/create.php
Normal file
18
backend/modules/questionnaire/views/answer/create.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Answer */
|
||||
|
||||
$this->title = 'Создание нового ответа';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Answers', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="answer-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
66
backend/modules/questionnaire/views/answer/index.php
Normal file
66
backend/modules/questionnaire/views/answer/index.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\questionnaire\models\AnswerSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Ответы на вопросы';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="answer-index">
|
||||
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Создать новый ответ', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
// 'id',
|
||||
[
|
||||
'attribute' => 'question_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionBody();
|
||||
}
|
||||
],
|
||||
'answer_body',
|
||||
[
|
||||
'attribute' => 'answer_flag',
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
return \yii\helpers\Html::tag(
|
||||
'span',
|
||||
$model->answer_flag ? 'Correct' : 'Wrong',
|
||||
[
|
||||
'class' => 'label label-' . ($model->answer_flag ? 'success' : 'danger'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
[
|
||||
'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'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
//'created_at',
|
||||
//'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
19
backend/modules/questionnaire/views/answer/update.php
Normal file
19
backend/modules/questionnaire/views/answer/update.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Answer */
|
||||
|
||||
$this->title = $model->answer_body;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Answers', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="answer-update">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
76
backend/modules/questionnaire/views/answer/view.php
Normal file
76
backend/modules/questionnaire/views/answer/view.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Answer */
|
||||
|
||||
$this->title = cut_title($model->answer_body);
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Answers', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
\yii\web\YiiAsset::register($this);
|
||||
|
||||
function cut_title($str)
|
||||
{
|
||||
if(strlen($str) > 35){
|
||||
return mb_substr($str, 0, 35, 'UTF-8') . '...';
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
?>
|
||||
<div class="answer-view">
|
||||
|
||||
<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?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'question_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionBody();
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'answer_flag',
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
return \yii\helpers\Html::tag(
|
||||
'span',
|
||||
$model->answer_flag ? 'Correct' : 'Wrong',
|
||||
[
|
||||
'class' => 'label label-' . ($model->answer_flag ? 'success' : 'danger'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
[
|
||||
'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'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
</div>
|
12
backend/modules/questionnaire/views/default/index.php
Normal file
12
backend/modules/questionnaire/views/default/index.php
Normal file
@ -0,0 +1,12 @@
|
||||
<div class="questionnaire-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>
|
23
backend/modules/questionnaire/views/question-type/_form.php
Normal file
23
backend/modules/questionnaire/views/question-type/_form.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionType */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="question-type-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'question_type')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionTypeSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="question-type-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'question_type') ?>
|
||||
|
||||
<?= $form->field($model, 'slug') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
18
backend/modules/questionnaire/views/question-type/create.php
Normal file
18
backend/modules/questionnaire/views/question-type/create.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionType */
|
||||
|
||||
$this->title = 'Создание типа вопроса';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Question Types', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="question-type-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
34
backend/modules/questionnaire/views/question-type/index.php
Normal file
34
backend/modules/questionnaire/views/question-type/index.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\questionnaire\models\QuestionTypeSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Типы вопросов';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="question-type-index">
|
||||
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Создать новый тип вопроса', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
// 'id',
|
||||
'question_type',
|
||||
'slug',
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
19
backend/modules/questionnaire/views/question-type/update.php
Normal file
19
backend/modules/questionnaire/views/question-type/update.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionType */
|
||||
|
||||
$this->title = 'Изменить тип вопроса: ' . $model->id;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Question Types', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="question-type-update">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
37
backend/modules/questionnaire/views/question-type/view.php
Normal file
37
backend/modules/questionnaire/views/question-type/view.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionType */
|
||||
|
||||
$this->title = $model->question_type;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Question Types', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
\yii\web\YiiAsset::register($this);
|
||||
?>
|
||||
<div class="question-type-view">
|
||||
|
||||
<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?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
'question_type',
|
||||
'slug',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
80
backend/modules/questionnaire/views/question/_form.php
Normal file
80
backend/modules/questionnaire/views/question/_form.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Question */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="question-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'question_type_id')->widget(Select2::class,
|
||||
[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\QuestionType::find()->all(),'id', 'question_type'),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]
|
||||
); ?>
|
||||
|
||||
<?= $form->field($model, 'questionnaire_id')->widget(Select2::class,
|
||||
[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\Questionnaire::find()->all(),'id', 'title'),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]
|
||||
); ?>
|
||||
|
||||
<!-- <?//= $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() ?>
|
||||
|
||||
<?= $form->field($model, 'next_question')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList(
|
||||
$model->statuses,
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
|
||||
<!-- <?//= $form->field($model, 'created_at')->textInput() ?> -->
|
||||
|
||||
<!-- <?//= $form->field($model, 'updated_at')->textInput() ?> -->
|
||||
|
||||
<?= $form->field($model, 'time_limit')->dropDownList(
|
||||
[
|
||||
'' => 'Не ограничено',
|
||||
'30' => '30 секунд',
|
||||
'60' => '1 минута',
|
||||
'90' => '1:30 секунд',
|
||||
'120' => '2 минуты',
|
||||
'180' => '3 минуты',
|
||||
'300' => '5 минут',
|
||||
'600' => '10 минут',
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'score')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
47
backend/modules/questionnaire/views/question/_search.php
Normal file
47
backend/modules/questionnaire/views/question/_search.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="question-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'question_type_id') ?>
|
||||
|
||||
<?= $form->field($model, 'questionnaire_id') ?>
|
||||
|
||||
<?= $form->field($model, 'question_body') ?>
|
||||
|
||||
<?= $form->field($model, 'question_priority') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'next_question') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'status') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'score') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'time_limit') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'created_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
18
backend/modules/questionnaire/views/question/create.php
Normal file
18
backend/modules/questionnaire/views/question/create.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Question */
|
||||
|
||||
$this->title = 'Создание вопроса';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questions', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="question-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
73
backend/modules/questionnaire/views/question/index.php
Normal file
73
backend/modules/questionnaire/views/question/index.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\questionnaire\models\QuestionSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Список вопросов';
|
||||
$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>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
// 'id',
|
||||
'question_body',
|
||||
[
|
||||
'attribute' => 'question_type_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionTitle();
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'questionnaire_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionnaireTitle();
|
||||
}
|
||||
],
|
||||
'question_priority',
|
||||
'next_question',
|
||||
[
|
||||
'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'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
//'created_at',
|
||||
//'updated_at',
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'value' => function($model){
|
||||
return $model->limitTime;
|
||||
}
|
||||
],
|
||||
'score',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
19
backend/modules/questionnaire/views/question/update.php
Normal file
19
backend/modules/questionnaire/views/question/update.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Question */
|
||||
|
||||
$this->title = 'Изменение вопроса: ' . $model->question_body;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questions', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="question-update">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
72
backend/modules/questionnaire/views/question/view.php
Normal file
72
backend/modules/questionnaire/views/question/view.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Question */
|
||||
|
||||
$this->title = $model->question_body;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questions', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
\yii\web\YiiAsset::register($this);
|
||||
?>
|
||||
<div class="question-view">
|
||||
|
||||
<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?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'question_type_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionTitle();
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'questionnaire_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionnaireTitle();
|
||||
}
|
||||
],
|
||||
'question_body',
|
||||
'question_priority',
|
||||
'next_question',
|
||||
[
|
||||
'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'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'value' => function($model){
|
||||
return $model->limitTime;
|
||||
}
|
||||
],
|
||||
'score'
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionnaireCategory */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="questionnaire-category-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<!-- <?//= $form->field($model, 'status')->textInput() ?> -->
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList(
|
||||
$model->statuses,
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
|
||||
<!-- <?//= $form->field($model, 'created_at')->textInput() ?> -->
|
||||
|
||||
<!-- <?//= $form->field($model, 'updated_at')->textInput() ?> -->
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionnaireCategorySearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="questionnaire-category-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'title') ?>
|
||||
|
||||
<?= $form->field($model, 'status') ?>
|
||||
|
||||
<?= $form->field($model, 'created_at') ?>
|
||||
|
||||
<?= $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionnaireCategory */
|
||||
|
||||
$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>-->
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\questionnaire\models\QuestionnaireCategorySearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Категории анкет';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="questionnaire-category-index">
|
||||
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Создать новую категорию анкет', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'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'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
// 'created_at',
|
||||
// 'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionnaireCategory */
|
||||
|
||||
$this->title = 'Редактировать категорию анкет: ' . $model->title;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questionnaire Categories', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="questionnaire-category-update">
|
||||
|
||||
<!-- <h1>-->
|
||||
<!-- <?//= Html::encode($this->title) ?> -->
|
||||
<!-- </h1>-->
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionnaireCategory */
|
||||
|
||||
$this->title = $model->title;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questionnaire Categories', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
\yii\web\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?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'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'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
54
backend/modules/questionnaire/views/questionnaire/_form.php
Normal file
54
backend/modules/questionnaire/views/questionnaire/_form.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Questionnaire */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="questionnaire-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'category_id')->widget(Select2::class,
|
||||
[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\QuestionnaireCategory::find()->all(),'id', 'title'),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]
|
||||
); ?>
|
||||
|
||||
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList(
|
||||
$model->statuses,
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'time_limit')->dropDownList(
|
||||
[
|
||||
'' => 'Не ограничено',
|
||||
'600' => '10 минут',
|
||||
'900' => '15 минут',
|
||||
'1200' => '20 минут',
|
||||
'1800' => '30 минут',
|
||||
'2700' => '45 минут',
|
||||
'3600' => '1 час',
|
||||
]
|
||||
)
|
||||
?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\QuestionnaireSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="questionnaire-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'category_id') ?>
|
||||
|
||||
<?= $form->field($model, 'title') ?>
|
||||
|
||||
<?= $form->field($model, 'status') ?>
|
||||
|
||||
<?= $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']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
22
backend/modules/questionnaire/views/questionnaire/create.php
Normal file
22
backend/modules/questionnaire/views/questionnaire/create.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Questionnaire */
|
||||
|
||||
$this->title = 'Создание анкеты';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questionnaires', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="questionnaire-create">
|
||||
|
||||
<!-- <h1>-->
|
||||
<!-- <?//= Html::encode($this->title) ?> -->
|
||||
<!-- </h1>-->
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
64
backend/modules/questionnaire/views/questionnaire/index.php
Normal file
64
backend/modules/questionnaire/views/questionnaire/index.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\questionnaire\models\QuestionnaireSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Список анкет';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="questionnaire-index">
|
||||
|
||||
<!-- <h1>-->
|
||||
<!-- <?//= Html::encode($this->title) ?> -->
|
||||
<!-- </h1>-->
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Создать', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'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'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
[
|
||||
'attribute' => 'category_id',
|
||||
'value' => function($model){
|
||||
return $model->getCategoryTitle();
|
||||
}
|
||||
],
|
||||
// 'created_at',
|
||||
// 'updated_at',
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'value' => function($model){
|
||||
return $model->limitTime;
|
||||
}
|
||||
],
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
23
backend/modules/questionnaire/views/questionnaire/update.php
Normal file
23
backend/modules/questionnaire/views/questionnaire/update.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Questionnaire */
|
||||
|
||||
$this->title = 'Изменение: ' . $model->title;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questionnaires', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="questionnaire-update">
|
||||
|
||||
<!-- <h1>-->
|
||||
<!-- <?//= Html::encode($this->title) ?> -->
|
||||
<!-- </h1>-->
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
131
backend/modules/questionnaire/views/questionnaire/view.php
Normal file
131
backend/modules/questionnaire/views/questionnaire/view.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\Questionnaire */
|
||||
/* @var $questionDataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = $model->title;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Questionnaires', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
\yii\web\YiiAsset::register($this);
|
||||
?>
|
||||
<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']) ?>
|
||||
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => 'Are you sure you want to delete this item?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'category_id',
|
||||
'value' => function($model){
|
||||
return $model->getCategoryTitle();
|
||||
}
|
||||
],
|
||||
'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'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'value' => function($model){
|
||||
return $model->limitTime;
|
||||
}
|
||||
]
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<div>
|
||||
<h2>
|
||||
<?= 'Вопросы анкеты: ' . Html::encode($this->title) ?>
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
echo GridView::widget([
|
||||
'dataProvider' => $questionDataProvider,
|
||||
'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'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
// 'created_at',
|
||||
// 'updated_at',
|
||||
[
|
||||
'attribute' => 'time_limit',
|
||||
'value' => function($model){
|
||||
return $model->limitTime;
|
||||
}
|
||||
],
|
||||
'score',
|
||||
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view} {update}', // {delete}
|
||||
'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']]);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
]);
|
||||
?>
|
||||
|
||||
</div>
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
use kartik\depdrop\DepDrop;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserQuestionnaire */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
/* @var $modelCategory backend\modules\questionnaire\models\QuestionnaireCategory */
|
||||
?>
|
||||
|
||||
<div class="user-questionnaire-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($modelCategory, 'title')
|
||||
->dropDownList($modelCategory->getIdTitlesArr(),
|
||||
[
|
||||
'id' => 'cat-id',
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
);
|
||||
?>
|
||||
|
||||
<?= $form->field($model, 'questionnaire_id')->widget(DepDrop::className(),
|
||||
[
|
||||
'options' => ['id' => 'questionnaire-id'],
|
||||
'pluginOptions' => [
|
||||
'depends' => ['cat-id'],
|
||||
'placeholder' => 'Выберите',
|
||||
'url' => Url::to(['/questionnaire/user-questionnaire/questionnaire'])
|
||||
]
|
||||
]
|
||||
); ?>
|
||||
|
||||
<?= $form->field($model, 'user_id')->widget(Select2::class,
|
||||
[
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\User::find()->all(),'id', 'username'),
|
||||
'options' => ['placeholder' => 'Выберите пользователя','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'placeholder' => 'Выберите',
|
||||
'allowClear' => true
|
||||
],
|
||||
]
|
||||
); ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList(
|
||||
$model->statuses,
|
||||
[
|
||||
'prompt' => 'Выберите'
|
||||
]
|
||||
) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserQuestionnaireSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="user-questionnaire-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'questionnaire_id') ?>
|
||||
|
||||
<?= $form->field($model, 'user_id') ?>
|
||||
|
||||
<?= $form->field($model, 'uuid') ?>
|
||||
|
||||
<?= $form->field($model, 'created_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'updated_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'score') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'status') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserQuestionnaire */
|
||||
/* @var $modelCategory backend\modules\questionnaire\models\QuestionnaireCategory */
|
||||
|
||||
$this->title = 'Назначение анкеты пользователю';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'User Questionnaires', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-questionnaire-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
'modelCategory' => $modelCategory,
|
||||
]) ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\questionnaire\models\UserQuestionnaireSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Анкеты пользователей';
|
||||
$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>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
// 'id',
|
||||
[
|
||||
'attribute' => 'questionnaire_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionnaireTitle();
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'user_id',
|
||||
'value' => function($model){
|
||||
return $model->getUserName();
|
||||
}
|
||||
],
|
||||
// 'UUID',
|
||||
'score',
|
||||
[
|
||||
'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'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserQuestionnaire */
|
||||
|
||||
/* @var $modelCategory backend\modules\questionnaire\models\QuestionnaireCategory */
|
||||
|
||||
$this->title = 'Изменить: ' . $model->id;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'User Questionnaires', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="user-questionnaire-update">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
'modelCategory' => $modelCategory,
|
||||
]) ?>
|
||||
|
||||
</div>
|
177
backend/modules/questionnaire/views/user-questionnaire/view.php
Normal file
177
backend/modules/questionnaire/views/user-questionnaire/view.php
Normal file
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
use yii\bootstrap\Modal;
|
||||
use yii\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\UserQuestionnaire */
|
||||
/* @var $responseDataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$user = $model->getUserName();
|
||||
$questionnaire = $model->getQuestionnaireTitle();
|
||||
|
||||
$this->title = $user . ": " . $questionnaire;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'User Questionnaires', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
YiiAsset::register($this);
|
||||
?>
|
||||
<div class="user-questionnaire-view">
|
||||
|
||||
<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?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'questionnaires_id',
|
||||
'value' => $questionnaire,
|
||||
],
|
||||
[
|
||||
'attribute' => 'user_id',
|
||||
'value' => $user,
|
||||
],
|
||||
'uuid',
|
||||
'score',
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
return Html::tag(
|
||||
'span',
|
||||
$model->status ? 'Active' : 'Not Active',
|
||||
[
|
||||
'class' => 'label label-' . ($model->status ? 'success' : 'danger'),
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<p>
|
||||
|
||||
<?= Html::a('Проверить ответы', ['rate-responses', 'id' => $model->id], [
|
||||
'class' => 'btn btn-primary',
|
||||
'data' => [
|
||||
'confirm' => 'Проверка ответов пользователя: ' . $user . ". Категория: " . $questionnaire,
|
||||
// 'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
<?php
|
||||
Modal::begin([
|
||||
'header' => '<h3>Подсчёт балов</h3>',
|
||||
'toggleButton' => [
|
||||
'label' => 'Посчитать баллы',
|
||||
'tag' => 'button',
|
||||
'class' => 'btn btn-success',
|
||||
],
|
||||
]);
|
||||
if($model->checkAnswerFlagsForNull())
|
||||
{
|
||||
echo 'Ответы проверены. Посчитать баллы?';
|
||||
echo Html::a('Посчитать баллы', ['calculate-score', 'id' => $model->id], [
|
||||
'class' => 'btn btn-primary'
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'Не все ответы проверены.';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<?php Modal::end(); ?>
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<h2>
|
||||
<?= 'Ответы пользователя' ?>
|
||||
</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';
|
||||
}
|
||||
else if ($answerFlag === 0.0)
|
||||
{
|
||||
$class = 'label label-danger';
|
||||
$content = 'Wrong';
|
||||
}
|
||||
|
||||
return Html::tag(
|
||||
'span',
|
||||
$content,
|
||||
[
|
||||
'class' => $class,
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
|
||||
// 'created_at',
|
||||
// 'updated_at',
|
||||
|
||||
[
|
||||
'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']]);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
]);
|
||||
?>
|
||||
|
||||
</div>
|
65
backend/modules/questionnaire/views/user-response/_form.php
Normal file
65
backend/modules/questionnaire/views/user-response/_form.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserResponse */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="user-response-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'answer_flag')->dropDownList(
|
||||
[
|
||||
'' => 'Не задано',
|
||||
'0.1' => '10%',
|
||||
'0.2' => '20%',
|
||||
'0.3' => '30%',
|
||||
'0.5' => '50%',
|
||||
'0.7' => '70%',
|
||||
'0.8' => '80%',
|
||||
'0.85' => '85%',
|
||||
'0.9' => '90%',
|
||||
'1' => '100%',
|
||||
]
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'user_id')->widget(Select2::class, [
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\User::find()->all(),'id', 'username'),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
|
||||
]); ?>
|
||||
|
||||
<?= $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'),
|
||||
'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'),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
])?>
|
||||
|
||||
<?= $form->field($model, 'response_body')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserResponseSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="user-response-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'user_id') ?>
|
||||
|
||||
<?= $form->field($model, 'question_id') ?>
|
||||
|
||||
<?= $form->field($model, 'response_body') ?>
|
||||
|
||||
<?= $form->field($model, 'created_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'answer_flag') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'updated_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'user_questionnaire_id') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
18
backend/modules/questionnaire/views/user-response/create.php
Normal file
18
backend/modules/questionnaire/views/user-response/create.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserResponse */
|
||||
|
||||
$this->title = 'Создать ответ пользователя';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'User Responses', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-response-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
123
backend/modules/questionnaire/views/user-response/index.php
Normal file
123
backend/modules/questionnaire/views/user-response/index.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\questionnaire\models\Questionnaire;
|
||||
use kartik\depdrop\DepDrop;
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Url;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\questionnaire\models\UserResponseSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
/* @var $model backend\modules\questionnaire\models\UserResponse */
|
||||
/* @var $questionnaire backend\modules\questionnaire\models\Questionnaire */
|
||||
|
||||
$this->title = 'Ответы пользователей';
|
||||
$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',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionnaireTitle();
|
||||
}
|
||||
],
|
||||
// 'user_questionnaire_id',
|
||||
|
||||
[
|
||||
'attribute' => 'user_id',
|
||||
'value' => function($model){
|
||||
return $model->getUserName();
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'question_id',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionBody();
|
||||
}
|
||||
],
|
||||
|
||||
'response_body',
|
||||
[
|
||||
'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';
|
||||
}
|
||||
else if ($answerFlag === 0.0)
|
||||
{
|
||||
$class = 'label label-danger';
|
||||
$content = 'Wrong';
|
||||
}
|
||||
|
||||
return Html::tag(
|
||||
'span',
|
||||
$content,
|
||||
[
|
||||
'class' => $class,
|
||||
]
|
||||
);
|
||||
},
|
||||
],
|
||||
|
||||
// 'created_at',
|
||||
// 'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
19
backend/modules/questionnaire/views/user-response/update.php
Normal file
19
backend/modules/questionnaire/views/user-response/update.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserResponse */
|
||||
|
||||
$this->title = 'Изменение ответа: ' . $model->response_body;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'User Responses', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Update';
|
||||
?>
|
||||
<div class="user-response-update">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
62
backend/modules/questionnaire/views/user-response/view.php
Normal file
62
backend/modules/questionnaire/views/user-response/view.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\modules\questionnaire\models\UserResponse */
|
||||
/* @var $responseDataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$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);
|
||||
|
||||
function cut_title($str)
|
||||
{
|
||||
if(strlen($str) > 40){
|
||||
return mb_substr($str, 0, 40, 'UTF-8') . '...';
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
?>
|
||||
<div class="user-response-view">
|
||||
|
||||
<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?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'Пользователь',
|
||||
'value' => function($model){
|
||||
return $model->getUserName();
|
||||
}
|
||||
],
|
||||
[
|
||||
'attribute' => 'Вопрос',
|
||||
'value' => function($model){
|
||||
return $model->getQuestionBody();
|
||||
}
|
||||
],
|
||||
'response_body',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'answer_flag',
|
||||
'user_questionnaires_uuid',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
Reference in New Issue
Block a user