diff --git a/backend/modules/questionnaire/views/user-response/index.php b/backend/modules/questionnaire/views/user-response/index.php index ba97d41..52a3b82 100644 --- a/backend/modules/questionnaire/views/user-response/index.php +++ b/backend/modules/questionnaire/views/user-response/index.php @@ -20,13 +20,6 @@ $this->params['breadcrumbs'][] = $this->title; 'btn btn-success']) ?>

- render('_search_by_questionnaire', [ -// 'model' => $searchModel, -// ]) - ?> - - $dataProvider, 'filterModel' => $searchModel, diff --git a/common/helpers/AnswerHelper.php b/common/helpers/AnswerHelper.php index afd3d4b..baf5f3e 100644 --- a/common/helpers/AnswerHelper.php +++ b/common/helpers/AnswerHelper.php @@ -10,12 +10,14 @@ class AnswerHelper { const FLAG_TRUE = 1; const FLAG_FALSE = 0; + const FLAG_NOT_VERIFIED = null; public static function answerFlagsList(): array { return [ self::FLAG_TRUE => 'Верен', self::FLAG_FALSE => 'Ошибочный', + self::FLAG_NOT_VERIFIED => 'Не проверен', ]; } @@ -24,15 +26,15 @@ class AnswerHelper */ public static function answerFlagLabel($status): string { - switch ($status) { - case self::FLAG_FALSE: + switch (true) { + case ($status === self::FLAG_FALSE): $class = 'label label-danger'; break; - case self::FLAG_TRUE: + case ($status === self::FLAG_TRUE): $class = 'label label-success'; break; default: - $class = 'label label-default'; + $class = 'label label-warning'; } return Html::tag('span', ArrayHelper::getValue(self::answerFlagsList(), $status), [ diff --git a/common/services/ScoreCalculatorService.php b/common/services/ScoreCalculatorService.php index 4168319..b7318de 100644 --- a/common/services/ScoreCalculatorService.php +++ b/common/services/ScoreCalculatorService.php @@ -5,6 +5,7 @@ namespace common\services; use backend\modules\questionnaire\models\Answer; use common\models\UserQuestionnaire; use common\models\UserResponse; +use yii\base\InvalidConfigException; use yii\helpers\ArrayHelper; class ScoreCalculatorService @@ -44,6 +45,9 @@ class ScoreCalculatorService return true; } + /** + * @throws InvalidConfigException + */ public static function calculateScore(UserQuestionnaire $userQuestionnaire) { $responses_questions = $userQuestionnaire->hasMany(UserResponse::className(), ['user_questionnaire_uuid' => 'uuid']) @@ -71,11 +75,9 @@ class ScoreCalculatorService } } -// if($score !== null) { self::setPercentCorrectAnswers($user_correct_answers_num, $userQuestionnaire); $userQuestionnaire->score = round($score); $userQuestionnaire->save(); -// } } protected static function isCorrect($answer_flag): bool @@ -91,6 +93,9 @@ class ScoreCalculatorService return Answer::numCorrectAnswers($question_id); } + /** + * @throws InvalidConfigException + */ protected static function setPercentCorrectAnswers($user_correct_answers_num, UserQuestionnaire $userQuestionnaire) { if($user_correct_answers_num !== null) {