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
|
|
|
|
2023-11-16 11:55:49 +03:00
|
|
|
use yii\db\ActiveQuery;
|
2023-10-10 15:06:01 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @OA\Schema(
|
|
|
|
* schema="Question",
|
|
|
|
* @OA\Property(
|
|
|
|
* property="id",
|
|
|
|
* type="int",
|
|
|
|
* example=1,
|
|
|
|
* description="Идентификатор вопроса"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="question_type_id",
|
|
|
|
* type="int",
|
|
|
|
* example="2",
|
|
|
|
* description="Тип вопроса: 1 - Открытый вопрос; 2 - Один правильный ответ; 3 - Несколько вариантов ответа; 4 - 'Истина - ложь'"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="question_body",
|
|
|
|
* type="string",
|
|
|
|
* example="Вопрос №1",
|
|
|
|
* description="Тело вопроса"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="question_priority",
|
|
|
|
* type="int",
|
|
|
|
* example="2",
|
|
|
|
* description="Приоритет вопроса"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="next_question",
|
|
|
|
* type="int",
|
|
|
|
* example="5",
|
|
|
|
* description="Следующий вопрос"
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="time_limit",
|
|
|
|
* type="string",
|
|
|
|
* example="00:22:00",
|
|
|
|
* description="Лимит времени на ответ"
|
|
|
|
* ),
|
2023-11-16 11:55:49 +03:00
|
|
|
* @OA\Property(
|
|
|
|
* property="result_profiles",
|
|
|
|
* ref="#/components/schemas/AnswerExampleArr",
|
|
|
|
* ),
|
2023-10-10 15:06:01 +03:00
|
|
|
*)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @OA\Schema(
|
|
|
|
* schema="QuestionExampleArr",
|
|
|
|
* type="array",
|
|
|
|
* @OA\Items(
|
|
|
|
* type="object",
|
|
|
|
* @OA\Property(
|
|
|
|
* property="id",
|
|
|
|
* type="integer",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="question_type_id",
|
|
|
|
* type="integer",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="question_body",
|
|
|
|
* type="string",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="question_priority",
|
|
|
|
* type="integer",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="next_question",
|
|
|
|
* type="integer",
|
|
|
|
* ),
|
|
|
|
* @OA\Property(
|
|
|
|
* property="time_limit",
|
|
|
|
* type="string",
|
|
|
|
* ),
|
2023-11-16 11:55:49 +03:00
|
|
|
* @OA\Property(
|
|
|
|
* property="result_profiles",
|
|
|
|
* ref="#/components/schemas/AnswerExampleArr",
|
|
|
|
* ),
|
2023-10-10 15:06:01 +03:00
|
|
|
* ),
|
|
|
|
*)
|
|
|
|
*
|
2023-11-16 11:55:49 +03:00
|
|
|
* @property Answer[] $answers
|
2023-10-10 15:06:01 +03:00
|
|
|
*/
|
|
|
|
class Question extends \common\models\Question
|
|
|
|
{
|
2023-11-16 11:55:49 +03:00
|
|
|
/**
|
|
|
|
* @return string[]
|
|
|
|
*/
|
|
|
|
public function fields(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'id',
|
|
|
|
'question_type_id',
|
|
|
|
'question_body',
|
|
|
|
'question_priority',
|
|
|
|
'next_question',
|
|
|
|
'time_limit',
|
|
|
|
'answers' => function () {
|
|
|
|
return $this->answers;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string[]
|
|
|
|
*/
|
|
|
|
public function extraFields(): array
|
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
2023-10-10 15:06:01 +03:00
|
|
|
|
2023-11-16 11:55:49 +03:00
|
|
|
/**
|
|
|
|
* @return ActiveQuery
|
|
|
|
*/
|
|
|
|
public function getAnswers(): ActiveQuery
|
|
|
|
{
|
|
|
|
return $this->hasMany(Answer::class, ['question_id' => 'id']);
|
|
|
|
}
|
2023-10-10 15:06:01 +03:00
|
|
|
}
|