['get'], ]; } /** * @OA\Get(path="/question/get-questions", * summary="Список вопросов", * description="Получение списка вопросов", * security={ * {"bearerAuth": {}} * }, * tags={"Tests"}, * @OA\Parameter( * name="user", * in="query", * required=true, * description="UUID анкеты назначеной пользователю", * @OA\Schema( * type="integer", * ) * ), * @OA\Response( * response=200, * description="Возвращает масив вопросов", * @OA\MediaType( * mediaType="application/json", * @OA\Schema(ref="#/components/schemas/QuestionExampleArr"), * ), * * * ), * ) * * @throws NotFoundHttpException * @throws \Exception */ public function actionGetQuestions(): array { $uuid = Yii::$app->request->get('uuid'); if(empty($uuid) or !UUIDHelper::is_valid($uuid)) { throw new NotFoundHttpException('Incorrect questionnaire UUID'); } $questionnaire_id = UserQuestionnaire::getQuestionnaireId($uuid); $questions = Question::activeQuestions($questionnaire_id); if(empty($questions)) { throw new NotFoundHttpException('Questions not found'); } array_walk( $questions, function(&$arr){ unset( $arr['score'], $arr['created_at'], $arr['updated_at'], $arr['status'], $arr['questionnaire_id'] ); }); return $questions; } }