2023-10-10 15:06:01 +03:00
|
|
|
<?php
|
|
|
|
|
2023-11-16 11:55:49 +03:00
|
|
|
namespace frontend\modules\api\models\questionnaire;
|
2023-10-10 15:06:01 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @OA\Schema(
|
|
|
|
* schema="UserQuestionnaire",
|
|
|
|
* @OA\Property(
|
|
|
|
* property="user_id",
|
|
|
|
* type="int",
|
|
|
|
* example=1,
|
|
|
|
* description="Идентификатор пользователя"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="uuid",
|
|
|
|
* type="string",
|
|
|
|
* example="d222f858-60fd-47fb-8731-dc9d5fc384c5",
|
|
|
|
* description="uuid"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="score",
|
|
|
|
* type="int",
|
|
|
|
* example="11",
|
|
|
|
* description="Количество балов за тест"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="status",
|
|
|
|
* type="int",
|
|
|
|
* example="2",
|
|
|
|
* description="статус файла"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="percent_correct_answers",
|
|
|
|
* type="float",
|
|
|
|
* example="0.25",
|
|
|
|
* description="Процент правильных ответов"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="testing_date",
|
|
|
|
* type="string",
|
|
|
|
* example="2022-03-17 11:14:22",
|
|
|
|
* description="Дата тестирования"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="questionnaire_title",
|
|
|
|
* type="string",
|
|
|
|
* example="Анкета 1",
|
|
|
|
* description="Название анкеты"
|
|
|
|
* ),
|
2023-11-16 11:55:49 +03:00
|
|
|
* @OA\Property(
|
|
|
|
* property="description",
|
|
|
|
* type="string",
|
|
|
|
* example="Анкета 1",
|
|
|
|
* description="Описание теста"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="points_number",
|
|
|
|
* type="int",
|
|
|
|
* example="80",
|
|
|
|
* description="Количество балов"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="number_questions",
|
|
|
|
* type="int",
|
|
|
|
* example="21",
|
|
|
|
* description="Количество вопросов"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
2024-02-07 00:38:10 +03:00
|
|
|
* property="count_correct_answers",
|
|
|
|
* type="int",
|
|
|
|
* example="18",
|
|
|
|
* description="Количество правильных ответов"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
2023-11-16 11:55:49 +03:00
|
|
|
* property="time_limit",
|
|
|
|
* type="string",
|
|
|
|
* example="00:50:00",
|
|
|
|
* description="Лимит времени на выполнение"
|
|
|
|
* ),
|
2023-10-10 15:06:01 +03:00
|
|
|
*)
|
|
|
|
*
|
|
|
|
* @OA\Schema(
|
|
|
|
* schema="UserQuestionnaireExample",
|
|
|
|
* type="array",
|
|
|
|
* @OA\Items(
|
|
|
|
* type="object",
|
|
|
|
* ref="#/components/schemas/UserQuestionnaire",
|
|
|
|
* ),
|
|
|
|
*)
|
|
|
|
*
|
|
|
|
* @OA\Schema(
|
|
|
|
* schema="UserQuestionnaireArrExample",
|
|
|
|
* type="array",
|
|
|
|
* example={
|
2024-02-07 00:38:10 +03: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"},
|
2023-10-10 15:06:01 +03:00
|
|
|
* },
|
|
|
|
* @OA\Items(
|
|
|
|
* type="object",
|
|
|
|
* @OA\Property(
|
|
|
|
* property="uuid",
|
|
|
|
* type="string",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="score",
|
|
|
|
* type="integer",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="status",
|
|
|
|
* type="integer",
|
2024-02-07 00:38:10 +03:00
|
|
|
* description="Статус опроса"
|
2023-10-10 15:06:01 +03:00
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="percent_correct_answers",
|
|
|
|
* type="float",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="testing_date",
|
|
|
|
* type="string",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="questionnaire_title",
|
|
|
|
* type="string",
|
|
|
|
* ),
|
2023-11-16 11:55:49 +03:00
|
|
|
* @OA\Property(
|
|
|
|
* property="description",
|
|
|
|
* type="string",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="points_number",
|
|
|
|
* type="int",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="number_questions",
|
|
|
|
* type="int",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
2024-02-07 00:38:10 +03:00
|
|
|
* property="count_correct_answers",
|
|
|
|
* type="int",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
2023-11-16 11:55:49 +03:00
|
|
|
* property="time_limit",
|
|
|
|
* type="string",
|
|
|
|
* ),
|
2023-10-10 15:06:01 +03:00
|
|
|
* ),
|
|
|
|
*)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class UserQuestionnaire extends \common\models\UserQuestionnaire
|
|
|
|
{
|
2023-10-26 11:37:04 +03:00
|
|
|
public function fields(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'user_id',
|
|
|
|
'uuid',
|
|
|
|
'score',
|
|
|
|
'status',
|
|
|
|
'percent_correct_answers',
|
|
|
|
'testing_date',
|
2023-11-16 11:55:49 +03:00
|
|
|
'questionnaire_title' => function () {
|
2023-10-26 11:37:04 +03:00
|
|
|
return $this->questionnaire->title;
|
|
|
|
},
|
2023-11-16 11:55:49 +03:00
|
|
|
'description' => function () {
|
2023-10-26 11:37:04 +03:00
|
|
|
return $this->questionnaire->description;
|
|
|
|
},
|
2023-11-16 11:55:49 +03:00
|
|
|
'points_number' => function () {
|
|
|
|
return Question::find()
|
|
|
|
->where(['questionnaire_id' => $this->questionnaire_id])
|
|
|
|
->andWhere(['status' => 1])
|
|
|
|
->sum('score');
|
|
|
|
},
|
|
|
|
'number_questions' => function () {
|
|
|
|
return Question::find()
|
|
|
|
->where(['questionnaire_id' => $this->questionnaire_id])
|
|
|
|
->andWhere(['status' => 1])
|
|
|
|
->count();
|
|
|
|
},
|
2024-02-07 00:38:10 +03:00
|
|
|
'count_correct_answers' => function () {
|
|
|
|
return $this->countCorrectAnswers($this->questionnaire_id);
|
|
|
|
},
|
2023-11-16 11:55:49 +03:00
|
|
|
'time_limit' => function () {
|
|
|
|
return $this->questionnaire->time_limit;
|
|
|
|
}
|
2023-10-26 11:37:04 +03:00
|
|
|
];
|
|
|
|
}
|
2023-10-10 15:06:01 +03:00
|
|
|
|
2023-10-26 11:37:04 +03:00
|
|
|
/**
|
|
|
|
* @return string[]
|
|
|
|
*/
|
|
|
|
public function extraFields(): array
|
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
2023-10-10 15:06:01 +03:00
|
|
|
}
|