add count current answers at user Questionnaire

This commit is contained in:
2024-02-07 00:38:10 +03:00
parent 4845f7944b
commit 6d23a9825a
3 changed files with 33 additions and 3 deletions

View File

@ -68,6 +68,12 @@ namespace frontend\modules\api\models\questionnaire;
* description="Количество вопросов"
* ),
* @OA\Property(
* property="count_correct_answers",
* type="int",
* example="18",
* description="Количество правильных ответов"
* ),
* @OA\Property(
* property="time_limit",
* type="string",
* example="00:50:00",
@ -88,8 +94,8 @@ namespace frontend\modules\api\models\questionnaire;
* schema="UserQuestionnaireArrExample",
* type="array",
* example={
* {"uuid": "d222f858-60fd-47fb-8731-dc9d5fc384c5", "score": 11, "status": 2, "percent_correct_answers": 0.25, "testing_date": "2022-04-03 09:23:45", "questionnaire_title": "Тест 2", "description": "Описание", "points_number": "22", "number_questions": "15", "time_limit": "00:50:00"},
* {"uuid": "gcjs77d9-vtyd-02jh-9467-dc8fbb6s6jdb", "score": 20, "status": 2, "percent_correct_answers": 0.85, "testing_date": "2022-03-17 11:14:22", "questionnaire_title": "Тест 1", "description": "Описание", "points_number": "80", "number_questions": "35", "time_limit": "01:10:00"},
* {"uuid": "d222f858-60fd-47fb-8731-dc9d5fc384c5", "score": 11, "status": 2, "percent_correct_answers": 0.25, "testing_date": "2022-04-03 09:23:45", "questionnaire_title": "Тест 2", "description": "Описание", "points_number": "22", "number_questions": "15", "count_correct_answers": "13", "time_limit": "00:50:00"},
* {"uuid": "gcjs77d9-vtyd-02jh-9467-dc8fbb6s6jdb", "score": 20, "status": 2, "percent_correct_answers": 0.85, "testing_date": "2022-03-17 11:14:22", "questionnaire_title": "Тест 1", "description": "Описание", "points_number": "80", "number_questions": "35", "count_correct_answers": "25", "time_limit": "01:10:00"},
* },
* @OA\Items(
* type="object",
@ -104,6 +110,7 @@ namespace frontend\modules\api\models\questionnaire;
* @OA\Property(
* property="status",
* type="integer",
* description="Статус опроса"
* ),
* @OA\Property(
* property="percent_correct_answers",
@ -130,6 +137,10 @@ namespace frontend\modules\api\models\questionnaire;
* type="int",
* ),
* @OA\Property(
* property="count_correct_answers",
* type="int",
* ),
* @OA\Property(
* property="time_limit",
* type="string",
* ),
@ -166,6 +177,9 @@ class UserQuestionnaire extends \common\models\UserQuestionnaire
->andWhere(['status' => 1])
->count();
},
'count_correct_answers' => function () {
return $this->countCorrectAnswers($this->questionnaire_id);
},
'time_limit' => function () {
return $this->questionnaire->time_limit;
}