Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
4f4686ee
Commit
4f4686ee
authored
Jan 21, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix passing
parent
6bdf9f63
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
78 deletions
+118
-78
common/modules/testings/controllers/TestingPassingAdminController.php
...es/testings/controllers/TestingPassingAdminController.php
+50
-27
common/modules/testings/models/SearchTestingPassing.php
common/modules/testings/models/SearchTestingPassing.php
+68
-51
No files found.
common/modules/testings/controllers/TestingPassingAdminController.php
View file @
4f4686ee
...
...
@@ -11,6 +11,7 @@ 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\TestingQuestionPassing
;
class
TestingPassingAdminController
extends
AdminController
{
...
...
@@ -22,10 +23,10 @@ class TestingPassingAdminController extends AdminController
'Delete'
=>
'Удаление прохождения'
,
'Manage'
=>
'Управление прохождениями'
,
'Mistake'
=>
'Ошибка'
,
'Change
S
tatus'
=>
'Изменить статус'
,
'Change
AnswerS
tatus'
=>
'Изменить статус ответа'
,
'Change
-s
tatus'
=>
'Изменить статус'
,
'Change
-answer-s
tatus'
=>
'Изменить статус ответа'
,
'Statistics'
=>
'Статистика прохождений'
,
'Re
A
ttempt'
=>
'Переназначение теста'
'Re
-a
ttempt'
=>
'Переназначение теста'
);
}
...
...
@@ -161,49 +162,71 @@ class TestingPassingAdminController extends AdminController
));
}
public
function
actionChangeAnswerStatus
(
$qp_id
)
{
$qp
=
TestingQuestionPassing
::
model
()
->
findByPk
(
$qp_id
);
if
(
$qp
)
{
if
(
$qp
->
user_answer
==
$qp
->
answer_text
)
{
public
function
actionChangeAnswerStatus
(
$qp_id
)
{
$qp
=
TestingQuestionPassing
::
findOne
(
$qp_id
);
if
(
$qp
)
{
if
(
$qp
->
user_answer
==
$qp
->
answer_text
)
{
$qp
->
user_answer
=
'Заведомо неправильный ответ'
;
}
else
{
}
else
{
$qp
->
user_answer
=
$qp
->
answer_text
;
}
$qp
->
save
();
$passing
=
$this
->
loadModel
(
$qp
->
passing_id
);
if
(
$passing
)
{
$passing
=
$this
->
findModel
(
$qp
->
passing_id
);
if
(
$passing
)
{
$passing
->
recountPassResult
();
$passing
->
save
();
}
}
$this
->
redirect
(
$_SERVER
[
'HTTP_REFERER'
]);
}
public
function
actionChangeStatus
(
$user
,
$test
)
{
public
function
actionChangeStatus
(
$user
,
$test
)
{
$tp
=
TestingPassing
::
model
()
->
findAllByAttributes
(
array
(
'user_id'
=>
$user
,
'test_id'
=>
$test
));
if
(
$tp
)
{
foreach
(
$tp
as
$t
)
{
$t
->
delete
();
}
}
else
{
$tp
=
TestingPassing
::
find
()
->
where
([
'user_id'
=>
$user
,
'test_id'
=>
$test
])
->
one
();
if
(
$tp
)
{
$tp
->
delete
();
}
else
{
$tp
=
new
TestingPassing
;
$tp
->
user_id
=
$user
;
$tp
->
test_id
=
$test
;
$tp
->
save
();
}
$this
->
redirect
(
$_SERVER
[
'HTTP_REFERER'
]);
}
public
function
loadModel
(
$id
)
{
$model
=
TestingPassing
::
model
()
->
findByPk
((
int
)
$id
);
if
(
$model
===
null
)
{
$this
->
pageNotFound
();
/**
* 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
=
TestingAnswer
::
findOne
(
$id
))
!==
null
)
{
return
$model
;
}
else
{
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
}
return
$model
;
}
}
}
common/modules/testings/models/SearchTestingPassing.php
View file @
4f4686ee
...
...
@@ -53,7 +53,7 @@ class SearchTestingPassing extends TestingPassing
'query'
=>
$query
,
'pagination'
=>
[
'pageSize'
=>
self
::
PAGE_SIZE
],
'sort'
=>
[
'defaultOrder'
=>
'
user.last_name, user.first_name, user.patronymic, test.nam
e DESC'
,
'defaultOrder'
=>
'
create_dat
e DESC'
,
],
]);
...
...
@@ -65,7 +65,7 @@ class SearchTestingPassing extends TestingPassing
return
$dataProvider
;
}
$query
=
$this
->
query
(
$params
,
$order
,
$limit
);
$
dataProvider
->
query
=
$this
->
query
(
$params
,
$order
,
$limit
);
return
$dataProvider
;
}
...
...
@@ -74,7 +74,7 @@ class SearchTestingPassing extends TestingPassing
{
$query
=
TestingPassing
::
find
();
$
query
->
joinWith
([
'user'
,
'test'
,
'mistake'
])
;
$
with
=
[
'test'
=>
true
]
;
$query
->
andFilterWhere
([
'id'
=>
$this
->
id
,
...
...
@@ -82,12 +82,27 @@ class SearchTestingPassing extends TestingPassing
'test_id'
=>
$this
->
test_id
,
'create_date'
=>
$this
->
create_date
,
TestingTest
::
tableName
()
.
'.session_id'
=>
Yii
::
$app
->
request
->
get
(
'session'
),
TestingUser
::
tableName
()
.
'.email'
=>
$this
->
filter_user_email
,
TestingUser
::
tableName
()
.
'.company_name'
=>
$this
->
filter_user_company_name
,
TestingUser
::
tableName
()
.
'.last_name'
=>
$this
->
filter_user_last_name
]);
// $tpassing = Yii::app()->request->getQuery('TestingPassing');
if
(
$this
->
filter_user_email
)
{
$with
[
'user'
]
=
true
;
$query
->
andFilterWhere
([
'like'
,
TestingUser
::
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
]);
}
if
(
$this
->
filter_user_last_name
)
{
$with
[
'user'
]
=
true
;
$query
->
andFilterWhere
([
'like'
,
TestingUser
::
tableName
()
.
'.last_name'
,
$this
->
filter_user_last_name
]);
}
// $tpassing = Yii::app()->request->getQuery('TestingPassing');
// $pass_date = 'CONCAT( RIGHT( LEFT( pass_date, 10 ) , 4 ) , "-", TRIM(
// TRAILING CONCAT( ".", SUBSTRING_INDEX( LEFT( pass_date, 10 ) , ".", -1 ) )
...
...
@@ -106,51 +121,51 @@ class SearchTestingPassing extends TestingPassing
// $criteria->addCondition($pass_date.' > "'.Yii::app()->request->getQuery('pass_date').'"');
// }
switch
(
$this
->
is_passed
)
{
case
TestingPassing
::
AUTH
:
$query
->
andFilterWhere
([
'>'
,
'ser.create_date'
,
'2014-06-05 00:00:00'
]);
$query
->
andFilterWhere
([
TestingUser
::
tableName
()
.
'.is_auth'
=>
0
]);
break
;
case
TestingPassing
::
STARTED
:
$query
->
andFilterWhere
([
'is_passed'
=>
0
,
'pass_date'
=>
null
,
TestingMistake
::
tableName
()
.
'.passing_id'
=>
null
]);
break
;
case
TestingPassing
::
MISTAKE
:
$query
->
andFilterWhere
([
'='
,
TestingMistake
::
tableName
()
.
'.passing_id'
,
'id'
]);
break
;
case
TestingPassing
::
PASSED
:
$query
->
andFilterWhere
([
'is_passed'
=>
1
,
TestingMistake
::
tableName
()
.
'.passing_id'
=>
null
]);
break
;
case
TestingPassing
::
FAILED
:
$query
->
andFilterWhere
([
'is_passed'
=>
0
,
TestingMistake
::
tableName
()
.
'.passing_id'
=>
null
]);
$query
->
andFilterWhere
([
'not'
,
'pass_date'
,
null
]);
break
;
case
TestingPassing
::
NOT_STARTED
:
$query
->
andFilterWhere
([
'is_passed'
=>
null
,
TestingMistake
::
tableName
()
.
'.passing_id'
=>
null
]);
break
;
}
// if (Yii::app()->user->getRole() == 'schneider_electric')
// switch ($this->is_passed)
// {
// $criteria->compare('user.tki', Yii::app()->user->getName(), true);
// case TestingPassing::AUTH:
// $with['user'] = true;
// $query->andFilterWhere(['>', 'ser.create_date', '2014-06-05 00:00:00']);
// $query->andFilterWhere([TestingUser::tableName() . '.is_auth' => 0]);
// break;
// case TestingPassing::STARTED:
// $query->andFilterWhere([
// 'is_passed' => 0,
// 'pass_date' => null,
// TestingMistake::tableName() . '.passing_id' => null
// ]);
// break;
// case TestingPassing::MISTAKE:
// $with['mistake'] = true;
// $query->andFilterWhere(['=', TestingMistake::tableName() . '.passing_id', 'id']);
// break;
// case TestingPassing::PASSED:
// $with['mistake'] = true;
// $query->andFilterWhere([
// 'is_passed' => 1,
// TestingMistake::tableName() . '.passing_id' => null
// ]);
// break;
// case TestingPassing::FAILED:
// $with['mistake'] = true;
// $query->andFilterWhere([
// 'is_passed' => 0,
// TestingMistake::tableName() . '.passing_id' => null
// ]);
// $query->andFilterWhere(['not', 'pass_date', null]);
// break;
// case TestingPassing::NOT_STARTED:
// $with['mistake'] = true;
// $query->andFilterWhere([
// 'is_passed' => null,
// TestingMistake::tableName() . '.passing_id' => null
// ]);
// break;
// }
if
(
!
empty
(
$order
))
...
...
@@ -159,6 +174,8 @@ class SearchTestingPassing extends TestingPassing
if
(
!
empty
(
$limit
))
$query
->
limit
(
$limit
);
$query
->
joinWith
(
array_keys
(
$with
));
return
$query
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment