fix answerFlagLabel method in AnswerHelper, fix setPercentCorrectAnswers method in ScoreCalculatorService

This commit is contained in:
iironside 2022-03-16 12:55:44 +03:00
parent 97e79f6c94
commit 86853f2a59
8 changed files with 42 additions and 17 deletions

View File

@ -33,11 +33,11 @@ $this->params['breadcrumbs'][] = $this->title;
'id', 'id',
[ [
'attribute' => 'field_id', 'attribute' => 'field_id',
'value' => ArrayHelper::getValue($model, 'field.title') // AnswerHelper::answerFlagLabel($model->answer_flag), 'value' => ArrayHelper::getValue($model, 'field.title')
], ],
[ [
'attribute' => 'document_id', 'attribute' => 'document_id',
'value' => ArrayHelper::getValue($model, 'document.title') // AnswerHelper::answerFlagLabel($model->answer_flag), 'value' => ArrayHelper::getValue($model, 'document.title')
], ],
'value', 'value',
], ],

View File

@ -129,7 +129,7 @@ YiiAsset::register($this);
'attribute' => 'answer_flag', 'attribute' => 'answer_flag',
'format' => 'raw', 'format' => 'raw',
'value' => function ($model) { 'value' => function ($model) {
return AnswerHelper::answerStatusLabel($model->answer_flag); return AnswerHelper::userResponseLabel($model->answer_flag);
}, },
], ],

View File

@ -43,7 +43,7 @@ $this->params['breadcrumbs'][] = $this->title;
'format' => 'raw', 'format' => 'raw',
'filter' => AnswerHelper::answerFlagsList(), 'filter' => AnswerHelper::answerFlagsList(),
'value' => function ($model) { 'value' => function ($model) {
return AnswerHelper::answerStatusLabel($model->answer_flag); return AnswerHelper::userResponseLabel($model->answer_flag);
}, },
], ],
[ [

View File

@ -44,7 +44,7 @@ YiiAsset::register($this);
[ [
'attribute' => 'answer_flag', 'attribute' => 'answer_flag',
'format' => 'raw', 'format' => 'raw',
'value' => AnswerHelper::answerFlagLabel($model->answer_flag), 'value' => AnswerHelper::userResponseLabel($model->answer_flag),
], ],
'user_questionnaire_uuid', 'user_questionnaire_uuid',
], ],

View File

@ -10,14 +10,12 @@ class AnswerHelper
{ {
const FLAG_TRUE = 1; const FLAG_TRUE = 1;
const FLAG_FALSE = 0; const FLAG_FALSE = 0;
const FLAG_NOT_VERIFIED = null;
public static function answerFlagsList(): array public static function answerFlagsList(): array
{ {
return [ return [
self::FLAG_TRUE => 'Верен', self::FLAG_TRUE => 'Верен',
self::FLAG_FALSE => 'Ошибочный', self::FLAG_FALSE => 'Ошибочный',
self::FLAG_NOT_VERIFIED => 'Не проверен',
]; ];
} }
@ -26,15 +24,15 @@ class AnswerHelper
*/ */
public static function answerFlagLabel($status): string public static function answerFlagLabel($status): string
{ {
switch (true) { switch ($status) {
case ($status === self::FLAG_FALSE): case self::FLAG_FALSE:
$class = 'label label-danger'; $class = 'label label-danger';
break; break;
case ($status === self::FLAG_TRUE): case self::FLAG_TRUE:
$class = 'label label-success'; $class = 'label label-success';
break; break;
default: default:
$class = 'label label-warning'; $class = 'label label-default';
} }
return Html::tag('span', ArrayHelper::getValue(self::answerFlagsList(), $status), [ return Html::tag('span', ArrayHelper::getValue(self::answerFlagsList(), $status), [
@ -42,7 +40,7 @@ class AnswerHelper
]); ]);
} }
public static function answerStatusLabel($answer_flag): string public static function userResponseLabel($answer_flag): string
{ {
$class = 'label label-warning'; $class = 'label label-warning';
$content = 'Не проверен'; $content = 'Не проверен';

View File

@ -150,8 +150,8 @@ class UserQuestionnaire extends ActiveRecord
*/ */
public function numCorrectAnswersWithoutOpenQuestions() public function numCorrectAnswersWithoutOpenQuestions()
{ {
return $this->hasMany(Answer::className(), ['question_id' => 'question_id']) return $this->hasMany(Answer::className(), ['question_id' => 'id'])
->viaTable('user_response', ['user_questionnaire_uuid' => 'uuid']) ->viaTable('question', ['questionnaire_id' => 'questionnaire_id'])
->where(['answer_flag' => '1']) ->where(['answer_flag' => '1'])
->andWhere(['status' => '1']) ->andWhere(['status' => '1'])
->count(); ->count();
@ -162,9 +162,10 @@ class UserQuestionnaire extends ActiveRecord
*/ */
public function numOpenQuestionsAnswers() public function numOpenQuestionsAnswers()
{ {
return $this->hasMany(Question::className(), ['id' => 'question_id']) return $this->hasMany(Question::className(), ['questionnaire_id' => 'id'])
->viaTable('user_response', ['user_questionnaire_uuid' => 'uuid']) ->viaTable('questionnaire', ['id' => 'questionnaire_id'])
->where(['question_type_id' => '1']) ->where(['question_type_id' => '1'])
->andWhere(['status' => '1'])
->count(); ->count();
} }

View File

@ -97005,3 +97005,29 @@
127.0.0.1 - - [11/Mar/2022:10:48:38 +0300] "GET /reports/ajax/get-reports-for-day-by-date?date=2022-01-31 HTTP/1.1" 200 456 "http://backend.guild.loc/reports/reports" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" 127.0.0.1 - - [11/Mar/2022:10:48:38 +0300] "GET /reports/ajax/get-reports-for-day-by-date?date=2022-01-31 HTTP/1.1" 200 456 "http://backend.guild.loc/reports/reports" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [11/Mar/2022:10:48:38 +0300] "GET /reports/ajax/get-reports-for-month-by-id-year-month?&month=01&year=2022 HTTP/1.1" 200 12 "http://backend.guild.loc/reports/reports" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" 127.0.0.1 - - [11/Mar/2022:10:48:38 +0300] "GET /reports/ajax/get-reports-for-month-by-id-year-month?&month=01&year=2022 HTTP/1.1" 200 12 "http://backend.guild.loc/reports/reports" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [11/Mar/2022:10:48:38 +0300] "GET /reports/ajax/get-reports-for-day-by-date?date=2022-01-31 HTTP/1.1" 200 456 "http://backend.guild.loc/reports/reports" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" 127.0.0.1 - - [11/Mar/2022:10:48:38 +0300] "GET /reports/ajax/get-reports-for-day-by-date?date=2022-01-31 HTTP/1.1" 200 456 "http://backend.guild.loc/reports/reports" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:51 +0300] "GET /questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1" 200 13709 "http://backend.guild.loc/questionnaire/user-questionnaire/view?id=1" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/39b83f70/css/select2.css HTTP/1.1" 200 17358 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/71772193/css/bootstrap.css HTTP/1.1" 200 145933 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/5b57ee2f/css/select2-addl.css HTTP/1.1" 200 994 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/5b57ee2f/css/select2-krajee.css HTTP/1.1" 200 20817 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/bae3a4f/css/kv-widgets.css HTTP/1.1" 200 813 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /css/site.css HTTP/1.1" 200 805 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/ccdf1f3a/css/font-awesome.min.css HTTP/1.1" 200 31000 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/cd83ad4b/css/AdminLTE.min.css HTTP/1.1" 200 106548 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/cd83ad4b/css/skins/_all-skins.min.css HTTP/1.1" 200 41635 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/cd83ad4b/img/user2-160x160.jpg HTTP/1.1" 200 7070 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/5aa3f20b/jquery.js HTTP/1.1" 200 288580 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/27128343/yii.js HTTP/1.1" 200 20934 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/39b83f70/js/i18n/ru.js HTTP/1.1" 200 1171 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/39b83f70/js/select2.full.js HTTP/1.1" 200 173566 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/5b57ee2f/js/select2-krajee.js HTTP/1.1" 200 7344 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/bae3a4f/js/kv-widgets.js HTTP/1.1" 200 1061 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/27128343/yii.validation.js HTTP/1.1" 200 16405 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/27128343/yii.activeForm.js HTTP/1.1" 200 36765 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /js/site.js HTTP/1.1" 200 1214 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/71772193/js/bootstrap.js HTTP/1.1" 200 75484 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/cd83ad4b/js/adminlte.min.js HTTP/1.1" 200 13611 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /debug/default/toolbar?tag=6231a1a376864 HTTP/1.1" 200 3426 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/bae3a4f/img/loading-plugin.gif HTTP/1.1" 200 847 "http://backend.guild.loc/assets/bae3a4f/css/kv-widgets.css" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:52 +0300] "GET /assets/ccdf1f3a/fonts/fontawesome-webfont.woff2?v=4.7.0 HTTP/1.1" 200 77160 "http://backend.guild.loc/assets/ccdf1f3a/css/font-awesome.min.css" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"
127.0.0.1 - - [16/Mar/2022:11:36:53 +0300] "GET /favicon.ico HTTP/1.1" 200 318 "http://backend.guild.loc/questionnaire/user-response/update?id=218&user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0"