Mistake fix

parent 372ac585
......@@ -265,7 +265,8 @@ JS;
$config['options'][] = $this->field($meta, 'description');
$config['options'][] = $this->field($meta, 'keywords');
}
foreach($config['buttons'] as $buttonName => $button) {
foreach($config['buttons'] as $buttonName => $button)
{
if($button['type'] == 'htmlBlock')
$config['options'][] = $button['value'];
else if($button['type'] == 'submit')
......@@ -276,6 +277,8 @@ JS;
$config['options'][] = \yii\helpers\Html::button($button['value'], ['class'=> 'btn btn-danger', 'id' => $buttonName]);
else
$config['options'][] = \yii\helpers\Html::button($button['value'], ['class'=> 'btn btn-info', 'id' => $buttonName]);
$config['options'][] = ' ';
}
unset($config['buttons']);
......
<?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.');
}
}
}
<?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
$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
public $company;
public $managerField;
public $mistakeField;
public $retest = 0;
public static $state_list = [
self::NOT_AGREED => 'Не согласовано',
......@@ -29,7 +30,17 @@ class Mistake extends \common\components\ActiveRecordModel
public function name()
{
return 'Переназначения';
return 'Сообщения об ошибках';
}
public function attributeLabels()
{
return [
'passing_id' => 'Прохождение',
'description' => 'Описание ошибки',
'is_expert_agreed' => 'Согласовано ли с экспертом',
'create_date' => 'Время создания',
];
}
/**
......@@ -56,7 +67,7 @@ class Mistake extends \common\components\ActiveRecordModel
[['passing_id', 'description', 'is_expert_agreed'], 'required'],
[['passing_id', 'is_expert_agreed'], 'integer'],
[['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
// ])
// ->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
{
return [
[['user_id', 'test_id'], 'required'],
[['user_id', 'test_id', 'is_passed'], 'integer'],
[['pass_date', 'pass_date_start', 'attempt'], 'safe'],
[['test_id'], 'string', 'max' => 11],
[['end_date'], 'required', 'on' => 'extend'],
[['user_id', 'is_passed'], 'integer'],
];
}
......@@ -78,7 +77,7 @@ class Passing extends \common\components\ActiveRecordModel
{
return [
'is_passed' => 'Состояние',
'test_id' => 'Тип теста',
'test_id' => 'Tест',
'user_id' => 'ФИО',
'create_date' => 'Дата создания',
'pass_date' => 'Дата прохождения теста',
......
<?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
<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
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