mega fix

parent b121ecca
......@@ -41,9 +41,10 @@ class Module extends \common\components\WebModule
public static function adminMenu()
{
return array(
'Список сессий' => '/testings/testing-session-admin/manage',
'Список тестов' => '/testings/testing-test-admin/manage',
'Список вопросов' => '/testings/testing-question-admin/manage',
'Список сессий' => '/testings/session-admin/manage',
'Список тестов' => '/testings/test-admin/manage',
'Список вопросов' => '/testings/question-admin/manage',
'Список тем' => '/testings/theme-admin/manage',
);
}
}
$(function()
{
var $answers_forms = $('#answers_forms');
var $form = $('#testing-question-form');
$('#add_answer').click(function()
{
var $inputs = $('#answers_forms input');
var num = 0;
if ($inputs.length)
{
var max_num = 0;
$inputs.each(function()
{
var reg = new RegExp('([0-9]+)');
var curr_num = reg.exec($(this).attr('name'))[0];
if (curr_num > max_num)
{
max_num = curr_num;
}
});
num = ++max_num;
}
var params = {
'sub_form' : 'add',
'num' : num
};
$.post('/testings/testingQuestionAdmin/GetAnswerForm', params , function(form)
{
$answers_forms.append(form);
});
return false;
});
$form.submit(function()
{
if ($('#answers_forms input').length)
{
$.post('/testings/testingQuestionAdmin/ValidateAnswerForm', $(this).serialize(), function(res)
{
if (res.done)
{
alert('valid');
}
else
{
$answers_forms.html(res.html);
}
},
'json'
);
//return true;
}
return false;
});
});
......@@ -7,10 +7,10 @@ use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\modules\testings\models\TestingAnswer;
use common\modules\testings\models\SearchTestingAnswer;
use common\modules\testings\models\Answer;
use common\modules\testings\models\SearchAnswer;
class TestingAnswerAdminController extends AdminController
class AnswerAdminController extends AdminController
{
public static function actionsTitles()
{
......@@ -45,11 +45,11 @@ class TestingAnswerAdminController extends AdminController
public function actionCreate()
{
$model = new TestingAnswer;
$model = new Answer;
Yii::$app->controller->page_title = 'Добавить ответ';
Yii::$app->controller->breadcrumbs = [
['Список ответов' => '/testings/testing-question-admin/manage'],
['Список ответов' => '/testings/question-admin/manage'],
'Добавить ответ'
];
......@@ -66,7 +66,7 @@ class TestingAnswerAdminController extends AdminController
}
else
{
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestingAnswerForm', $model);
$form = new \common\components\BaseForm('/common/modules/testings/forms/AnswerForm', $model);
return $this->render('create', [
'model' => $model,
'form' => $form->out
......@@ -79,7 +79,7 @@ class TestingAnswerAdminController extends AdminController
{
Yii::$app->controller->page_title = 'Редактировать ответ';
Yii::$app->controller->breadcrumbs = [
['Список ответов' => '/testings/testing-answer-admin/manage'],
['Список ответов' => '/testings/answer-admin/manage'],
'Редактировать ответ'
];
......@@ -98,7 +98,7 @@ class TestingAnswerAdminController extends AdminController
}
else
{
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestingAnswerForm', $model);
$form = new \common\components\BaseForm('/common/modules/testings/forms/AnswerForm', $model);
return $this->render('update', [
'model' => $model,
'form' => $form->out
......@@ -117,7 +117,7 @@ class TestingAnswerAdminController extends AdminController
public function actionManage()
{
$searchModel = new SearchTestingAnswer();
$searchModel = new SearchAnswer();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Yii::$app->controller->page_title = 'Список ответов';
......@@ -140,7 +140,7 @@ class TestingAnswerAdminController extends AdminController
*/
protected function findModel($id)
{
if (($model = TestingAnswer::findOne($id)) !== null) {
if (($model = Answer::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
......
......@@ -7,14 +7,14 @@ use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\TestingPassing;
use common\modules\testings\models\SearchTestingPassing;
use common\modules\testings\models\TestingSession;
use common\modules\testings\models\SearchTestingQuestionPassing;
use common\modules\testings\models\TestingQuestionPassing;
class TestingPassingAdminController extends AdminController
use common\modules\testings\models\Test;
use common\modules\testings\models\Passing;
use common\modules\testings\models\SearchPassing;
use common\modules\testings\models\Session;
use common\modules\testings\models\SearchQuestionPassing;
use common\modules\testings\models\QuestionPassing;
class PassingAdminController extends AdminController
{
public static function actionsTitles()
{
......@@ -45,7 +45,7 @@ class TestingPassingAdminController extends AdminController
public function actionView($id)
{
$searchModel = new SearchTestingQuestionPassing();
$searchModel = new SearchQuestionPassing();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams, null, null, $id);
return $this->render('view', [
......@@ -59,18 +59,18 @@ class TestingPassingAdminController extends AdminController
public function actionCreate($session)
{
$model = new TestingTest;
$model = new Test;
Yii::$app->controller->page_title = 'Добавить прохождение';
Yii::$app->controller->breadcrumbs = [
['Список прохождений' => '/testings/testing-passing-admin/manage'],
['Список прохождений' => '/testings/passing-admin/manage'],
'Добавить прохождение'
];
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['manage', 'session' => $session]);
} else {
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestingPassingForm', $model);
$form = new \common\components\BaseForm('/common/modules/testings/forms/PassingForm', $model);
return $this->render('create', [
'model' => $model,
'form' => $form->out
......@@ -84,11 +84,11 @@ class TestingPassingAdminController extends AdminController
if ($model->mistake)
{
return $this->redirect(['/testings/testingMistakeAdmin/view', 'passing' => $id]);
return $this->redirect(['/testings/mistake-admin/view', 'passing' => $id]);
}
else
{
return $this->redirect(['/testings/testingMistakeAdmin/create', 'passing' => $id]);
return $this->redirect(['/testings/mistake-admin/create', 'passing' => $id]);
}
}
......@@ -103,7 +103,7 @@ class TestingPassingAdminController extends AdminController
public function actionManage($session)
{
$searchModel = new SearchTestingPassing();
$searchModel = new SearchPassing();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Yii::$app->controller->page_title = 'Список прохождений';
......@@ -114,13 +114,13 @@ class TestingPassingAdminController extends AdminController
return $this->render('manage', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'session' => TestingSession::findOne($session),
'session' => Session::findOne($session),
]);
}
public function actionStatistics($session)
{
$searchModel = new SearchTestingPassing();
$searchModel = new SearchPassing();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Yii::$app->controller->page_title = 'Список прохождений';
......@@ -131,7 +131,7 @@ class TestingPassingAdminController extends AdminController
return $this->render('statistics', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'session' => TestingSession::findOne($session),
'session' => Session::findOne($session),
]);
}
......@@ -166,7 +166,7 @@ class TestingPassingAdminController extends AdminController
public function actionChangeAnswerStatus($qp_id)
{
$qp = TestingQuestionPassing::findOne($qp_id);
$qp = QuestionPassing::findOne($qp_id);
if ($qp)
{
......@@ -196,7 +196,7 @@ class TestingPassingAdminController extends AdminController
public function actionChangeStatus($user, $test)
{
$tp = TestingPassing::find()->where([
$tp = Passing::find()->where([
'user_id' => $user,
'test_id' => $test
])->one();
......@@ -207,7 +207,7 @@ class TestingPassingAdminController extends AdminController
}
else
{
$tp = new TestingPassing;
$tp = new Passing;
$tp->user_id = $user;
$tp->test_id = $test;
$tp->save();
......@@ -225,7 +225,7 @@ class TestingPassingAdminController extends AdminController
*/
protected function findModel($id)
{
if (($model = TestingPassing::findOne($id)) !== null) {
if (($model = Passing::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
......
......@@ -8,10 +8,10 @@ use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\helpers\ArrayHelper;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\SearchTestingQuestion;
use common\modules\testings\models\Question;
use common\modules\testings\models\SearchQuestion;
class TestingQuestionAdminController extends AdminController
class QuestionAdminController extends AdminController
{
public static function actionsTitles()
{
......@@ -21,7 +21,7 @@ class TestingQuestionAdminController extends AdminController
'Update' => 'Редактирование вопроса',
'Delete' => 'Удаление вопроса',
'Manage' => 'Управление вопросами',
'UpdateAnswer' => 'Изменение ответов'
'Update-answer' => 'Изменение ответов'
);
}
......@@ -46,18 +46,18 @@ class TestingQuestionAdminController extends AdminController
public function actionCreate()
{
$model = new TestingQuestion;
$model = new Question;
Yii::$app->controller->page_title = 'Добавить вопрос';
Yii::$app->controller->breadcrumbs = [
['Список вопросов' => '/testings/testing-question-admin/manage'],
['Список вопросов' => '/testings/question-admin/manage'],
'Добавить вопрос'
];
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['manage']);
} else {
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestingQuestionForm', $model);
$form = new \common\components\BaseForm('/common/modules/testings/forms/QuestionForm', $model);
return $this->render('create', [
'model' => $model,
'form' => $form->out
......@@ -69,7 +69,7 @@ class TestingQuestionAdminController extends AdminController
{
Yii::$app->controller->page_title = 'Редактировать вопрос';
Yii::$app->controller->breadcrumbs = [
['Список вопросов' => '/testings/testing-question-admin/manage'],
['Список вопросов' => '/testings/question-admin/manage'],
'Редактировать вопрос'
];
......@@ -78,7 +78,7 @@ class TestingQuestionAdminController extends AdminController
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['manage']);
} else {
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestingQuestionForm', $model);
$form = new \common\components\BaseForm('/common/modules/testings/forms/QuestionForm', $model);
return $this->render('update', [
'model' => $model,
'form' => $form->out
......@@ -104,7 +104,7 @@ class TestingQuestionAdminController extends AdminController
if(Yii::$app->request->get('test') && !empty($words))
{
$query = TestingQuestion::find();
$query = Question::find();
for ($i = 0; $i < count($words); $i++)
{
......@@ -116,7 +116,7 @@ class TestingQuestionAdminController extends AdminController
$questions = ArrayHelper::map($query->all(), 'id', 'text');
}
$searchModel = new SearchTestingQuestion();
$searchModel = new SearchQuestion();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Yii::$app->controller->page_title = 'Список вопросов';
......@@ -149,13 +149,13 @@ class TestingQuestionAdminController extends AdminController
}
if ((isset($_POST['q'])) && ($_POST['q'] == 'new')) {
$model = new TestingAnswer;
$model = new Answer;
$model->question_id = $id;
echo $id;
}
else {
$model = TestingAnswer::model()->findByPk((int) $id);
$model = Answer::model()->findByPk((int) $id);
if($model === null)
{
......@@ -184,7 +184,7 @@ class TestingQuestionAdminController extends AdminController
*/
protected function findModel($id)
{
if (($model = TestingQuestion::findOne($id)) !== null) {
if (($model = Question::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
......
......@@ -7,9 +7,10 @@ use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\modules\testings\models\SearchTestingSendHistory;
use common\modules\testings\models\SendHistory;
use common\modules\testings\models\SearchSendHistory;
class TestingSendHistoryAdminController extends AdminController
class SendHistoryAdminController extends AdminController
{
public static function actionsTitles()
{
......@@ -21,7 +22,7 @@ class TestingSendHistoryAdminController extends AdminController
public function actionManage($session)
{
$searchModel = new SearchTestingSendHistory();
$searchModel = new SearchSendHistory();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Yii::$app->controller->page_title = 'История отправки дубликатов';
......@@ -98,7 +99,7 @@ class TestingSendHistoryAdminController extends AdminController
*/
protected function findModel($id)
{
if (($model = TestingUser::findOne($id)) !== null) {
if (($model = SendHistory::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
......
......@@ -9,13 +9,13 @@ use yii\filters\VerbFilter;
use yii\web\UploadedFile;
use yii\helpers\Html;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\SearchTestingTest;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\TestingTheme;
use common\modules\testings\models\TestingAnswer;
use common\modules\testings\models\Test;
use common\modules\testings\models\SearchTest;
use common\modules\testings\models\Question;
use common\modules\testings\models\Theme;
use common\modules\testings\models\Answer;
class TestingTestAdminController extends AdminController
class TestAdminController extends AdminController
{
public static function actionsTitles()
{
......@@ -50,18 +50,18 @@ class TestingTestAdminController extends AdminController
public function actionCreate()
{
$model = new TestingTest;
$model = new Test;
Yii::$app->controller->page_title = 'Добавить тест';
Yii::$app->controller->breadcrumbs = [
['Список тестов' => '/testings/testing-test-admin/manage'],
['Список тестов' => '/testings/test-admin/manage'],
'Добавить тест'
];
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['manage']);
} else {
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestingTestForm', $model);
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestForm', $model);
return $this->render('create', [
'model' => $model,
'form' => $form->out
......@@ -74,7 +74,7 @@ class TestingTestAdminController extends AdminController
{
Yii::$app->controller->page_title = 'Редактировать тест';
Yii::$app->controller->breadcrumbs = [
['Список тестов' => '/testings/testing-test-admin/manage'],
['Список тестов' => '/testings/test-admin/manage'],
'Редактировать тест'
];
......@@ -83,7 +83,7 @@ class TestingTestAdminController extends AdminController
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['manage']);
} else {
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestingTestForm', $model);
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestForm', $model);
return $this->render('update', [
'model' => $model,
'form' => $form->out
......@@ -102,7 +102,7 @@ class TestingTestAdminController extends AdminController
public function actionManage()
{
$searchModel = new SearchTestingTest();
$searchModel = new SearchTest();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Yii::$app->controller->page_title = 'Список тестов';
......@@ -118,7 +118,7 @@ class TestingTestAdminController extends AdminController
public function actionImportTests($id)
{
$model = new TestingTest;
$model = new Test;
$model->scenario = 'upload';
......@@ -164,11 +164,11 @@ class TestingTestAdminController extends AdminController
{
$themesCount++;
$theme = TestingTheme::find()->where(['name' => $theme_name])->one();
$theme = Theme::find()->where(['name' => $theme_name])->one();
if(!$theme)
{
$theme = new TestingTheme;
$theme = new Theme;
$theme->name = $theme_name;
}
else
......@@ -185,12 +185,12 @@ class TestingTestAdminController extends AdminController
// создание вопроса
if ($question_name <> '')
{
$question = new TestingQuestion;
$question = new Question;
$question->text = $question_name;
$question->type = $question_type;
$question->test_id = $id;
$question->theme_id = $theme->id;
$question->is_active = TestingQuestion::ACTIVE;
$question->is_active = Question::ACTIVE;
if($question->save())
{
......@@ -203,16 +203,16 @@ class TestingTestAdminController extends AdminController
}
// создание ответа
$answer = new TestingAnswer;
$answer = new Answer;
$answer->text = $answer_name;
if (in_array($answer_isright, TestingAnswer::$xls_rights_list))
if (in_array($answer_isright, Answer::$xls_rights_list))
{
$answer->is_right = TestingAnswer::IS_RIGHT;
$answer->is_right = Answer::IS_RIGHT;
}
else
{
$answer->is_right = TestingAnswer::IS_NOT_RIGHT;
$answer->is_right = Answer::IS_NOT_RIGHT;
}
$answer->question_id = $question->id;
......@@ -224,7 +224,7 @@ class TestingTestAdminController extends AdminController
}
// добавляем отчёт о кол-ве добавленных вопросов и гамм
Yii::$app->session->setFlash('flash', '<i>Всего добавлено <b>' . $questionsCount . '</b> вопросов в <b>' . $themesCount . '</b> темах. Перейти к ' . Html::a('списку загруженных вопросов', ['/testings/testing-question-admin/manage', 'test'=>$model->id]) . '.</i>');
Yii::$app->session->setFlash('flash', '<i>Всего добавлено <b>' . $questionsCount . '</b> вопросов в <b>' . $themesCount . '</b> темах. Перейти к ' . Html::a('списку загруженных вопросов', ['/testings/question-admin/manage', 'test'=>$model->id]) . '.</i>');
$params['log'] = '<p>' . implode('</p><p>', $log) . '</p>';
}
......@@ -253,7 +253,7 @@ class TestingTestAdminController extends AdminController
*/
protected function findModel($id)
{
if (($model = TestingTest::findOne($id)) !== null) {
if (($model = Test::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
......
<?php
class TestingGammaAdminController extends AdminController
{
public static function actionsTitles()
{
return array(
'View' => 'Просмотр гаммы продукции',
'Create' => 'Создание гаммы продукции',
'Update' => 'Редактирование гаммы продукции',
'Delete' => 'Удаление гаммы продукции',
'Manage' => 'Управление гаммами продукции',
);
}
public function actionView($id)
{
$this->render('view', array(
'model' => $this->loadModel($id),
));
}
public function actionCreate()
{
$model = new TestingGamma;
$form = new BaseForm('testings.TestingGammaForm', $model);
// $this->performAjaxValidation($model);
if(isset($_POST['TestingGamma']))
{
$model->attributes = $_POST['TestingGamma'];
if($model->save())
{
$this->redirect(array('manage'));
}
}
$this->render('create', array(
'form' => $form,
));
}
public function actionUpdate($id)
{
$model = $this->loadModel($id);
$form = new BaseForm('testings.TestingGammaForm', $model);
// $this->performAjaxValidation($model);
if(isset($_POST['TestingGamma']))
{
$model->attributes = $_POST['TestingGamma'];
if($model->save())
{
$this->redirect(array('manage'));
}
}
$this->render('update', array(
'form' => $form,
));
}
public function actionDelete($id)
{
if(Yii::app()->request->isPostRequest)
{
$this->loadModel($id)->delete();
if(!isset($_GET['ajax']))
{
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
}
else
{
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
}
public function actionManage()
{
$model=new TestingGamma('search');
$model->unsetAttributes();
if(isset($_GET['TestingGamma']))
{
$model->attributes = $_GET['TestingGamma'];
}
$this->render('manage', array(
'model' => $model,
));
}
public function loadModel($id)
{
$model = TestingGamma::model()->findByPk((int) $id);
if($model === null)
{
$this->pageNotFound();
}
return $model;
}
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax'] === 'testing-gamma-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
<?php
class TestingPassingController extends BaseController
{
public $layout = '/layouts/testing';
public $page_subtitle;
public static function actionsTitles()
{
return array(
'Index' => 'Просмотр прохождения',
'Session' => 'Прохождение сессии',
);
}
public function filters() {
return CMap::mergeArray(parent::filters(), array(
'checkAuth - login',
));
}
public function filterCheckAuth($filterChain) {
$data = explode('.', $_SERVER['SERVER_NAME']);
if(!in_array('www',$data))
$this->redirect('http://www.partnersnet.schneider-electric.ru/testings/testingPassing/');
if (!in_array(Yii::app()->user->role, array('schneider_electric', 'admin'))) {
$this->redirect('/login/');
}
$filterChain->run();
}
public function actionIndex() {
$sessions = TestingSession::model()->findAll();
$user = User::model()->findByPk(Yii::app()->user->id);
$cr = new CDbCriteria;
$cr->with = array('user', 'test');
$name = trim(implode(' ', array($user->last_name, $user->first_name, $user->patronymic)));
//echo $name = 'Алешин Алексей Евгеньевич';
//$cr->addCondition('user.tki = "'.$user->last_name.' '.$user->first_name.' '.$user->patronymic.'"');
$cr->compare('user.tki', $name, true);
//$cr->compare('user.manager_id', Yii::app()->user->id);
//$cr->limit = 300;
$cr->together = true;
$passings = TestingPassing::model()->findAll($cr);
//соотнесем тесты с сессиями
$tests_list = array();
$tests = TestingTest::model()->findAll();
foreach ($tests as $test) {
$tests_list[$test->id] = $test->session_id;
}
$tests = $tests_list;
//отсортируем сдачи тестов по сессиям
$passings_list = array();
foreach ($passings as $p) {
$session_id = $tests[$p->test_id];
$passings_list[$session_id][] = $p;
}
$passings = $passings_list;
$this->render('index', array('sessions' => $sessions, 'passings' => $passings));
}
}
<?php
namespace common\modules\testings\controllers;
use Yii;
use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\modules\testings\models\Theme;
use common\modules\testings\models\SearchTheme;
class ThemeAdminController extends AdminController
{
public static function actionsTitles()
{
return array(
'View' => 'Просмотр темы',
'Create' => 'Создание темы',
'Update' => 'Редактирование темы',
'Delete' => 'Удаление темы',
'Manage' => 'Управление темами',
);
}
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
public function actionCreate()
{
$model = new Theme;
Yii::$app->controller->page_title = 'Добавить тему';
Yii::$app->controller->breadcrumbs = [
['Список тем' => '/testings/theme-admin/manage'],
'Добавить тему'
];
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['manage']);
} else {
$form = new \common\components\BaseForm('/common/modules/testings/forms/ThemeForm', $model);
return $this->render('create', [
'model' => $model,
'form' => $form->out
]);
}
}
public function actionUpdate($id)
{
Yii::$app->controller->page_title = 'Редактировать тему';
Yii::$app->controller->breadcrumbs = [
['Список тем' => '/testings/theme-admin/manage'],
'Редактировать тему'
];
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['manage']);
} else {
$form = new \common\components\BaseForm('/common/modules/testings/forms/ThemeForm', $model);
return $this->render('update', [
'model' => $model,
'form' => $form->out
]);
}
}
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['manage']);
}
public function actionManage()
{
$searchModel = new SearchTheme();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Yii::$app->controller->page_title = 'Список тем';
Yii::$app->controller->breadcrumbs = [
'Список тем',
];
return $this->render('manage', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Finds the Faq model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Faq the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Theme::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
......@@ -9,11 +9,11 @@ use yii\filters\VerbFilter;
use common\modules\testings\components\MarkBoxBehavior;
use common\modules\testings\models\TestingUser;
use common\modules\testings\models\SearchTestingUser;
use common\modules\testings\models\SearchTestingUserGroup;
use common\modules\testings\models\User;
use common\modules\testings\models\SearchUser;
use common\modules\testings\models\SearchUserGroup;
class TestingUserAdminController extends AdminController
class UserAdminController extends AdminController
{
public static function actionsTitles()
{
......@@ -64,11 +64,11 @@ class TestingUserAdminController extends AdminController
public function actionCreate()
{
$model = new TestingUser;
$model = new User;
Yii::$app->controller->page_title = 'Добавить пользователя';
Yii::$app->controller->breadcrumbs = [
['Список пользователей' => '/testings/testing-user-admin/manage'],
['Список пользователей' => '/testings/user-admin/manage'],
'Добавить пользователя'
];
......@@ -86,7 +86,7 @@ class TestingUserAdminController extends AdminController
}
}
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestingUserForm', $model);
$form = new \common\components\BaseForm('/common/modules/testings/forms/UserForm', $model);
return $this->render('create', [
'model' => $model,
'form' => $form->out
......@@ -98,7 +98,7 @@ class TestingUserAdminController extends AdminController
{
Yii::$app->controller->page_title = 'Редактировать пользователя';
Yii::$app->controller->breadcrumbs = [
['Список пользователей' => '/testings/testing-user-admin/manage'],
['Список пользователей' => '/testings/user-admin/manage'],
'Редактировать пользователя'
];
......@@ -115,7 +115,7 @@ class TestingUserAdminController extends AdminController
}
}
$form = new \common\components\BaseForm('/common/modules/testings/forms/TestingAnswerForm', $model);
$form = new \common\components\BaseForm('/common/modules/testings/forms/AnswerForm', $model);
return $this->render('update', [
'model' => $model,
'form' => $form->out
......@@ -133,7 +133,7 @@ class TestingUserAdminController extends AdminController
public function actionManage()
{
$searchModel = new SearchTestingUser();
$searchModel = new SearchUser();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Yii::$app->controller->page_title = 'Список назначений тестов пользователям';
......@@ -149,7 +149,7 @@ class TestingUserAdminController extends AdminController
public function actionManageGroup()
{
$searchModel = new SearchTestingUserGroup();
$searchModel = new SearchUserGroup();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
Yii::$app->controller->page_title = 'Список групп';
......@@ -172,7 +172,7 @@ class TestingUserAdminController extends AdminController
*/
protected function findModel($id)
{
if (($model = TestingUser::findOne($id)) !== null) {
if (($model = User::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
......
CREATE TABLE IF NOT EXISTS `bulkmail_accounts` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`server` varchar(50) NOT NULL COMMENT ' ',
`port` int(10) unsigned NOT NULL COMMENT ' ',
`email` varchar(50) NOT NULL COMMENT 'E-mail ',
`username` varchar(50) NOT NULL COMMENT ' ',
`password` varchar(50) NOT NULL COMMENT ' ',
`create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' ',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `bulkmail_queue` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`emailTo` varchar(100) NOT NULL COMMENT 'Email ',
`subject` varchar(250) NOT NULL COMMENT ' ',
`body` text NOT NULL COMMENT ' ',
`create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' ',
`send_date` timestamp NULL DEFAULT NULL COMMENT ' ',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `bulkmail_state` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`date_last` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' ',
`qtyTotal` int(11) NOT NULL COMMENT ' ',
`qtyMod` float NOT NULL COMMENT ' ',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
INSERT INTO `settings` (`id`, `module_id`, `code`, `name`, `value`, `element`, `hidden`) VALUES
(39, 'testings', 'bulkmail_letters_per_hour', 'Количество отправляемых писем за 1 час', '40', 'text', 0),
(40, 'testings', 'bulkmail_cron_period', 'Период срабатывания CRON', '2', 'text', 0);
-- phpMyAdmin SQL Dump
-- version 3.3.7
-- http://www.phpmyadmin.net
--
-- : localhost
-- : 11 2011 ., 20:50
-- : 5.1.49
-- PHP: 5.3.3-1ubuntu9.5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- : `schneider-electric`
--
-- --------------------------------------------------------
--
-- `testings`
--
CREATE TABLE IF NOT EXISTS `testings` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(150) NOT NULL COMMENT '',
`minutes` tinyint(4) NOT NULL COMMENT ' ( )',
`percentage_passing` tinyint(4) NOT NULL COMMENT ' ( )',
`questions_count` tinyint(4) NOT NULL COMMENT ' ( )',
`date_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`date_update` datetime DEFAULT NULL COMMENT '',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- `testings`
--
-- --------------------------------------------------------
--
-- `testings_answers`
--
CREATE TABLE IF NOT EXISTS `testings_answers` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`question_id` int(11) unsigned NOT NULL COMMENT '',
`text` text NOT NULL COMMENT '',
`is_correct` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '',
`date_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`date_update` datetime NOT NULL COMMENT '',
PRIMARY KEY (`id`),
KEY `question_id` (`question_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- `testings_answers`
--
-- --------------------------------------------------------
--
-- `testings_questions`
--
CREATE TABLE IF NOT EXISTS `testings_questions` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`section_id` int(11) unsigned DEFAULT NULL COMMENT '',
`difficulty` enum('hard','easy') NOT NULL COMMENT '',
`type` enum('one_option','several_options','own_version') NOT NULL COMMENT ' ',
`text` text NOT NULL COMMENT '',
`image` varchar(37) DEFAULT NULL COMMENT '',
`is_active` tinyint(1) NOT NULL DEFAULT '0' COMMENT '',
`date_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`date_update` datetime NOT NULL COMMENT '',
PRIMARY KEY (`id`),
KEY `section_id` (`section_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- `testings_questions`
--
-- --------------------------------------------------------
--
-- `testings_sections`
--
CREATE TABLE IF NOT EXISTS `testings_sections` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`parent_id` int(11) unsigned DEFAULT NULL COMMENT '',
`name` varchar(150) NOT NULL COMMENT '',
`is_active` tinyint(1) NOT NULL COMMENT '',
`date_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
`date_update` datetime NOT NULL COMMENT '',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `parent_id` (`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- `testings_sections`
--
--
--
--
--
-- `testings_answers`
--
ALTER TABLE `testings_answers`
ADD CONSTRAINT `testings_answers_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `testings_questions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- `testings_questions`
--
ALTER TABLE `testings_questions`
ADD CONSTRAINT `testings_questions_ibfk_1` FOREIGN KEY (`section_id`) REFERENCES `testings_sections` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- `testings_sections`
--
ALTER TABLE `testings_sections`
ADD CONSTRAINT `testings_sections_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `testings_sections` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
This diff is collapsed.
<?xml version="1.0" encoding="utf-8" ?>
<!--
-
- phpMyAdmin XML Dump
- version 2.11.10
- http://www.phpmyadmin.net
-
- Хост: localhost
- Время создания: Окт 12 2011 г., 21:06
- Версия сервера: 5.0.37
- Версия PHP: 5.2.5
-->
<!--
- База данных: 'partners_schneider'
-->
<partners_schneider>
<!-- Таблица gammas -->
<gammas>
<theme_id>1</theme_id>
<gamma_name>Кабеленесущие системы Thorsman, Wibe, Stago, Schneider Electric</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>1</gamma_id>
</gammas>
<gammas>
<theme_id>1</theme_id>
<gamma_name>Низковольтные шкафы Prisma Plus и Prisma Pack</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>2</gamma_id>
</gammas>
<gammas>
<theme_id>1</theme_id>
<gamma_name>Автоматические выключатели, УЗО и Дифференциальные автоматы серии Домовой</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>3</gamma_id>
</gammas>
<gammas>
<theme_id>2</theme_id>
<gamma_name>Мини-контроллеры</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>4</gamma_id>
</gammas>
<gammas>
<theme_id>2</theme_id>
<gamma_name>Вспомогательное оборудование автоматизации</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>5</gamma_id>
</gammas>
<gammas>
<theme_id>2</theme_id>
<gamma_name>Компактные панели оператора Magelis</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>6</gamma_id>
</gammas>
<gammas>
<theme_id>2</theme_id>
<gamma_name>Шкафы Spacial</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>7</gamma_id>
</gammas>
<gammas>
<theme_id>2</theme_id>
<gamma_name>Датчики гаммы Global Detection</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>8</gamma_id>
</gammas>
<gammas>
<theme_id>2</theme_id>
<gamma_name>Кнопки</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>9</gamma_id>
</gammas>
<gammas>
<theme_id>1</theme_id>
<gamma_name>Устройства контроля и управления гамм Acti 9, Multi 9</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>10</gamma_id>
</gammas>
<gammas>
<theme_id>1</theme_id>
<gamma_name>Автоматические выключатели, УЗО, щитки гамм Acti 9, Multi 9</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>11</gamma_id>
</gammas>
<gammas>
<theme_id>2</theme_id>
<gamma_name>ATV, ATS</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>12</gamma_id>
</gammas>
<gammas>
<theme_id>1</theme_id>
<gamma_name>Автоматические выключатели Masterpact</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>13</gamma_id>
</gammas>
<gammas>
<theme_id>1</theme_id>
<gamma_name>Автоматические выключатели Compact и выключатели-разъединители Interpact</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>14</gamma_id>
</gammas>
<gammas>
<theme_id>2</theme_id>
<gamma_name>Контакторы</gamma_name>
<gamma_act>1</gamma_act>
<gamma_date></gamma_date>
<gamma_utime>0</gamma_utime>
<gamma_id>15</gamma_id>
</gammas>
</partners_schneider>
<?php
use yii\helpers\ArrayHelper;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\TestingAnswer;
use common\modules\testings\models\Question;
use common\modules\testings\models\Answer;
$elements = [
'question_id' => [
'type' => 'dropdownlist',
'items' => ArrayHelper::map(TestingQuestion::find()->all(), 'id', 'text', 'test.name'),
'items' => ArrayHelper::map(Question::find()->all(), 'id', 'text', 'test.name'),
],
'text' => ['type' => 'textarea'],
'is_right' => [
'type' => 'dropdownlist',
'items' => TestingAnswer::$type_list,
'items' => Answer::$type_list,
],
];
......
<?php
use yii\helpers\ArrayHelper;
use common\modules\testings\models\User;
use common\modules\testings\models\Test;
return [
'activeForm'=>[
'id' => 'testing-answer-form',
],
'elements' => [
'user_id' => [
'type' => 'dropdownlist',
'items' => ArrayHelper::map(Question::find()->all(), 'id', 'fio'),
],
'user_id' => [
'type' => 'dropdownlist',
'items' => ArrayHelper::map(Test::find()->all(), 'id','name', 'session.name'),
],
],
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Cохранить']
]
];
<?php
use yii\helpers\ArrayHelper;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\TestingTheme;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\Test;
use common\modules\testings\models\Theme;
use common\modules\testings\models\Question;
$elements = [
'test_id' => [
'type' => 'dropdownlist',
'items' => ArrayHelper::map(TestingTest::find()->all(), 'id', 'name', 'session.name'),
'items' => ArrayHelper::map(Test::find()->all(), 'id', 'name', 'session.name'),
],
'theme_id' => [
'type' => 'dropdownlist',
'items' => ArrayHelper::map(TestingTheme::find()->all(), 'id', 'name'),
'items' => ArrayHelper::map(Theme::find()->all(), 'id', 'name'),
],
'text' => ['type' => 'textarea'],
'is_active' => [
'type' => 'dropdownlist',
'items' => TestingQuestion::$active_list,
'items' => Question::$active_list,
],
'type' => [
'type' => 'dropdownlist',
'items' => TestingQuestion::$type_list,
'items' => Question::$type_list,
],
// 'files' => [
// 'type' => 'file_manager',
......
<?php
use yii\helpers\ArrayHelper;
use common\modules\testings\models\TestingSession;
use common\modules\testings\models\Session;
$elements = [
'session_id' => [
'type' => 'dropdownlist',
'items' => ArrayHelper::map(TestingSession::find()->all(), 'id', 'name'),
'items' => ArrayHelper::map(Session::find()->all(), 'id', 'name'),
],
'name' => ['type' => 'text'],
'minutes' => ['type' => 'text'],
......
<?php
return array(
'activeForm' => array(
'id' => 'testing-faq-form',
),
'elements' => array(
'title' => array('type' => 'text'),
'url' => array('type' => 'text'),
'content' => array('type' => 'editor'),
),
'buttons' => array(
'submit' => array(
'type' => 'submit',
'value' => $this->model->isNewRecord ? 'создать' : 'сохранить',
),
),
);
<?php
return array(
'activeForm' => array(
'id' => 'testing-gamma-form',
//'enableAjaxValidation' => true,
//'clientOptions' => array(
// 'validateOnSubmit' => true,
// 'validateOnChange' => true
//)
),
'elements' => array(
'name' => array('type' => 'text'),
'type' => array(
'type' => 'dropdownlist',
'items' => TestingGamma::$type_list,
),
),
'buttons' => array(
'submit' => array(
'type' => 'submit',
'value' => $this->model->isNewRecord ? 'создать' : 'сохранить')
)
);
<?php
return array(
'activeForm' => array(
'id' => 'testing-passing-form',
//'enableAjaxValidation' => true,
//'clientOptions' => array(
// 'validateOnSubmit' => true,
// 'validateOnChange' => true
//)
),
'elements' => array(
'user_id' => array(
'type' => 'dropdownlist',
'items' => CHtml::listData(TestingUser::model()->findAll(),'id','fio'),
),
'test_id' => array(
'type' => 'dropdownlist',
'items' => CHtml::listData(TestingTest::model()->findAll(),'id','name','session.name'),
),
//'is_passed' => array('type' => 'checkbox'),
//'pass_date' => array('type' => 'text'),
),
'buttons' => array(
'submit' => array(
'type' => 'submit',
'value' => $this->model->isNewRecord ? 'создать' : 'сохранить')
)
);
<?php
return array(
'activeForm' => array(
'id' => 'testing-user-form',
//'enableAjaxValidation' => true,
//'clientOptions' => array(
// 'validateOnSubmit' => true,
// 'validateOnChange' => true
//)
),
'elements' => array(
'sex' => array(
'type' => 'dropdownlist',
'items' => TestingUser::$sex_list
),
'last_name' => array('type' => 'text'),
'first_name' => array('type' => 'text'),
'patronymic' => array('type' => 'text'),
'company_name' => array('type' => 'text'),
'city' => array('type' => 'text'),
'email' => array('type' => 'text'),
'tki' => array('type' => 'text'),
'region' => array('type' => 'text'),
),
'buttons' => array(
'submit' => array(
'type' => 'submit',
'value' => $this->model->isNewRecord ? 'создать' : 'сохранить')
)
);
<?php
return [
'activeForm'=>[
'id' => 'testing-theme-form',
],
'elements' => [
'name' => ['type' => 'text'],
],
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Cохранить']
]
];
<?php
return [
'activeForm'=>[
'id' => 'testing-user-form',
],
'elements' => [
'sex' => []
'type' => 'dropdownlist',
'items' => User::$sex_list
],
'last_name' => ['type' => 'text'],
'first_name' => ['type' => 'text'],
'patronymic' => ['type' => 'text'],
'company_name' => ['type' => 'text'],
'city' => ['type' => 'text'],
'email' => ['type' => 'text'],
'tki' => ['type' => 'text'],
'region' => ['type' => 'text'],
],
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Cохранить']
]
];
......@@ -6,9 +6,9 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\Question;
class TestingAnswer extends \common\components\ActiveRecordModel
class Answer extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......@@ -68,6 +68,6 @@ class TestingAnswer extends \common\components\ActiveRecordModel
public function getQuestion()
{
return $this->hasOne(TestingQuestion::className(), ['id' => 'question_id']);
return $this->hasOne(Question::className(), ['id' => 'question_id']);
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
class TestingMistake extends \common\components\ActiveRecordModel
class Mistake extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......@@ -62,7 +62,7 @@ class TestingMistake extends \common\components\ActiveRecordModel
public function getPassing()
{
return $this->hasOne(TestingPassing::className(), ['id' => 'passing_id']);
return $this->hasOne(Passing::className(), ['id' => 'passing_id']);
}
// public function getFiles()
......
......@@ -6,9 +6,9 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use common\modules\testings\models\TestingUser;
use common\modules\testings\models\User;
class TestingPassing extends \common\components\ActiveRecordModel
class Passing extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......@@ -91,22 +91,22 @@ class TestingPassing extends \common\components\ActiveRecordModel
public function getMistake()
{
return $this->hasOne(TestingMistake::className(), ['passing_id' => 'id']);
return $this->hasOne(Mistake::className(), ['passing_id' => 'id']);
}
public function getTest()
{
return $this->hasOne(TestingTest::className(), ['id' => 'test_id']);
return $this->hasOne(Test::className(), ['id' => 'test_id']);
}
public function getUser()
{
return $this->hasOne(TestingUser::className(), ['id' => 'user_id']);
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
public function getQuestions()
{
return $this->hasMany(TestingQuestionPassing::className(), ['passing_id' => 'id']);
return $this->hasMany(QuestionPassing::className(), ['passing_id' => 'id']);
}
public function getCountPassedQuestions()
......@@ -303,7 +303,7 @@ FROM LEFT( pass_date, 10 ) ) ) , "-", LEFT( pass_date, 2 ) )';
public function getStatus()
{
$user = TestingUser::findOne($this->user_id);
$user = User::findOne($this->user_id);
if ((strtotime($user->create_date) > mktime(0,0,0,6,5,2014)) && ($user->is_auth == 0))
{
......
......@@ -6,12 +6,12 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use common\modules\testings\models\TestingAnswer;
use common\modules\testings\models\TestingTheme;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\TestingQuestionPassing;
use common\modules\testings\models\Answer;
use common\modules\testings\models\Theme;
use common\modules\testings\models\Test;
use common\modules\testings\models\QuestionPassing;
class TestingQuestion extends \common\components\ActiveRecordModel
class Question extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......@@ -85,22 +85,22 @@ class TestingQuestion extends \common\components\ActiveRecordModel
public function getAnswers()
{
return $this->hasMany(TestingAnswer::className(), ['question_id' => 'id']);
return $this->hasMany(Answer::className(), ['question_id' => 'id']);
}
public function getTheme()
{
return $this->hasOne(TestingTheme::className(), ['id' => 'theme_id']);
return $this->hasOne(Theme::className(), ['id' => 'theme_id']);
}
public function getTest()
{
return $this->hasOne(TestingTest::className(), ['id' => 'test_id']);
return $this->hasOne(Test::className(), ['id' => 'test_id']);
}
public function getPassings()
{
return $this->hasMany(TestingQuestionPassing::className(), ['question_id' => 'id']);
return $this->hasMany(QuestionPassing::className(), ['question_id' => 'id']);
}
public function getFiles()
......@@ -113,7 +113,7 @@ class TestingQuestion extends \common\components\ActiveRecordModel
public function getRightAnswer()
{
$query = TestingAnswer::find()->where(['question_id' => $this->id]);
$query = Answer::find()->where(['question_id' => $this->id]);
switch ($this->type)
{
......@@ -168,6 +168,6 @@ class TestingQuestion extends \common\components\ActiveRecordModel
public static function getThemesList()
{
return \yii\helpers\ArrayHelper::map(TestingTheme::find()->all(), 'id', 'name');
return \yii\helpers\ArrayHelper::map(Theme::find()->all(), 'id', 'name');
}
}
......@@ -6,10 +6,10 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\TestingPassing;
use common\modules\testings\models\Question;
use common\modules\testings\models\Passing;
class TestingQuestionPassing extends \common\components\ActiveRecordModel
class QuestionPassing extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......@@ -67,12 +67,12 @@ class TestingQuestionPassing extends \common\components\ActiveRecordModel
public function getQuestion()
{
return $this->hasOne(TestingQuestion::className(), ['id' => 'question_id']);
return $this->hasOne(Question::className(), ['id' => 'question_id']);
}
public function getPassing()
{
return $this->hasOne(TestingPassing::className(), ['passing_id' => 'id']);
return $this->hasOne(Passing::className(), ['passing_id' => 'id']);
}
public function search($passing = null)
......@@ -101,17 +101,17 @@ class TestingQuestionPassing extends \common\components\ActiveRecordModel
switch ($this->question->type)
{
case TestingQuestion::ONE_OPTION:
case Question::ONE_OPTION:
$right = (trim($this->answer_text) == trim($this->user_answer));
break;
case TestingQuestion::FEW_OPTIONS:
$arr = explode(TestingQuestion::DELIMITER, $this->answer_text);
case Question::FEW_OPTIONS:
$arr = explode(Question::DELIMITER, $this->answer_text);
foreach ($arr as $index => $item)
{
$arr[$index] = trim(preg_replace('/\s+/', ' ', mb_strtolower($item)));
}
$arr2 = explode(TestingQuestion::DELIMITER, $this->user_answer);
$arr2 = explode(Question::DELIMITER, $this->user_answer);
foreach ($arr2 as $index => $item)
{
$arr2[$index] = trim(preg_replace('/\s+/', ' ', mb_strtolower($item)));
......@@ -121,7 +121,7 @@ class TestingQuestionPassing extends \common\components\ActiveRecordModel
$right = ($arr == $arr2); // TRUE в случае, если $a и $b содержат одни и те же элементы
break;
case TestingQuestion::USER_ANSWER:
case Question::USER_ANSWER:
$opt1 = str_replace(';', ',', preg_replace('/\s+/', '', mb_strtolower($this->answer_text)));
$opt2 = str_replace(';', ',', preg_replace('/\s+/', '', mb_strtolower($this->user_answer)));
$right = (trim($opt1) == trim($opt2));
......
......@@ -6,9 +6,9 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\TestingAnswer;
use common\modules\testings\models\Answer;
class SearchTestingAnswer extends TestingAnswer
class SearchAnswer extends Answer
{
/**
* @inheritdoc
......@@ -39,7 +39,7 @@ class SearchTestingAnswer extends TestingAnswer
*/
public function search($params, $order = null, $limit = null)
{
$query = TestingAnswer::find();
$query = Answer::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
......
......@@ -7,12 +7,12 @@ use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use common\modules\testings\models\TestingPassing;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\TestingUser;
use common\modules\testings\models\TestingMistake;
use common\modules\testings\models\Passing;
use common\modules\testings\models\Test;
use common\modules\testings\models\User;
use common\modules\testings\models\Mistake;
class SearchTestingPassing extends TestingPassing
class SearchPassing extends Passing
{
public $filter_user_email;
public $filter_user_company_name;
......@@ -47,7 +47,7 @@ class SearchTestingPassing extends TestingPassing
*/
public function search($params, $order = null, $limit = null)
{
$query = TestingPassing::find();
$query = Passing::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
......@@ -72,7 +72,7 @@ class SearchTestingPassing extends TestingPassing
public function query($params, $order = null, $limit = null)
{
$query = TestingPassing::find();
$query = Passing::find();
$with = ['test' => true];
......@@ -81,28 +81,28 @@ class SearchTestingPassing extends TestingPassing
'user_id' => $this->user_id,
'test_id' => $this->test_id,
'create_date' => $this->create_date,
TestingTest::tableName() . '.session_id' => Yii::$app->request->get('session'),
Test::tableName() . '.session_id' => Yii::$app->request->get('session'),
]);
if($this->filter_user_email)
{
$with['user'] = true;
$query->andFilterWhere(['like', TestingUser::tableName() . '.email', $this->filter_user_email]);
$query->andFilterWhere(['like', User::tableName() . '.email', $this->filter_user_email]);
}
if($this->filter_user_company_name)
{
$with['user'] = true;
$query->andFilterWhere(['like', TestingUser::tableName() . '.company_name', $this->filter_user_company_name]);
$query->andFilterWhere(['like', User::tableName() . '.company_name', $this->filter_user_company_name]);
}
if($this->filter_user_last_name)
{
$with['user'] = true;
$query->andFilterWhere(['like', TestingUser::tableName() . '.last_name', $this->filter_user_last_name]);
$query->andFilterWhere(['like', User::tableName() . '.last_name', $this->filter_user_last_name]);
}
// $tpassing = Yii::app()->request->getQuery('TestingPassing');
// $tpassing = Yii::app()->request->getQuery('Passing');
// $pass_date = 'CONCAT( RIGHT( LEFT( pass_date, 10 ) , 4 ) , "-", TRIM(
// TRAILING CONCAT( ".", SUBSTRING_INDEX( LEFT( pass_date, 10 ) , ".", -1 ) )
......@@ -123,47 +123,47 @@ class SearchTestingPassing extends TestingPassing
// switch ($this->is_passed)
// {
// case TestingPassing::AUTH:
// case Passing::AUTH:
// $with['user'] = true;
// $query->andFilterWhere(['>', 'ser.create_date', '2014-06-05 00:00:00']);
// $query->andFilterWhere([TestingUser::tableName() . '.is_auth' => 0]);
// $query->andFilterWhere([User::tableName() . '.is_auth' => 0]);
// break;
// case TestingPassing::STARTED:
// case Passing::STARTED:
// $query->andFilterWhere([
// 'is_passed' => 0,
// 'pass_date' => null,
// TestingMistake::tableName() . '.passing_id' => null
// Mistake::tableName() . '.passing_id' => null
// ]);
// break;
// case TestingPassing::MISTAKE:
// case Passing::MISTAKE:
// $with['mistake'] = true;
// $query->andFilterWhere(['=', TestingMistake::tableName() . '.passing_id', 'id']);
// $query->andFilterWhere(['=', Mistake::tableName() . '.passing_id', 'id']);
// break;
// case TestingPassing::PASSED:
// case Passing::PASSED:
// $with['mistake'] = true;
// $query->andFilterWhere([
// 'is_passed' => 1,
// TestingMistake::tableName() . '.passing_id' => null
// Mistake::tableName() . '.passing_id' => null
// ]);
// break;
// case TestingPassing::FAILED:
// case Passing::FAILED:
// $with['mistake'] = true;
// $query->andFilterWhere([
// 'is_passed' => 0,
// TestingMistake::tableName() . '.passing_id' => null
// Mistake::tableName() . '.passing_id' => null
// ]);
// $query->andFilterWhere(['not', 'pass_date', null]);
// break;
// case TestingPassing::NOT_STARTED:
// case Passing::NOT_STARTED:
// $with['mistake'] = true;
// $query->andFilterWhere([
// 'is_passed' => null,
// TestingMistake::tableName() . '.passing_id' => null
// Mistake::tableName() . '.passing_id' => null
// ]);
// break;
// }
......
......@@ -6,9 +6,9 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\Question;
class SearchTestingQuestion extends TestingQuestion
class SearchQuestion extends Question
{
/**
* @inheritdoc
......@@ -39,7 +39,7 @@ class SearchTestingQuestion extends TestingQuestion
*/
public function search($params, $order = null, $limit = null)
{
$query = TestingQuestion::find();
$query = Question::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
......
......@@ -6,9 +6,9 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\TestingQuestionPassing;
use common\modules\testings\models\QuestionPassing;
class SearchTestingQuestionPassing extends TestingQuestionPassing
class SearchQuestionPassing extends QuestionPassing
{
/**
* @inheritdoc
......@@ -39,7 +39,7 @@ class SearchTestingQuestionPassing extends TestingQuestionPassing
*/
public function search($params, $order = null, $limit = null, $passing_id = null)
{
$query = TestingQuestionPassing::find();
$query = QuestionPassing::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
......
......@@ -6,9 +6,9 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\TestingSendHistory;
use common\modules\testings\models\SendHistory;
class SearchTestingSendHistory extends TestingSendHistory
class SearchSendHistory extends SendHistory
{
/**
* @inheritdoc
......@@ -39,7 +39,7 @@ class SearchTestingSendHistory extends TestingSendHistory
*/
public function search($params, $order = null, $limit = null)
{
$query = TestingSendHistory::find();
$query = SendHistory::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
......
......@@ -6,9 +6,9 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\TestingSession;
use common\modules\testings\models\Session;
class SearchTestingSession extends TestingSession
class SearchSession extends Session
{
/**
* @inheritdoc
......@@ -39,7 +39,7 @@ class SearchTestingSession extends TestingSession
*/
public function search($params, $order = null, $limit = null)
{
$query = TestingSession::find();
$query = Session::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
......
......@@ -6,9 +6,9 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\Test;
class SearchTestingTest extends TestingTest
class SearchTest extends Test
{
/**
* @inheritdoc
......@@ -39,7 +39,7 @@ class SearchTestingTest extends TestingTest
*/
public function search($params, $order = null, $limit = null)
{
$query = TestingTest::find();
$query = Test::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
......
<?php
namespace common\modules\testings\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\Theme;
use common\modules\testings\models\Question;
class SearchTheme extends Theme
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'name'], '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, $order = null, $limit = null)
{
$query = Theme::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => ['pageSize' => self::PAGE_SIZE],
'sort'=>array(
'defaultOrder'=>'create_date DESC',
),
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'type' => $this->type,
]);
$query->andFilterWhere(['like', 'name', $this->name]);
if (Yii::$app->request->get('test'))
{
$query->joinWith(['questions']);
$query->groupBy(['id']);
$query->andWhere([Question::tableName() . '.test_id' => Yii::$app->request->get('test')]);
}
if(!empty($order))
$query->orderBy($order);
if(!empty($limit))
$query->limit($limit);
return $dataProvider;
}
}
\ No newline at end of file
......@@ -6,12 +6,12 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\TestingUser;
use common\modules\testings\models\TestingUserGroup;
use common\modules\testings\models\TestingSendHistory;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\User;
use common\modules\testings\models\UserGroup;
use common\modules\testings\models\SendHistory;
use common\modules\testings\models\Test;
class SearchTestingUser extends TestingUser
class SearchUser extends User
{
public $filter_group_id;
public $filter_history_status;
......@@ -42,7 +42,7 @@ class SearchTestingUser extends TestingUser
*/
public function search($params, $order = null, $limit = null)
{
$query = TestingUser::find();
$query = User::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
......@@ -77,7 +77,7 @@ class SearchTestingUser extends TestingUser
$with = ['passings.test'];
$query->groupBy([TestingUser::tableName() . '.id']);
$query->groupBy([User::tableName() . '.id']);
if($this->filter_group_id || Yii::$app->request->get('group'))
{
......@@ -86,14 +86,14 @@ class SearchTestingUser extends TestingUser
if($this->filter_group_id)
{
$query->andFilterWhere([
TestingUserGroup::tableName() . '.id' => $this->filter_group_id,
UserGroup::tableName() . '.id' => $this->filter_group_id,
]);
}
if(Yii::$app->request->get('group'))
{
$query->andFilterWhere([
TestingUserGroup::tableName() . '.id' => Yii::$app->request->get('group')
UserGroup::tableName() . '.id' => Yii::$app->request->get('group')
]);
}
}
......@@ -102,14 +102,14 @@ class SearchTestingUser extends TestingUser
{
$with[] = 'history';
$query->andFilterWhere([
TestingSendHistory::tableName() . '.unisender_status' => $this->filter_history_status
SendHistory::tableName() . '.unisender_status' => $this->filter_history_status
]);
}
if (Yii::$app->request->get('session'))
{
$query->andFilterWhere([
TestingTest::tableName() . '.session_id' => Yii::$app->request->get('session')
Test::tableName() . '.session_id' => Yii::$app->request->get('session')
]);
}
......
......@@ -6,9 +6,9 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\testings\models\TestingUserGroup;
use common\modules\testings\models\UserGroup;
class SearchTestingUserGroup extends TestingUserGroup
class SearchUserGroup extends UserGroup
{
/**
* @inheritdoc
......@@ -39,7 +39,7 @@ class SearchTestingUserGroup extends TestingUserGroup
*/
public function search($params, $order = null, $limit = null)
{
$query = TestingUserGroup::find();
$query = UserGroup::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
......
......@@ -7,7 +7,7 @@ use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use yii\helpers\Url;
class TestingSendHistory extends \common\components\ActiveRecordModel
class SendHistory extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......@@ -86,12 +86,12 @@ class TestingSendHistory extends \common\components\ActiveRecordModel
public function getUser()
{
return $this->hasOne(TestingUser::className(), ['id' => 'user_id']);
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
public function getSession()
{
return $this->hasOne(TestingSession::className(), ['id' => 'session_id']);
return $this->hasOne(Session::className(), ['id' => 'session_id']);
}
public function attributeLabels()
......@@ -163,7 +163,7 @@ class TestingSendHistory extends \common\components\ActiveRecordModel
public function generateFile($users, $session_id)
{
$path = Yii::getPathOfAlias('webroot') . TestingSendHistory::FOLDER_PATH;
$path = Yii::getPathOfAlias('webroot') . SendHistory::FOLDER_PATH;
mkdir($path, 0777, true);
$filename = 'spisok_dostupov_k_testirovaniyu_' . date('Y-m-d_His') . '_' . uniqid() . '.xlsx';
......@@ -177,7 +177,7 @@ class TestingSendHistory extends \common\components\ActiveRecordModel
$sheet = $objPHPExcel->getActiveSheet();
$session = TestingSession::model()->findByPK($session_id);
$session = Session::model()->findByPK($session_id);
$info = "Список доступов сотрудников к сессии ".$session->name."
Указанная почта: ".$users[0]->email."
......
......@@ -6,12 +6,12 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\TestingUser;
use common\modules\testings\models\TestingPassing;
use common\modules\testings\models\TestingUserGroup;
use common\modules\testings\models\Test;
use common\modules\testings\models\User;
use common\modules\testings\models\Passing;
use common\modules\testings\models\UserGroup;
class TestingSession extends \common\components\ActiveRecordModel
class Session extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......@@ -68,12 +68,12 @@ class TestingSession extends \common\components\ActiveRecordModel
public function getTests()
{
return $this->hasMany(TestingTest::className(), ['session_id' => 'id']);
return $this->hasMany(Test::className(), ['session_id' => 'id']);
}
public function getGroups()
{
return $this->hasMany(TestingUserGroup::className(), ['session_id' => 'id']);
return $this->hasMany(UserGroup::className(), ['session_id' => 'id']);
}
public function attributeLabels()
......@@ -89,10 +89,10 @@ class TestingSession extends \common\components\ActiveRecordModel
public function getUsersOverall()
{
$query = TestingPassing::find()->joinWith('test');
$query = Passing::find()->joinWith('test');
$query->andWhere([
TestingTest::tableName() . '.session_id' => $this->id,
Test::tableName() . '.session_id' => $this->id,
]);
$query->groupBy(['user_id', 'test_id']);
......@@ -102,11 +102,11 @@ class TestingSession extends \common\components\ActiveRecordModel
public function getUsersPassed()
{
$query = TestingPassing::find()->joinWith('test');
$query = Passing::find()->joinWith('test');
$query->andWhere([
TestingTest::tableName() . '.session_id' => $this->id,
'is_passed' => TestingPassing::PASSED,
Test::tableName() . '.session_id' => $this->id,
'is_passed' => Passing::PASSED,
]);
$query->groupBy(['user_id', 'test_id']);
......@@ -147,10 +147,10 @@ class TestingSession extends \common\components\ActiveRecordModel
public function getUsers()
{
$query = TestingUser::find()->joinWith('passings.test');
$query = User::find()->joinWith('passings.test');
$query->andWhere([
TestingTest::tableName() . '.session_id' => $this->id,
Test::tableName() . '.session_id' => $this->id,
]);
$query->groupBy(['t.id']);
......
......@@ -7,11 +7,11 @@ use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use yii\helpers\ArrayHelper;
use common\modules\testings\models\TestingPassing;
use common\modules\testings\models\TestingSession;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\Passing;
use common\modules\testings\models\Session;
use common\modules\testings\models\Question;
class TestingTest extends \common\components\ActiveRecordModel
class Test extends \common\components\ActiveRecordModel
{
const SCENARIO_UPLOAD = 'upload';
......@@ -90,51 +90,19 @@ class TestingTest extends \common\components\ActiveRecordModel
public function getPassings()
{
return $this->hasMany(TestingPassing::className(), ['test_id' => 'id']);
return $this->hasMany(Passing::className(), ['test_id' => 'id']);
}
public function getSession()
{
return $this->hasOne(TestingSession::className(), ['id' => 'session_id']);
return $this->hasOne(Session::className(), ['id' => 'session_id']);
}
public function getQuestionsRelation()
{
return $this->hasOne(TestingQuestion::className(), ['id' => 'test_id']);
return $this->hasOne(Question::className(), ['id' => 'test_id']);
}
public function getGammasMG()
{
$cr = new CDbCriteria;
$cr->with = 'questions';
$cr->addCondition('questions.test_id = :test_id');
$cr->addCondition('t.type = :type');
$cr->group = 't.id';
$cr->distinct = true;
$cr->params = array(
':test_id' => $this->id,
':type' => TestingGamma::MG,
);
$cr->select = 'gamma.*';
return TestingGamma::model()->findAll($cr);
}
public function getGammasTE()
{
$cr = new CDbCriteria;
$cr->with = 'questions';
$cr->addCondition('questions.test_id = :test_id');
$cr->addCondition('t.type = :type');
$cr->group = 't.id';
$cr->distinct = true;
$cr->params = array(
':test_id' => $this->id,
':type' => TestingGamma::TE,
);
$cr->select = 'gamma.*';
return TestingGamma::model()->findAll($cr);
}
public static function getTestsList($session_id)
{
return ArrayHelper::map(self::find()->where(['session_id' => $session_id]), 'id', 'name');
......
......@@ -6,7 +6,9 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
class TestingTheme extends \common\components\ActiveRecordModel
use common\modules\testings\models\Question;
class Theme extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......@@ -24,6 +26,7 @@ class TestingTheme extends \common\components\ActiveRecordModel
{
return [
'name' => 'Наименование темы',
'create_date' => 'Дата создания',
];
}
......@@ -34,9 +37,7 @@ class TestingTheme extends \common\components\ActiveRecordModel
{
return [
[['name'], 'required'],
[['type'], 'safe'],
[['name'], 'string', 'max' => 200],
// array('id, name, type', 'safe', 'on' => 'search'),
];
}
......@@ -57,38 +58,6 @@ class TestingTheme extends \common\components\ActiveRecordModel
public function getQuestions()
{
return $this->hasMany(TestingQuestion::className(), ['theme_id' => 'id']);
return $this->hasMany(Question::className(), ['theme_id' => 'id']);
}
public function search()
{
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id);
$criteria->compare('name', $this->name, true);
$criteria->compare('type', $this->type);
if (Yii::app()->request->getQuery('test')) {
$criteria->with = 'questions';
$criteria->together = true;
$criteria->group = 't.id';
$criteria->compare('questions.test_id', Yii::app()->request->getQuery('test'));
}
return new ActiveDataProvider(get_class($this), array(
'criteria' => $criteria
));
}
public function questionCount($test_id) {
$cr = new CDbCriteria;
$cr->addCondition('test_id = :test_id');
$cr->addCondition('gamma_id = :gamma_id');
$cr->params = array(
'test_id' => $test_id,
'gamma_id' => $this->id,
);
return TestingQuestion::model()->count($cr);
}
}
\ No newline at end of file
......@@ -6,12 +6,12 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
use common\modules\testings\models\TestingPassing;
use common\modules\testings\models\TestingUserGroupAssign;
use common\modules\testings\models\TestingSendHistory;
use common\modules\users\models\User;
use common\modules\testings\models\Passing;
use common\modules\testings\models\UserGroupAssign;
use common\modules\testings\models\SendHistory;
use common\modules\users\models\User as Manager;
class TestingUser extends \common\components\ActiveRecordModel
class User extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......@@ -83,25 +83,25 @@ class TestingUser extends \common\components\ActiveRecordModel
public function getPassings()
{
return $this->hasMany(TestingPassing::className(), ['user_id' => 'id']);
return $this->hasMany(Passing::className(), ['user_id' => 'id']);
}
public function getManager()
{
return $this->hasOne(User::className(), ['id' => 'manager_id']);
return $this->hasOne(Manager::className(), ['id' => 'manager_id']);
}
public function getGroupRelated()
{
return $this->hasOne(TestingUserGroupAssign::className(), ['user_id' => 'id'])->andWhere([
TestingUserGroupAssign::tableName() . '.session_id' => Yii::$app->request->get('session')
return $this->hasOne(UserGroupAssign::className(), ['user_id' => 'id'])->andWhere([
UserGroupAssign::tableName() . '.session_id' => Yii::$app->request->get('session')
]);
}
public function getHistory()
{
return $this->hasOne(TestingSendHistory::className(), ['user_id' => 'id'])->andWhere([
TestingSendHistory::tableName() . '.session_id' => Yii::$app->request->get('session')
return $this->hasOne(SendHistory::className(), ['user_id' => 'id'])->andWhere([
SendHistory::tableName() . '.session_id' => Yii::$app->request->get('session')
]);
}
......
......@@ -6,7 +6,7 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
class TestingUserGroup extends \common\components\ActiveRecordModel
class UserGroup extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......
......@@ -6,7 +6,7 @@ use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
class TestingUserGroupAssign extends \common\components\ActiveRecordModel
class UserGroupAssign extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
......@@ -53,22 +53,6 @@ class TestingUserGroupAssign extends \common\components\ActiveRecordModel
public function getGroup()
{
return $this->hasOne(TestingUserGroup::className(), ['id' => 'group_id']);
return $this->hasOne(UserGroup::className(), ['id' => 'group_id']);
}
public function search()
{
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id);
$criteria->compare('name', $this->name);
$criteria->compare('session_id', $this->session_id);
$criteria->compare('created', $this->created);
$criteria->order = 't.id DESC';
return new ActiveDataProvider(get_class($this), array(
'criteria' => $criteria
));
}
}
<?php
class AnswerSubForm extends Portlet
{
public $model;
public function init()
{
parent::init();
}
public function renderContent()
{
$this->render('AnswerSubForm');
}
public static function formHtml($num, $text = '', $is_correct = 0, $errors = array())
{
$checked = (bool) $is_correct ? "checked" : "";
return "
<table>
<tr>
<td>
<input type='text' class='text' value='{$text}' name='Answers[{$num}][text]' class='ans_txt'>
</td>
<td>
<input type='checkbox' name='Answers[{$num}][is_correct]' {$checked} value='1'>
верный
</td>
<td>
<input type='checkbox' name='Answers[{$num}][delete]' value='1'>
удалить
</td>
</tr>
</table>
";
}
public static function validate($answers)
{
$errors = array();
$texts = array();
foreach ($answers as $num => $answer)
{
if (isset($answer['delete']))
{
continue;
}
$text = trim($answer['text']);
if (empty($text) && !isset($answer['delete']))
{
$errors[] = 'Заполните все текста ответов либо отметьте удалить!';
continue;
}
if (in_array($text, $texts))
{
$errors[] = 'Ответы не могут совпадать!';
continue;
}
$texts[] = $text;
}
return array_unique($errors);
}
}
<?php
Yii::app()->clientScript->registerScriptFile(
Yii::app()->controller->module->assetsUrl() . '/js/AnswerSubForm.js'
);
?>
<fieldset>
<legend>Ответы:</legend>
<div id="subform_elements"></div>
<a href="#" class="action_link" id="add_answer_link">добавить вариант ответа</a>
</fieldset>
......@@ -3,8 +3,8 @@
use yii\helpers\Html;
use \common\components\zii\AdminGrid;
use common\modules\testings\models\TestingAnswer;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\Answer;
use common\modules\testings\models\Question;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\faq\models\SearchFaq */
......@@ -15,7 +15,7 @@ $question = \Yii::$app->request->get('question');
if ($question)
{
$question = TestingQuestion::find()->where(['id' => $question])->one();
$question = Question::find()->where(['id' => $question])->one();
if ($question)
{
$question_id = $question->id;
......@@ -48,10 +48,10 @@ if ($question)
'text',
[
'attribute' => 'is_right',
'filter' => TestingAnswer::$type_list,
'filter' => Answer::$type_list,
'value' => function($model)
{
return TestingAnswer::$type_list[$model->is_right];
return Answer::$type_list[$model->is_right];
}
],
[
......
......@@ -3,7 +3,7 @@
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\modules\testings\models\TestingAnswer;
use common\modules\testings\models\Answer;
/* @var $this yii\web\View */
......@@ -29,7 +29,7 @@ use common\modules\testings\models\TestingAnswer;
'text',
[
'attribute' => 'is_right',
'value' => TestingAnswer::$type_list[$model->is_right],
'value' => Answer::$type_list[$model->is_right],
],
'create_date',
],
......
......@@ -3,8 +3,8 @@
use yii\helpers\Html;
use \common\components\zii\AdminGrid;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\TestingPassing;
use common\modules\testings\models\Test;
use common\modules\testings\models\Passing;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
......@@ -29,8 +29,8 @@ use common\modules\testings\models\TestingPassing;
<p>
<?= Html::a('Добавить', ['create', 'session' => $session->id], ['class' => 'btn btn-success']) ?>
<?= Html::a('Импорт из CSV-файла', ['/testings/testing-session-admin/import-passings', 'id' => $session->id], ['class' => 'btn btn-success']) ?>
<?= Html::a('Экспорт результатов в CSV-файл', ['/testings/testing-session-admin/export-session-result', 'id' => $session->id], ['class' => 'btn btn-success']) ?>
<?= Html::a('Импорт из CSV-файла', ['/testings/session-admin/import-passings', 'id' => $session->id], ['class' => 'btn btn-success']) ?>
<?= Html::a('Экспорт результатов в CSV-файл', ['/testings/session-admin/export-session-result', 'id' => $session->id], ['class' => 'btn btn-success']) ?>
</p>
<?php echo AdminGrid::widget([
......@@ -46,7 +46,7 @@ use common\modules\testings\models\TestingPassing;
{
if($model->user)
{
return Html::a($model->user->fio, ["/testings/testing-user-admin/view", "id" => $model->user->id]);
return Html::a($model->user->fio, ["/testings/user-admin/view", "id" => $model->user->id]);
}
else
{
......@@ -73,19 +73,19 @@ use common\modules\testings\models\TestingPassing;
[
'attribute' => 'test_id',
'format' => 'html',
'filter' => TestingTest::getTestsList($session->id),
'filter' => Test::getTestsList($session->id),
'value' => function($model)
{
return Html::a($model->test->name, ["/testings/testing-test-admin/view","id" => $model->test_id]);
return Html::a($model->test->name, ["/testings/test-admin/view","id" => $model->test_id]);
}
],
[
'attribute' => 'is_passed',
'format' => 'html',
'filter' => TestingPassing::$state_list,
'filter' => Passing::$state_list,
'value' => function($model)
{
return Html::tag("span", TestingPassing::$state_list[$model->status], ["class" => "STATE" . $model->status]);
return Html::tag("span", Passing::$state_list[$model->status], ["class" => "STATE" . $model->status]);
}
],
'pass_date',
......@@ -120,7 +120,7 @@ use common\modules\testings\models\TestingPassing;
{
$text = "Загрузить";
}
return Html::a($text, ["/testings/testing-passing-admin/mistake", "id" => $model->id]);
return Html::a($text, ["/testings/passing-admin/mistake", "id" => $model->id]);
}
else
{
......
......@@ -3,8 +3,8 @@
use yii\helpers\Html;
use \common\components\zii\AdminGrid;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\TestingPassing;
use common\modules\testings\models\Test;
use common\modules\testings\models\Passing;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
......@@ -106,7 +106,7 @@ use common\modules\testings\models\TestingPassing;
{
if($model->user)
{
return Html::a($model->user->fio, ["/testings/testing-user-admin/view", "id" => $model->user->id]);
return Html::a($model->user->fio, ["/testings/user-admin/view", "id" => $model->user->id]);
}
else
{
......@@ -133,19 +133,19 @@ use common\modules\testings\models\TestingPassing;
[
'attribute' => 'test_id',
'format' => 'html',
'filter' => TestingTest::getTestsList($session->id),
'filter' => Test::getTestsList($session->id),
'value' => function($model)
{
return Html::a($model->test->name, ["/testings/testing-test-admin/view","id" => $model->test_id]);
return Html::a($model->test->name, ["/testings/test-admin/view","id" => $model->test_id]);
}
],
[
'attribute' => 'is_passed',
'format' => 'html',
'filter' => TestingPassing::$state_list,
'filter' => Passing::$state_list,
'value' => function($model)
{
return Html::tag("span", TestingPassing::$state_list[$model->status], ["class" => "STATE" . $model->status]);
return Html::tag("span", Passing::$state_list[$model->status], ["class" => "STATE" . $model->status]);
}
],
[
......@@ -185,7 +185,7 @@ use common\modules\testings\models\TestingPassing;
{
$text = "Загрузить";
}
return Html::a($text, ["/testings/testing-passing-admin/mistake", "id" => $model->id]);
return Html::a($text, ["/testings/passing-admin/mistake", "id" => $model->id]);
}
else
{
......
......@@ -4,7 +4,7 @@ use yii\helpers\Html;
use yii\widgets\DetailView;
use \common\components\zii\AdminGrid;
use common\modules\testings\models\TestingPassing;
use common\modules\testings\models\Passing;
/* @var $this yii\web\View */
......@@ -28,23 +28,23 @@ use common\modules\testings\models\TestingPassing;
'attributes' => [
[
'attribute' => 'user_id',
'value' => ($model->user) ? Html::a($model->user->fio, ["/testings/testing-user-admin/view", "id" => $model->user->id]) : "Пользователь удалён",
'value' => ($model->user) ? Html::a($model->user->fio, ["/testings/user-admin/view", "id" => $model->user->id]) : "Пользователь удалён",
'format' => 'html',
],
[
'attribute' => 'session_id',
'value' => Html::a($model->test->session->name, ["/testings/testing-session-admin/view", "id" => $model->test->session_id]),
'value' => Html::a($model->test->session->name, ["/testings/session-admin/view", "id" => $model->test->session_id]),
'format' => 'html',
],
[
'attribute' => 'test_id',
'value' => Html::a($model->test->name, ["/testings/testing-test-admin/view", "id" => $model->test_id]),
'value' => Html::a($model->test->name, ["/testings/test-admin/view", "id" => $model->test_id]),
'format' => 'html',
],
[
'attribute' => 'is_passed',
'format' => 'raw',
'value' => TestingPassing::$state_list[$model->is_passed] . " ({$model->CountPassedQuestions} - {$model->percent_rights}%)",
'value' => Passing::$state_list[$model->is_passed] . " ({$model->CountPassedQuestions} - {$model->percent_rights}%)",
],
'pass_date',
],
......@@ -84,7 +84,7 @@ use common\modules\testings\models\TestingPassing;
'header' => 'Ответ',
'value' => function($model)
{
return Html::tag("span", TestingPassing::$answer_list[$model->isRight], ["class"=>"STATE".$model->isRight]) . " " . Html::a("Изменить на обратное", ["/testings/testing-passing-admin/change-answer-status", "qp_id" => $model->id]);
return Html::tag("span", Passing::$answer_list[$model->isRight], ["class"=>"STATE".$model->isRight]) . " " . Html::a("Изменить на обратное", ["/testings/passing-admin/change-answer-status", "qp_id" => $model->id]);
},
'format' => 'html'
],
......
......@@ -3,8 +3,8 @@
use yii\helpers\Html;
use \common\components\zii\AdminGrid;
use common\modules\testings\models\TestingTest;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\Test;
use common\modules\testings\models\Question;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
......@@ -14,7 +14,7 @@ $test = \Yii::$app->request->get('test');
if ($test)
{
$test = TestingTest::find()->where(['id' => $test])->one();
$test = Test::find()->where(['id' => $test])->one();
if ($test)
{
$test_id = $test->id;
......@@ -67,7 +67,7 @@ $this->registerJs($js, yii\web\View::POS_READY, 'expnd.info');
{
if($model->test && $model->test->session)
{
return Html::a($model->test->session->name, ["/testings/testing-session-admin/view", "id" => $model->test->session_id]);
return Html::a($model->test->session->name, ["/testings/session-admin/view", "id" => $model->test->session_id]);
}
else
{
......@@ -84,7 +84,7 @@ $this->registerJs($js, yii\web\View::POS_READY, 'expnd.info');
{
if($model->test)
{
return Html::a($model->test->name, ["/testings/testing-test-admin/view", "id" => $model->test_id]);
return Html::a($model->test->name, ["/testings/test-admin/view", "id" => $model->test_id]);
}
else
{
......@@ -101,7 +101,7 @@ $this->registerJs($js, yii\web\View::POS_READY, 'expnd.info');
{
if($model->theme)
{
return Html::a($model->theme->name, ["/testings/testing-theme-admin/view", "id" => $model->theme_id]);
return Html::a($model->theme->name, ["/testings/theme-admin/view", "id" => $model->theme_id]);
}
else
{
......@@ -114,12 +114,12 @@ $this->registerJs($js, yii\web\View::POS_READY, 'expnd.info');
'attribute' => 'theme_id',
'format' => 'html',
'visible' => $test_id,
'filter' => TestingQuestion::getThemesList(),
'filter' => Question::getThemesList(),
'value' => function($model)
{
if($model->theme)
{
return Html::a($model->theme->name, ["/testings/testing-theme-admin/view", "id" => $model->theme_id]);
return Html::a($model->theme->name, ["/testings/theme-admin/view", "id" => $model->theme_id]);
}
else
{
......@@ -133,23 +133,23 @@ $this->registerJs($js, yii\web\View::POS_READY, 'expnd.info');
'filter' => false,
'value' => function($model)
{
return Html::a('Подробнее', ["/testings/testing-answer-admin/manage", "question" => $model->id]);
return Html::a('Подробнее', ["/testings/answer-admin/manage", "question" => $model->id]);
}
],
[
'attribute' => 'is_active',
'filter' => TestingQuestion::$active_list,
'filter' => Question::$active_list,
'value' => function($model)
{
return TestingQuestion::$active_list[$model->is_active];
return Question::$active_list[$model->is_active];
}
],
[
'attribute' => 'type',
'filter' => TestingQuestion::$type_list,
'filter' => Question::$type_list,
'value' => function($model)
{
return TestingQuestion::$type_list[$model->type];
return Question::$type_list[$model->type];
}
],
[
......
......@@ -3,7 +3,7 @@
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\Question;
/* @var $this yii\web\View */
......@@ -27,28 +27,28 @@ use common\modules\testings\models\TestingQuestion;
'attributes' => [
[
'attribute' => 'test.session.name',
'value' => Html::a($model->test->session->name, ['/testings/testing-session-admin/view', 'id' => $model->test->session_id]),
'value' => Html::a($model->test->session->name, ['/testings/session-admin/view', 'id' => $model->test->session_id]),
'format' => 'html'
],
[
'attribute' => 'test.name',
'value' => Html::a($model->test->name, ['/testings/testing-test-admin/view', 'id' => $model->test_id]),
'value' => Html::a($model->test->name, ['/testings/test-admin/view', 'id' => $model->test_id]),
'format' => 'html'
],
[
'attribute' => 'theme.name',
'value' => Html::a($model->theme->name, ['/testings/testing-theme-admin/view', 'id' => $model->theme_id]),
'value' => Html::a($model->theme->name, ['/testings/theme-admin/view', 'id' => $model->theme_id]),
'format' => 'html'
],
'text',
[
'attribute' => 'is_active',
'value' => TestingQuestion::$active_list[$model->is_active],
'value' => Question::$active_list[$model->is_active],
],
'author',
[
'attribute' => 'type',
'value' => TestingQuestion::$type_list[$model->type],
'value' => Question::$type_list[$model->type],
],
'create_date',
],
......
......@@ -4,7 +4,7 @@ use yii\helpers\Html;
use \common\components\zii\AdminGrid;
use yii\helpers\Url;
use common\modules\testings\models\TestingSendHistory;
use common\modules\testings\models\SendHistory;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
......@@ -29,9 +29,9 @@ use common\modules\testings\models\TestingSendHistory;
'attribute' => 'unisender_status',
'value' => function($model)
{
return TestingSendHistory::getStatusTitle($model->unisender_status);
return SendHistory::getStatusTitle($model->unisender_status);
},
'filter' => TestingSendHistory::getStatusTitle(),
'filter' => SendHistory::getStatusTitle(),
],
[
'class' => \common\components\ColorActionColumn::className(),
......@@ -41,7 +41,7 @@ use common\modules\testings\models\TestingSendHistory;
{
if($model->file && file_exists($model->getFilePath()))
{
return Html::a('<i class="fa fa-envelope fa-lg"></i>', Url::to(['testings/testing-session-admin/send-message', 'id' => $session->id, 'user' => $model->id]), [
return Html::a('<i class="fa fa-envelope fa-lg"></i>', Url::to(['testings/session-admin/send-message', 'id' => $session->id, 'user' => $model->id]), [
'title' => 'Уведомить о тестировании',
'data-toggle' => 'tooltip',
'data-pjax' => '0',
......
......@@ -55,7 +55,7 @@ use \common\components\zii\AdminGrid;
'format' => 'html',
'value' => function($model)
{
return Html::a("Список тестов", ["/testings/testing-test-admin/manage", "session" => $model->id]);
return Html::a("Список тестов", ["/testings/test-admin/manage", "session" => $model->id]);
},
],
[
......@@ -63,7 +63,7 @@ use \common\components\zii\AdminGrid;
'format' => 'html',
'value' => function($model)
{
return Html::a("Список групп", ["/testings/testing-user-admin/manage-group", "session" => $model->id]);
return Html::a("Список групп", ["/testings/user-admin/manage-group", "session" => $model->id]);
},
],
[
......@@ -71,7 +71,7 @@ use \common\components\zii\AdminGrid;
'format' => 'html',
'value' => function($model)
{
return Html::a("Список пользователей", ["/testings/testing-user-admin/manage", "session" => $model->id]);
return Html::a("Список пользователей", ["/testings/user-admin/manage", "session" => $model->id]);
},
],
[
......@@ -79,7 +79,7 @@ use \common\components\zii\AdminGrid;
'format' => 'html',
'value' => function($model)
{
return Html::a("Список прохождений", ["/testings/testing-passing-admin/manage", "session" => $model->id]);
return Html::a("Список прохождений", ["/testings/passing-admin/manage", "session" => $model->id]);
},
],
[
......@@ -87,7 +87,7 @@ use \common\components\zii\AdminGrid;
'format' => 'html',
'value' => function($model)
{
return Html::a("Статистика прохождений", ["/testings/testing-passing-admin/statistics", "session" => $model->id]);
return Html::a("Статистика прохождений", ["/testings/passing-admin/statistics", "session" => $model->id]);
},
],
[
......
......@@ -14,7 +14,7 @@ use yii\widgets\DetailView;
<p>
<?= Html::a(Yii::t('content', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a("Экспорт результатов", ['testings/testing-session-admin/export-session-result', 'id' => $model->id], ['class' => 'btn btn-info']) ?>
<?= Html::a("Экспорт результатов", ['testings/session-admin/export-session-result', 'id' => $model->id], ['class' => 'btn btn-info']) ?>
</p>
<?= DetailView::widget([
......
......@@ -3,7 +3,7 @@
use yii\helpers\Html;
use \common\components\zii\AdminGrid;
use common\modules\testings\models\TestingSession;
use common\modules\testings\models\Session;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
......@@ -12,7 +12,7 @@ $session_id = null;
$session = \Yii::$app->request->get('session');
if($session)
{
$session = TestingSession::find()->where(['id' => $session])->one();
$session = Session::find()->where(['id' => $session])->one();
if ($session)
{
$session_id = $session->id;
......@@ -37,7 +37,7 @@ if($session)
'format' => 'raw',
'value' => function($model)
{
return Html::a($model->session->name, ["/testings/testing-session-admin/view", "id" => $model->session_id]);
return Html::a($model->session->name, ["/testings/session-admin/view", "id" => $model->session_id]);
},
],
'name',
......@@ -54,7 +54,7 @@ if($session)
return;
}
return Html::a("Список вопросов", ["/testings/testing-question-admin/manage", "test" => $model->id]);
return Html::a("Список вопросов", ["/testings/question-admin/manage", "test" => $model->id]);
},
'format' => 'raw',
],
......@@ -67,7 +67,7 @@ if($session)
return;
}
return Html::a("Список тем", ["/testings/testing-theme-admin/manage", "test" => $model->id]);
return Html::a("Список тем", ["/testings/theme-admin/manage", "test" => $model->id]);
},
'format' => 'html',
],
......
......@@ -22,7 +22,7 @@ use yii\widgets\DetailView;
'attributes' => [
[
'attribute' => 'session.name',
'value' => Html::a($model->session->name, array('/testings/testing-session-admin/view', 'id' => $model->session_id)),
'value' => Html::a($model->session->name, array('/testings/session-admin/view', 'id' => $model->session_id)),
'format' => 'raw',
],
'name',
......
<?php
$this->tabs = array(
//'управление' => $this->createUrl('manage')
);
$this->crumbs = array(
/*'Список сессий' => array('/testings/testingSessionAdmin/manage'),
$session->name => array('/testings/testingPassingAdmin/manage','session'=>$session->id),
'Создать прохождение',*/
);
echo $form;
<div class="wide form">
<?php $form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<div class="row">
<?php echo $form->label($model,'id'); ?>
<?php echo $form->textField($model,'id'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'test_id'); ?>
<?php echo $form->textField($model,'test_id'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'name'); ?>
<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>200)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'type'); ?>
<?php echo $form->textField($model,'type'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'create_date'); ?>
<?php echo $form->textField($model,'create_date'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Search'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- search-form -->
\ No newline at end of file
<?php
$this->tabs = array(
//'управление' => $this->createUrl('manage')
);
echo $form;
<?php
$test_id = null;
if (Yii::app()->request->getQuery('test')) {
$test = TestingTest::model()->findByPk(Yii::app()->request->getQuery('test'));
if ($test) {
$test_id = $test->id;
$this->crumbs = array(
'Список сессий' => array('/testings/testingSessionAdmin/manage'),
'Сессия "'.$test->session->name.'"' => array('/testings/testingSessionAdmin/view','id'=>$test->session->id),
'Список тестов' => array('/testings/testingTestAdmin/manage','session'=>$test->session->id),
$test->name => array('/testings/testingTestAdmin/view','id'=>$test->id),
'Список гамм'
);
}
$this->tabs = array(
'импорт вопросов из CSV-файла' => $this->createUrl('/testings/testingTestAdmin/importTests',array('id'=>$test->id)),
);
}
$this->tabs = CMap::mergeArray($this->tabs, array(
'добавить' => $this->createUrl('create',array('test'=>$test_id))
));
$this->widget('AdminGrid', array(
'id' => 'testing-gamma-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
array(
'name' => 'name',
'value' => '$data->name',
),
array(
'header' => 'Заполненность',
'value' => 'CHtml::tag("span", array("class"=>"fill_mark", "style"=>"font-weight: bold;"), ($data->type == TestingGamma::MG) ? $data->questionCount('.$test_id.')."/".(TestingTest::model()->findByPk('.$test_id.')->questions * TestingTest::model()->findByPk('.$test_id.')->mg_percent / (TestingTest::model()->findByPk('.$test_id.')->mg_percent + TestingTest::model()->findByPk('.$test_id.')->te_percent) / TestingTest::model()->findByPk('.$test_id.')->mg_count) : $data->questionCount('.$test_id.')."/".(TestingTest::model()->findByPk('.$test_id.')->questions * TestingTest::model()->findByPk('.$test_id.')->te_percent / (TestingTest::model()->findByPk('.$test_id.')->mg_percent + TestingTest::model()->findByPk('.$test_id.')->te_percent) / TestingTest::model()->findByPk('.$test_id.')->te_count))',
'visible' => $test_id,
'type' => 'html',
),
array(
'name' => 'type',
'value' => 'TestingGamma::$type_list[$data->type]',
'filter' => false,
),
//array('name' => 'create_date'),
array(
'class' => 'CButtonColumn',
'template' => '{view}{update}',
),
),
));
?>
<script type="text/javascript">
jQuery(function(){
jQuery(".fill_mark").each(function(){
var $this = $(this);
var str = $this.html();
var arr = str.split('/');
console.log(arr);
if (parseInt(arr[0]) >= parseInt(arr[1])) {
$this.css('color','green');
} else {
$this.css('color','red');
}
});
});
</script>
\ No newline at end of file
<?php
$this->tabs = array(
'управление' => $this->createUrl('manage'),
'просмотр' => $this->createUrl('view', array('id' => $form->model->id))
);
echo $form;
\ No newline at end of file
<?php
$this->tabs = array(
'управление' => $this->createUrl('manage'),
'редактировать' => $this->createUrl('update', array('id' => $model->id))
);
$this->widget('DetailView', array(
'data' => $model,
'attributes' => array(
array('name' => 'name'),
array('name' => 'type', 'value'=> TestingGamma::$type_list[$model->type]),
array('name' => 'create_date'),
),
));
<?php
use yii\helpers\Html;
use \common\components\zii\AdminGrid;
use common\modules\testings\models\Test;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\faq\models\SearchFaq */
/* @var $dataProvider yii\data\ActiveDataProvider */
$test_id = null;
$test = \Yii::$app->request->get('test');
if ($test)
{
$test = Test::findOne($test);
if ($test)
{
$test_id = $test->id;
}
}
?>
<p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
<?php if($question_id) : ?>
<?= Html::a('Импорт вопросов из XLS-файла', ['testings/test-admin/import-tests', 'id' => $test_id], ['class' => 'btn btn-info']) ?>
<?php endif; ?>
</p>
<?php echo AdminGrid::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
'name',
[
'class' => 'common\components\ColorActionColumn',
'template' => '{view} {update}',
],
],
]); ?>
\ No newline at end of file
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
?>
<div class="faq-view">
<p>
<?= Html::a(Yii::t('content', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'name',
'create_date',
],
]) ?>
</div>
......@@ -26,7 +26,7 @@ use \common\components\zii\AdminGrid;
'header' => 'Список пользователей',
'value' => function($model) {
return Html::a('Список пользователей', [
"/testings/testing-user-admin/manage",
"/testings/user-admin/manage",
"session" => \Yii::$app->request->get('session'),
"group" => $model->id,
]);
......
......@@ -5,11 +5,11 @@ use \common\components\zii\AdminGrid;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use common\modules\testings\models\TestingUser;
use common\modules\testings\models\TestingUserGroup;
use common\modules\testings\models\TestingSendHistory;
use common\modules\testings\models\TestingSession;
use common\modules\testings\models\TestingPassing;
use common\modules\testings\models\User;
use common\modules\testings\models\UserGroup;
use common\modules\testings\models\SendHistory;
use common\modules\testings\models\Session;
use common\modules\testings\models\Passing;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
......@@ -17,16 +17,16 @@ use common\modules\testings\models\TestingPassing;
$session = null;
if (\Yii::$app->request->get('session'))
{
$session = TestingSession::findOne(\Yii::$app->request->get('session'));
$session = Session::findOne(\Yii::$app->request->get('session'));
}
?>
<p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
<?php if($session) : ?>
<?= Html::a('Разослать уведомления всем', ['/testings/testing-session-admin/send-message-to-all', 'id' => $session->id], ['class' => 'btn btn-info']) ?>
<?= Html::a('История отправки дубликатов', ['/testings/testing-send-history-admin/manage', 'session' => $session->id], ['class' => 'btn btn-info']) ?>
<?= Html::a('Импорт пользователей из XLS', ['/testings/testing-session-admin/import-passings', 'id' => $session->id], ['class' => 'btn btn-info']) ?>
<?= Html::a('Разослать уведомления всем', ['/testings/session-admin/send-message-to-all', 'id' => $session->id], ['class' => 'btn btn-info']) ?>
<?= Html::a('История отправки дубликатов', ['/testings/send-history-admin/manage', 'session' => $session->id], ['class' => 'btn btn-info']) ?>
<?= Html::a('Импорт пользователей из XLS', ['/testings/session-admin/import-passings', 'id' => $session->id], ['class' => 'btn btn-info']) ?>
<?php endif; ?>
</p>
......@@ -42,9 +42,9 @@ $columns = [
'attribute' => 'sex',
'value' => function($model)
{
return TestingUser::$sex_list[$model->sex];
return User::$sex_list[$model->sex];
},
'filter' => TestingUser::$sex_list,
'filter' => User::$sex_list,
'visible' => !\Yii::$app->request->get('session'),
],
'last_name',
......@@ -57,7 +57,7 @@ $columns = [
{
return $model->groupRelated->group->name;
},
'filter' => ArrayHelper::map(TestingUserGroup::find()->where(['session_id' => \Yii::$app->request->get('session')])->all(), 'id', 'name')
'filter' => ArrayHelper::map(UserGroup::find()->where(['session_id' => \Yii::$app->request->get('session')])->all(), 'id', 'name')
],
[
'attribute' => 'email',
......@@ -70,13 +70,13 @@ $columns = [
[
'header' => 'Статус отправки',
'attribute' => 'filter_history_status',
'filter' => TestingSendHistory::getStatusTitle(),
'filter' => SendHistory::getStatusTitle(),
'format' => 'raw',
'value' => function($model)
{
if($model->history)
{
return TestingSendHistory::getStatusTitle($model->history->unisender_status);
return SendHistory::getStatusTitle($model->history->unisender_status);
}
},
],
......@@ -119,7 +119,7 @@ if ($session)
$style = ($qty) ? '' : 'display:none;';
$send = Html::a("Разослать выделенным ($qty)",
['testings/testing-session-admin/send-message-to-marked', 'id' => $session->id],
['testings/session-admin/send-message-to-marked', 'id' => $session->id],
['style' => $style, 'id' => 'sendMarkup']
);
......@@ -149,18 +149,18 @@ if ($session)
'header' => $test->name,
'value' => function($model) use($test)
{
$passing = TestingPassing::find()->where([
$passing = Passing::find()->where([
'test_id' => $test->id,
'user_id' => $model->id
])->one();
if($passing)
{
return Html::a("Да", ["/testings/testing-passing-admin/change-status", "user"=>$model->id, "test" => $test->id], ["title" => "Изменить на НЕТ"]);
return Html::a("Да", ["/testings/passing-admin/change-status", "user"=>$model->id, "test" => $test->id], ["title" => "Изменить на НЕТ"]);
}
else
{
return Html::a("Нет", ["/testings/testing-passing-admin/change-status", "user"=>$model->id, "test" => $test->id], ["title" => "Изменить на ДА"]);
return Html::a("Нет", ["/testings/passing-admin/change-status", "user"=>$model->id, "test" => $test->id], ["title" => "Изменить на ДА"]);
}
},
'format' => 'html',
......@@ -176,7 +176,7 @@ if ($session)
'buttons' => [
'send' => function ($url, $model, $key) use($session)
{
return Html::a('<i class="fa fa-envelope fa-lg"></i>', Url::to(['testings/testing-session-admin/send-message', 'id' => $session->id, 'user' => $model->id]), [
return Html::a('<i class="fa fa-envelope fa-lg"></i>', Url::to(['testings/session-admin/send-message', 'id' => $session->id, 'user' => $model->id]), [
'title' => 'Уведомить о тестировании',
'data-toggle' => 'tooltip',
'data-pjax' => '0',
......
<?php
echo $form;
\ No newline at end of file
......@@ -3,7 +3,7 @@
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\modules\testings\models\TestingUser;
use common\modules\testings\models\User;
/* @var $this yii\web\View */
/* @var $model common\modules\faq\models\Faq */
......@@ -23,7 +23,7 @@ use common\modules\testings\models\TestingUser;
'attributes' => [
[
'attribute' => 'sex',
'value' => TestingUser::$sex_list[$model->sex],
'value' => User::$sex_list[$model->sex],
'filter' => false
],
'first_name',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment