Commit 32b4c6af authored by Shakarim Sapa's avatar Shakarim Sapa

Merge remote-tracking branch 'origin/master'

parents edcc089c 20328cb7
...@@ -304,32 +304,6 @@ CREATE TABLE IF NOT EXISTS `meta_tags` ( ...@@ -304,32 +304,6 @@ CREATE TABLE IF NOT EXISTS `meta_tags` (
INSERT INTO `meta_tags` (`id`, `object_id`, `model_id`, `language`, `title`, `keywords`, `description`, `created_at`, `updated_at`) VALUES INSERT INTO `meta_tags` (`id`, `object_id`, `model_id`, `language`, `title`, `keywords`, `description`, `created_at`, `updated_at`) VALUES
(6, 1, 'common\\modules\\content\\models\\CoContent', 'ru', 'Это главная', 'Это главная', 'Это главная', 1427531082, 1435822414), (6, 1, 'common\\modules\\content\\models\\CoContent', 'ru', 'Это главная', 'Это главная', 'Это главная', 1427531082, 1435822414),
(36, 24, 'common\\modules\\content\\models\\CoContent', 'ru', '', '', '', 1450859568, 1450859568),
(5, 6, 'common\\modules\\content\\models\\CoContent', 'ru', 'тест', 'тест', 'тест', 1427531082, 1432196320),
(10, 20, 'common\\modules\\content\\models\\CoContent', 'ru', 'Как это работает? - Онлайн выдача займов', 'как это работает', 'как это работает', 1430320024, 1432062111),
(11, 1, 'common\\modules\\faq\\models\\Faq', 'ru', 'Получение займа', 'контакт, система контакт, поступили деньги, как узнать, получение перевода, kontakt', 'Круглосуточная выдача займов нашим клиентам. Быстрые переводы через Контакт.', 1430828849, 1432644694),
(12, 3, 'common\\modules\\faq\\models\\Faq', 'ru', 'Займы под низкий процент круглосуточно', 'займы, погашение, низкий процент, низкий %, займ дешево, взять в долг, ', 'Уменьшение процентной ставки нашим постоянным клиентам. Постоянные акции по снижению процентов. Звоните!', 1430829119, 1430983831),
(13, 4, 'common\\modules\\faq\\models\\Faq', 'ru', 'Погашение займа ', 'погашение займа, возврат займа, вернуть долг, отдать займ, ', 'Возвращайте займы удобным для вас способом. Множество платежных систем. Выгодно и удобно.', 1430829544, 1430984105),
(14, 6, 'common\\modules\\faq\\models\\Faq', 'ru', 'Погашение займа через Киви', 'киви, qiwi, вернуть через киви, возврат без комиссии, быстрый, возврат, займа, ', 'Без комиссии возвращайте займы через платежную систему Киви. Просто и удобно. Никаких дополнительных переплат.', 1430829726, 1430984342),
(15, 7, 'common\\modules\\faq\\models\\Faq', 'ru', 'Займ за границей', 'займ за пределами РФ, за границей, взять, деньги, в другой стране, находясь,', 'Мы выдаем займы нашим клиентам с паспортом РФ в любых странах. Мгновенные переводы через различные платежные системы. Быстро и удобно.', 1430829814, 1430984804),
(16, 8, 'common\\modules\\faq\\models\\Faq', 'ru', 'Начисление пени', 'пени за просрочку, расчет пени, размер пени, ставка пени, пени, просрочка, штрафы, не вернул вовремя, начисление пени, пеней, ', 'Ставка пени минимальная. При погашении займа в срок или при досрочном погашении пени не начисляются. ', 1430829889, 1430985833),
(17, 9, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430829976, 1430830639),
(18, 30, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830077, 1430830647),
(19, 31, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830261, 1430830261),
(20, 35, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830331, 1430830626),
(21, 36, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830383, 1430830607),
(22, 37, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830445, 1430830601),
(23, 38, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830565, 1430830565),
(24, 39, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830714, 1430830714),
(25, 40, 'common\\modules\\faq\\models\\Faq', 'ru', 'Title', 'Keywords,Keywords', 'Description', 1430830763, 1432738488),
(26, 41, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830793, 1432203673),
(27, 42, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830847, 1430830847),
(28, 43, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830894, 1430830894),
(29, 44, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430830956, 1430830956),
(30, 45, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430831089, 1430831089),
(31, 46, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430832030, 1430832030),
(32, 47, 'common\\modules\\faq\\models\\Faq', 'ru', '', '', '', 1430832533, 1432644664),
(34, 22, 'common\\modules\\content\\models\\CoContent', 'ru', 'Требования к ПО', 'по, требования, работа с сайтом, технические требования, системные требования', 'Технические требования для работы с сайтом ', 1430906924, 1430922337),
(35, 23, 'common\\modules\\content\\models\\CoContent', 'ru', '404 страница не найдена', '404 страница не найдена', '404 страница не найдена', 1432895790, 1432895790); (35, 23, 'common\\modules\\content\\models\\CoContent', 'ru', '404 страница не найдена', '404 страница не найдена', '404 страница не найдена', 1432895790, 1432895790);
-- -------------------------------------------------------- -- --------------------------------------------------------
......
...@@ -164,6 +164,8 @@ JS; ...@@ -164,6 +164,8 @@ JS;
$opt['value'] = $element['value']; $opt['value'] = $element['value'];
if(!empty($element['options']['label'])) if(!empty($element['options']['label']))
$optEl['labelOptions'] = ['label' => $element['options']['label']]; $optEl['labelOptions'] = ['label' => $element['options']['label']];
if(!empty($element['fileOptions']))
$opt = $element['fileOptions'];
if(!empty($element['empty'])) if(!empty($element['empty']))
$opt['value'] = $element['empty']; $opt['value'] = $element['empty'];
switch($element['type']) { switch($element['type']) {
...@@ -248,7 +250,7 @@ JS; ...@@ -248,7 +250,7 @@ JS;
'</div>'; '</div>';
break; break;
case 'file': case 'file':
$config['options'][] = $this->field($this->model, $key, $optEl)->fileInput(); $config['options'][] = $this->field($this->model, $key, $optEl)->fileInput($opt);
break; break;
} }
} }
...@@ -265,7 +267,8 @@ JS; ...@@ -265,7 +267,8 @@ JS;
$config['options'][] = $this->field($meta, 'description'); $config['options'][] = $this->field($meta, 'description');
$config['options'][] = $this->field($meta, 'keywords'); $config['options'][] = $this->field($meta, 'keywords');
} }
foreach($config['buttons'] as $buttonName => $button) { foreach($config['buttons'] as $buttonName => $button)
{
if($button['type'] == 'htmlBlock') if($button['type'] == 'htmlBlock')
$config['options'][] = $button['value']; $config['options'][] = $button['value'];
else if($button['type'] == 'submit') else if($button['type'] == 'submit')
...@@ -276,6 +279,8 @@ JS; ...@@ -276,6 +279,8 @@ JS;
$config['options'][] = \yii\helpers\Html::button($button['value'], ['class'=> 'btn btn-danger', 'id' => $buttonName]); $config['options'][] = \yii\helpers\Html::button($button['value'], ['class'=> 'btn btn-danger', 'id' => $buttonName]);
else else
$config['options'][] = \yii\helpers\Html::button($button['value'], ['class'=> 'btn btn-info', 'id' => $buttonName]); $config['options'][] = \yii\helpers\Html::button($button['value'], ['class'=> 'btn btn-info', 'id' => $buttonName]);
$config['options'][] = ' ';
} }
unset($config['buttons']); unset($config['buttons']);
......
...@@ -64,7 +64,7 @@ class Settings extends \common\components\ActiveRecordModel ...@@ -64,7 +64,7 @@ class Settings extends \common\components\ActiveRecordModel
]; ];
} }
public function getValue($code) public static function getValue($code)
{ {
$model = Settings::find()->where(['code' => $code])->one(); $model = Settings::find()->where(['code' => $code])->one();
......
...@@ -115,7 +115,7 @@ use yii\helpers\Url; ...@@ -115,7 +115,7 @@ use yii\helpers\Url;
<div class="col-md-4 col-xs-4 col-sm-12"><a href="#zvonok_form" class="zvonok_bt popup-form"><span>Заказать звонок</span></a></div> <div class="col-md-4 col-xs-4 col-sm-12"><a href="#zvonok_form" class="zvonok_bt popup-form"><span>Заказать звонок</span></a></div>
<div class="col-md-4 col-xs-4 col-sm-12"> <div class="col-md-4 col-xs-4 col-sm-12">
<div class="phone_hover_foot">Стоимость звонка 0 руб,<br> в том числе с мобильного</div> <div class="phone_hover_foot">Стоимость звонка 0 руб,<br> в том числе с мобильного</div>
<span class="foot_phone">8-800-2000-600</span> <span class="foot_phone">8-495-749-29-69</span>
</div> </div>
</div> </div>
<div class="footbottom_line"> <div class="footbottom_line">
......
<?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\Mistake;
use common\modules\testings\models\Passing;
class MistakeAdminController extends AdminController
{
public $errorSummaryCssClass = 'error-summary';
public $encodeErrorSummary = true;
public static function actionsTitles()
{
return array(
'View' => 'Просмотр ошибки',
'Create' => 'Создание ошибки',
'Update' => 'Редактирование ошибки',
);
}
public function actionView($passing)
{
return $this->render('view', [
'model' => Mistake::find()->where(['passing_id' => $passing])->one(),
]);
}
public function actionCreate($passing)
{
$model = new Mistake;
Yii::$app->controller->page_title = 'Добавить ошибку';
Yii::$app->controller->breadcrumbs = [
['Список прохождений' => '/testings/passing-admin/manage', 'session' => $model->passing->test->session_id],
'Добавить ошибку'
];
$model->load(Yii::$app->request->post());
$model->passing_id = $passing;
if (Yii::$app->request->isPost && $model->save())
{
if ($model->retest)
{
$pass = new Passing;
$oldpass = Passing::findOne($model->passing_id);
$pass->attributes = $oldpass->attributes;
$pass->is_passed = null;
$pass->pass_date = null;
$pass->attempt = 0;
$pass->pass_date_start = '';
$pass->save();
}
return $this->redirect(['/testings/passing-admin/manage', 'session' => $model->passing->test->session_id]);
}
else
{
$form = new \common\components\BaseForm('/common/modules/testings/forms/MistakeForm', $model);
return $this->render('create', [
'model' => $model,
'form' => $form->out
]);
}
}
public function actionUpdate($passing)
{
Yii::$app->controller->page_title = 'Редактировать ошибку';
Yii::$app->controller->breadcrumbs = [
['Список прохождений' => '/testings/passing-admin/manage', 'session' => $model->passing->test->session_id],
'Редактировать ошибку'
];
$model = Mistake::find()->where(['passing_id' => $passing])->one();
$model->load(Yii::$app->request->post());
$model->passing_id = $passing;
if (Yii::$app->request->isPost && $model->save())
{
if ($model->retest)
{
$pass = new Passing;
$pass->attributes = $model->passing->attributes;
$pass->is_passed = null;
$pass->pass_date = null;
$pass->attempt = 0;
$pass->pass_date_start = '';
$pass->save();
}
return $this->redirect(['/testings/passing-admin/manage', 'session' => $model->passing->test->session_id]);
}
else
{
$form = new \common\components\BaseForm('/common/modules/testings/forms/MistakeForm', $model);
return $this->render('update', [
'model' => $model,
'form' => $form->out
]);
}
}
/**
* 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 = Answer::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
...@@ -140,29 +140,29 @@ class PassingAdminController extends AdminController ...@@ -140,29 +140,29 @@ class PassingAdminController extends AdminController
return sprintf("%02d:%02d:%02d", (int)($time / 3600), (int)(($time % 3600) / 60), $time % 60); return sprintf("%02d:%02d:%02d", (int)($time / 3600), (int)(($time % 3600) / 60), $time % 60);
} }
public function actionReAttempt($id) // public function actionReAttempt($id)
{ // {
$passing = $this->loadModel($id); // $passing = $this->loadModel($id);
$passing->attempt = 0; // $passing->attempt = 0;
$passing->save(false, array('attempt')); // $passing->save(false, array('attempt'));
$subject = 'Тестирование - переназначение теста'; // $subject = 'Тестирование - переназначение теста';
$body = Setting::getValue('email_reattempt_body'); // $body = Setting::getValue('email_reattempt_body');
$mailer_letter = MailerLetter::model(); // $mailer_letter = MailerLetter::model();
$body = $mailer_letter->compileText($body, array( // $body = $mailer_letter->compileText($body, array(
'test_name' => $passing->test->name, // 'test_name' => $passing->test->name,
)); // ));
unset($mailer_letter); // unset($mailer_letter);
$result = MailerModule::sendMailUniSender($passing->user->email, $subject, $body); // $result = MailerModule::sendMailUniSender($passing->user->email, $subject, $body);
$this->render('reattempt', array( // $this->render('reattempt', array(
'result' => $result // 'result' => $result
)); // ));
} // }
public function actionChangeAnswerStatus($qp_id) public function actionChangeAnswerStatus($qp_id)
{ {
......
...@@ -7,6 +7,7 @@ use common\components\AdminController; ...@@ -7,6 +7,7 @@ use common\components\AdminController;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\web\UploadedFile;
use common\modules\testings\models\Question; use common\modules\testings\models\Question;
use common\modules\testings\models\SearchQuestion; use common\modules\testings\models\SearchQuestion;
...@@ -54,9 +55,23 @@ class QuestionAdminController extends AdminController ...@@ -54,9 +55,23 @@ class QuestionAdminController extends AdminController
'Добавить вопрос' 'Добавить вопрос'
]; ];
if ($model->load(Yii::$app->request->post()) && $model->save()) { $model->load(Yii::$app->request->post());
$model->filesUpload = UploadedFile::getInstances($model, 'filesUpload');
if (Yii::$app->request->isPost && $model->validate())
{
if($model->filesUpload)
{
$model->upload();
$model->filesUpload = null;
}
$model->save();
return $this->redirect(['manage']); return $this->redirect(['manage']);
} else { }
else
{
$form = new \common\components\BaseForm('/common/modules/testings/forms/QuestionForm', $model); $form = new \common\components\BaseForm('/common/modules/testings/forms/QuestionForm', $model);
return $this->render('create', [ return $this->render('create', [
'model' => $model, 'model' => $model,
...@@ -75,9 +90,28 @@ class QuestionAdminController extends AdminController ...@@ -75,9 +90,28 @@ class QuestionAdminController extends AdminController
$model = $this->findModel($id); $model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) { $model->load(Yii::$app->request->post());
$model->filesUpload = UploadedFile::getInstances($model, 'filesUpload');
if (Yii::$app->request->isPost && $model->validate())
{
if($model->filesUpload)
{
if($model->files)
{
$model->deleteFiles();
}
$model->upload();
$model->filesUpload = null;
}
$model->save();
return $this->redirect(['manage']); return $this->redirect(['manage']);
} else { }
else
{
$form = new \common\components\BaseForm('/common/modules/testings/forms/QuestionForm', $model); $form = new \common\components\BaseForm('/common/modules/testings/forms/QuestionForm', $model);
return $this->render('update', [ return $this->render('update', [
'model' => $model, 'model' => $model,
...@@ -97,8 +131,7 @@ class QuestionAdminController extends AdminController ...@@ -97,8 +131,7 @@ class QuestionAdminController extends AdminController
{ {
$questions = []; $questions = [];
$param = 'карт, изобр, изображение, скриншот, картинка, схема, рисунок, рис'; $param = trim(\common\models\Settings::getValue('testings_questions_with_picture'));
// $param = trim(Setting::getValue('testings_questions_with_picture'));
$words = empty($param) ? array() : explode(',', trim($param)); $words = empty($param) ? array() : explode(',', trim($param));
......
<?php
class TestingMistakeAdminController extends AdminController
{
public static function actionsTitles()
{
return array(
'View' => 'Просмотр ошибки',
'Create' => 'Создание ошибки',
'Update' => 'Редактирование ошибки',
'Delete' => 'Удаление ошибки',
'Manage' => 'Управление ошибками',
);
}
public function actionView($passing)
{
$this->render('view', array(
'model' => TestingMistake::model()->find('passing_id = :passing',array(':passing'=>$passing)),
));
}
public function actionCreate($passing)
{
$model = new TestingMistake;
$form = new BaseForm('testings.TestingMistakeForm', $model);
// $this->performAjaxValidation($model);
if(isset($_POST['TestingMistake']))
{
$model->attributes = $_POST['TestingMistake'];
$model->passing_id = $passing;
if($model->save()) {
// назначение повторного тестирования
if (isset($_POST['retest'])) {
$pass = new TestingPassing;
$oldpass = TestingPassing::model()->findByPk($model->passing_id);
$pass->attributes = $oldpass->attributes;
$pass->is_passed = null;
$pass->pass_date = null;
$pass->attempt = 0;
$pass->pass_date_start = '';
$pass->save();
}
$this->redirect(array('/testings/testingPassingAdmin/manage','session'=>$model->passing->test->session_id));
}
}
$this->render('create', array(
'form' => $form,
));
}
public function actionUpdate($passing)
{
$model = TestingMistake::model()->find('passing_id = :passing',array(':passing'=>$passing));;
$form = new BaseForm('testings.TestingMistakeForm', $model);
// $this->performAjaxValidation($model);
if(isset($_POST['TestingMistake']))
{
$model->attributes = $_POST['TestingMistake'];
if($model->save())
{
// назначение повторного тестирования
if (isset($_POST['retest'])) {
$pass = new TestingPassing;
$oldpass = TestingPassing::model()->findByPk($model->passing_id);
$pass->attributes = $oldpass->attributes;
$pass->is_passed = null;
$pass->pass_date = null;
$pass->attempt = 0;
$pass->pass_date_start = '';
$pass->save();
}
$this->redirect(array('/testings/testingPassingAdmin/manage','session'=>$model->passing->test->session_id));
}
}
$this->render('update', array(
'form' => $form,
));
}
public function loadModel($id)
{
$model = TestingMistake::model()->findByPk((int) $id);
if($model === null)
{
$this->pageNotFound();
}
return $model;
}
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax'] === 'testing-mistake-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
<?php
$js = <<<JS
$('#retest').click(function(){
$('#mistake-retest').val(true);
$('#testing-answer-form').submit();
});
JS;
\Yii::$app->getView()->registerJs($js, \yii\web\View::POS_END, 'formLoad');
return [
'activeForm'=>[
'id' => 'testing-answer-form',
],
'elements' => [
'description' => ['type' => 'textarea'],
'is_expert_agreed' => ['type' => 'checkbox'],
'retest' => ['type' => 'hidden'],
// 'files' => array(
// 'type' => 'file_manager',
// 'data_type' => 'any',
// 'title' => 'Файлы для скачивания ',
// 'tag' => 'files'
// ),
],
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Cохранить'],
'retest' => ['type' => 'info', 'value' => 'Назначить пересдачу'],
]
];
<?php <?php
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use common\modules\testings\models\Test; use common\modules\testings\models\Test;
use common\modules\testings\models\Theme; use common\modules\testings\models\Theme;
use common\modules\testings\models\Question; use common\modules\testings\models\Question;
$files = '';
if($model->files)
{
foreach ($model->files as $file)
{
$files .= Html::img($file->getUrl(), ['width' => 150]) . ' ';
}
}
$elements = [ $elements = [
'test_id' => [ 'test_id' => [
'type' => 'dropdownlist', 'type' => 'dropdownlist',
...@@ -23,12 +34,14 @@ $elements = [ ...@@ -23,12 +34,14 @@ $elements = [
'type' => 'dropdownlist', 'type' => 'dropdownlist',
'items' => Question::$type_list, 'items' => Question::$type_list,
], ],
// 'files' => [ $files,
// 'type' => 'file_manager', 'filesUpload[]' => [
// 'data_type' => 'any', 'type' => 'file',
// 'title' => 'Файлы для скачивания ', 'fileOptions' => [
// 'tag' => 'files' 'multiple' => true,
// ], 'accept' => 'image/*',
]
],
// 'Ответы' => [ // 'Ответы' => [
// 'title' => 'Ответы', // 'title' => 'Ответы',
// 'type' => 'answers', // 'type' => 'answers',
...@@ -47,6 +60,9 @@ if (\Yii::$app->request->get('test')) ...@@ -47,6 +60,9 @@ if (\Yii::$app->request->get('test'))
return [ return [
'activeForm'=>[ 'activeForm'=>[
'id' => 'testing-question-form', 'id' => 'testing-question-form',
'options' => [
'enctype' => 'multipart/form-data'
],
], ],
'elements' => $elements, 'elements' => $elements,
'buttons' => [ 'buttons' => [
......
<?php
$buttons = array(
'submit' => array(
'type' => 'submit',
'value' => 'сохранить',
),
'retest' => array(
'type' => 'submit',
'value' => 'назначить пересдачу',
//'style' => 'width: 400px;',
)
);
return array(
'activeForm' => array(
'id' => 'testing-mistake-form',
),
'elements' => array(
//'passing_id' => array('type' => 'text'),
'description' => array('type' => 'textarea'),
'is_expert_agreed' => array('type' => 'checkbox'),
'files' => array(
'type' => 'file_manager',
'data_type' => 'any',
'title' => 'Файлы для скачивания ',
'tag' => 'files'
),
//'create_date' => array('type' => 'text'),
),
'buttons' => $buttons,
);
...@@ -16,6 +16,7 @@ class Mistake extends \common\components\ActiveRecordModel ...@@ -16,6 +16,7 @@ class Mistake extends \common\components\ActiveRecordModel
public $company; public $company;
public $managerField; public $managerField;
public $mistakeField; public $mistakeField;
public $retest = 0;
public static $state_list = [ public static $state_list = [
self::NOT_AGREED => 'Не согласовано', self::NOT_AGREED => 'Не согласовано',
...@@ -29,9 +30,19 @@ class Mistake extends \common\components\ActiveRecordModel ...@@ -29,9 +30,19 @@ class Mistake extends \common\components\ActiveRecordModel
public function name() public function name()
{ {
return 'Переназначения'; return 'Сообщения об ошибках';
} }
public function attributeLabels()
{
return [
'passing_id' => 'Прохождение',
'description' => 'Описание ошибки',
'is_expert_agreed' => 'Согласовано ли с экспертом',
'create_date' => 'Время создания',
];
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
...@@ -56,7 +67,7 @@ class Mistake extends \common\components\ActiveRecordModel ...@@ -56,7 +67,7 @@ class Mistake extends \common\components\ActiveRecordModel
[['passing_id', 'description', 'is_expert_agreed'], 'required'], [['passing_id', 'description', 'is_expert_agreed'], 'required'],
[['passing_id', 'is_expert_agreed'], 'integer'], [['passing_id', 'is_expert_agreed'], 'integer'],
[['description'], 'string', 'max' => 3000], [['description'], 'string', 'max' => 3000],
// array('id, passing_id, description, is_expert_agreed, create_date', 'safe', 'on' => 'search'), [['retest'], 'safe']
]; ];
} }
...@@ -74,18 +85,4 @@ class Mistake extends \common\components\ActiveRecordModel ...@@ -74,18 +85,4 @@ class Mistake extends \common\components\ActiveRecordModel
// ]) // ])
// ->orderBy(['files.order DESC']); // ->orderBy(['files.order DESC']);
// } // }
public function search()
{
$criteria = new CDbCriteria;
$criteria->compare('id', $this->id);
$criteria->compare('passing_id', $this->passing_id);
$criteria->compare('description', $this->description, true);
$criteria->compare('is_expert_agreed', $this->is_expert_agreed);
$criteria->compare('create_date', $this->create_date, true);
return new ActiveDataProvider(get_class($this), array(
'criteria' => $criteria
));
}
} }
\ No newline at end of file
...@@ -67,10 +67,9 @@ class Passing extends \common\components\ActiveRecordModel ...@@ -67,10 +67,9 @@ class Passing extends \common\components\ActiveRecordModel
{ {
return [ return [
[['user_id', 'test_id'], 'required'], [['user_id', 'test_id'], 'required'],
[['user_id', 'test_id', 'is_passed'], 'integer'],
[['pass_date', 'pass_date_start', 'attempt'], 'safe'], [['pass_date', 'pass_date_start', 'attempt'], 'safe'],
[['test_id'], 'string', 'max' => 11],
[['end_date'], 'required', 'on' => 'extend'], [['end_date'], 'required', 'on' => 'extend'],
[['user_id', 'is_passed'], 'integer'],
]; ];
} }
...@@ -78,7 +77,7 @@ class Passing extends \common\components\ActiveRecordModel ...@@ -78,7 +77,7 @@ class Passing extends \common\components\ActiveRecordModel
{ {
return [ return [
'is_passed' => 'Состояние', 'is_passed' => 'Состояние',
'test_id' => 'Тип теста', 'test_id' => 'Tест',
'user_id' => 'ФИО', 'user_id' => 'ФИО',
'create_date' => 'Дата создания', 'create_date' => 'Дата создания',
'pass_date' => 'Дата прохождения теста', 'pass_date' => 'Дата прохождения теста',
......
...@@ -10,6 +10,7 @@ use common\modules\testings\models\Answer; ...@@ -10,6 +10,7 @@ use common\modules\testings\models\Answer;
use common\modules\testings\models\Theme; use common\modules\testings\models\Theme;
use common\modules\testings\models\Test; use common\modules\testings\models\Test;
use common\modules\testings\models\QuestionPassing; use common\modules\testings\models\QuestionPassing;
use common\modules\testings\models\QuestionImage;
class Question extends \common\components\ActiveRecordModel class Question extends \common\components\ActiveRecordModel
{ {
...@@ -24,6 +25,10 @@ class Question extends \common\components\ActiveRecordModel ...@@ -24,6 +25,10 @@ class Question extends \common\components\ActiveRecordModel
const ACTIVE = 1; const ACTIVE = 1;
const HIDDEN = 0; const HIDDEN = 0;
const IMAGES_FOLDER = '/uploads/questions/';
public $filesUpload;
public static $type_list = [ public static $type_list = [
self::ONE_OPTION => 'Нужно выбрать один вариант', self::ONE_OPTION => 'Нужно выбрать один вариант',
self::FEW_OPTIONS => 'Нужно выбрать несколько вариантов', self::FEW_OPTIONS => 'Нужно выбрать несколько вариантов',
...@@ -54,6 +59,7 @@ class Question extends \common\components\ActiveRecordModel ...@@ -54,6 +59,7 @@ class Question extends \common\components\ActiveRecordModel
'text' => 'Текст вопроса', 'text' => 'Текст вопроса',
'type' => 'Тип вопроса', 'type' => 'Тип вопроса',
'create_date' => 'Время создания', 'create_date' => 'Время создания',
'filesUpload' => 'Изображения'
]; ];
} }
...@@ -65,6 +71,7 @@ class Question extends \common\components\ActiveRecordModel ...@@ -65,6 +71,7 @@ class Question extends \common\components\ActiveRecordModel
return [ return [
[['theme_id', 'test_id', 'text', 'is_active', 'type'], 'required'], [['theme_id', 'test_id', 'text', 'is_active', 'type'], 'required'],
[['theme_id', 'test_id', 'type', 'is_active'], 'integer'], [['theme_id', 'test_id', 'type', 'is_active'], 'integer'],
[['filesUpload'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif', 'maxFiles' => 4],
]; ];
} }
...@@ -83,6 +90,19 @@ class Question extends \common\components\ActiveRecordModel ...@@ -83,6 +90,19 @@ class Question extends \common\components\ActiveRecordModel
]; ];
} }
public function beforeDelete()
{
if (parent::beforeDelete())
{
$this->deleteFiles();
return true;
}
else
{
return false;
}
}
public function getAnswers() public function getAnswers()
{ {
return $this->hasMany(Answer::className(), ['question_id' => 'id']); return $this->hasMany(Answer::className(), ['question_id' => 'id']);
...@@ -105,10 +125,7 @@ class Question extends \common\components\ActiveRecordModel ...@@ -105,10 +125,7 @@ class Question extends \common\components\ActiveRecordModel
public function getFiles() public function getFiles()
{ {
return $this->hasMany(FileManager::className(), ['object_id' => 'id']) return $this->hasMany(QuestionImage::className(), ['question_id' => 'id']);
->andWhere([FileManager::tableName() . '.model_id' => get_class($this)])
->andWhere([FileManager::tableName() . '.tag' => 'files'])
->orderBy(FileManager::tableName() . '.order DESC');
} }
public function getRightAnswer() public function getRightAnswer()
...@@ -170,4 +187,52 @@ class Question extends \common\components\ActiveRecordModel ...@@ -170,4 +187,52 @@ class Question extends \common\components\ActiveRecordModel
{ {
return \yii\helpers\ArrayHelper::map(Theme::find()->all(), 'id', 'name'); return \yii\helpers\ArrayHelper::map(Theme::find()->all(), 'id', 'name');
} }
public function getPath()
{
return Yii::getAlias('@frontend/web') . self::IMAGES_FOLDER;
}
public function upload()
{
if ($this->validate())
{
if(!file_exists($this->getPath()))
{
mkdir($this->getPath(), 0777, true);
}
foreach ($this->filesUpload as $file)
{
$filename = date('dmYHis-') . uniqid() . '.' . $file->extension;
$file->saveAs($this->getPath() . $filename);
$image = new QuestionImage;
$image->question_id = $this->id;
$image->filename = $filename;
$image->save();
}
return true;
}
else
{
return false;
}
}
public function deleteFiles()
{
if($this->files)
{
foreach ($this->files as $file)
{
if(file_exists($this->getPath() . $file->filename))
{
unlink($this->getPath() . $file->filename);
}
$file->delete();
}
}
}
} }
<?php
namespace common\modules\testings\models;
use Yii;
use common\modules\testings\models\Question;
/**
* This is the model class for table "testings_questions_image".
*
* @property integer $id
* @property integer $question_id
* @property string $filename
*/
class QuestionImage extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'testings_questions_image';
}
public function name()
{
return 'Изображения для вопросов';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['question_id', 'filename'], 'required'],
[['question_id'], 'integer'],
[['filename'], 'string', 'max' => 50],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'question_id' => 'Вопрос',
'filename' => 'Изображение',
];
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
];
}
public function getQuestion()
{
return $this->hasOne(Question::className(), ['id' => 'question_id']);
}
public function getUrl()
{
return Yii::$app->params['frontUrl'] . Question::IMAGES_FOLDER . $this->filename;
}
}
<?php
echo $form;
\ No newline at end of file
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\modules\testings\models\Mistake;
/* @var $this yii\web\View */
?>
<div class="faq-view">
<p>
<?= Html::a(Yii::t('content', 'Update'), ['update', 'passing' => $model->passing_id], ['class' => 'btn btn-primary']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'description',
[
'attribute' => 'is_expert_agreed',
'value' => Mistake::$state_list[$model->is_expert_agreed],
],
'create_date',
],
]) ?>
</div>
<?php
// if ($model->files) {
// $this->widget('fileManager.portlets.FileList', array(
// 'model' => $model,
// 'tag' => 'files',
// 'tagName' => 'div',
// 'htmlOptions' => array(
// 'class' => 'file-list',
// 'style' => 'margin: 20px 10px 0 10px;'
// ),
// ));
// }
\ No newline at end of file
...@@ -88,7 +88,7 @@ use common\modules\testings\models\Passing; ...@@ -88,7 +88,7 @@ use common\modules\testings\models\Passing;
return Html::tag("span", Passing::$state_list[$model->status], ["class" => "STATE" . $model->status]); return Html::tag("span", Passing::$state_list[$model->status], ["class" => "STATE" . $model->status]);
} }
], ],
'pass_date', 'pass_date',
[ [
'header' => 'Ответственный менеджер', 'header' => 'Ответственный менеджер',
'format' => 'html', 'format' => 'html',
......
<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,'passing_id'); ?>
<?php echo $form->textField($model,'passing_id'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'description'); ?>
<?php echo $form->textField($model,'description',array('size'=>60,'maxlength'=>3000)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'is_expert_agreed'); ?>
<?php echo $form->textField($model,'is_expert_agreed'); ?>
</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
$this->tabs = array(
//'управление' => $this->createUrl('manage'),
'просмотр' => $this->createUrl('view', array('passing' => $form->model->passing_id))
);
echo $form;
\ No newline at end of file
<?php
$this->tabs = array(
//'управление' => $this->createUrl('manage'),
'редактировать' => $this->createUrl('update', array('passing' => $model->passing_id))
);
$this->widget('DetailView', array(
'data' => $model,
'attributes' => array(
/*array(
'name' => 'passing_id',
'value' => $model->passing->name,
),*/
array('name' => 'description'),
array(
'name' => 'is_expert_agreed',
'value' => TestingMistake::$state_list[$model->is_expert_agreed],
),
array('name' => 'create_date'),
),
));
if ($model->files) {
$this->widget('fileManager.portlets.FileList', array(
'model' => $model,
'tag' => 'files',
'tagName' => 'div',
'htmlOptions' => array(
'class' => 'file-list',
'style' => 'margin: 20px 10px 0 10px;'
),
));
}
\ No newline at end of file
...@@ -25,7 +25,7 @@ if ($test) ...@@ -25,7 +25,7 @@ if ($test)
<p> <p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?> <?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
<?php if($question_id) : ?> <?php if($test_id) : ?>
<?= Html::a('Импорт вопросов из XLS-файла', ['testings/test-admin/import-tests', 'id' => $test_id], ['class' => 'btn btn-info']) ?> <?= Html::a('Импорт вопросов из XLS-файла', ['testings/test-admin/import-tests', 'id' => $test_id], ['class' => 'btn btn-info']) ?>
<?php endif; ?> <?php endif; ?>
</p> </p>
......
<?php
use yii\db\Migration;
class m160128_054103_add_setting_testing extends Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
$this->insert('settings', [
'module_id' => 'testings',
'code' => 'testings_questions_with_picture',
'name' => 'Ключевые слова для загрузки картинки в вопрос',
'value' => 'карт, изобр, изображение, скриншот, картинка, схема, рисунок, рис',
'element' => 'text',
'hidden' => 0,
'description' => 'Ключевые слова для загрузки картинки в вопрос',
]);
}
public function safeDown()
{
$this->delete('settings', ['code' => 'testings_questions_with_picture']);
}
}
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160128_055509_add_testings_question_files extends Migration
{
public function safeUp()
{
$this->createTable(
'testings_questions_image',
[
'id' => Schema::TYPE_PK,
'question_id' => Schema::TYPE_INTEGER.'(11) NOT NULL',
'filename' => Schema::TYPE_STRING.'(50) NOT NULL',
]
);
$this->addForeignKey(
'fk_questions_image_question_id_question_id',
'testings_questions_image', 'question_id',
'testings_questions', 'id'
);
}
public function safeDown()
{
$this->dropForeignKey('fk_questions_image_question_id_question_id', 'testings_questions_image');
$this->dropTable('testings_questions_image');
}
}
...@@ -53,12 +53,14 @@ AppAsset::register($this); ...@@ -53,12 +53,14 @@ AppAsset::register($this);
<li><a href="#">Блог</a></li> <li><a href="#">Блог</a></li>
<li><a href="/school">Школа аналитики</a></li> <li><a href="/school">Школа аналитики</a></li>
<li><a href="/contacts">Контакты</a></li> <li><a href="/contacts">Контакты</a></li>
<li><a href="#">ENG</a></li>
<!-- <li><a href="#">RUS</a></li> -->
</ul> </ul>
</nav> </nav>
<div class="lang_check"> <!-- <div class="lang_check">
<a href="#" class="d_menu"><i class="icon-arrowDown"></i>ENG</a> <a href="#" class="d_menu"><i class="icon-arrowDown"></i>ENG</a>
<a href="#" class="d_menu_hide"><i class="icon-arrowRight"></i>RUS</a> <a href="#" class="d_menu_hide"><i class="icon-arrowRight"></i>RUS</a>
</div> </div> -->
</div> </div>
<div class="col-md-3 col-xs-3 col-sm-12"> <div class="col-md-3 col-xs-3 col-sm-12">
<span class="top_phone"><?=\common\models\Settings::getValue('content-phone')?></span> <span class="top_phone"><?=\common\models\Settings::getValue('content-phone')?></span>
......
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