update api for test
This commit is contained in:
@ -2,8 +2,9 @@
|
||||
|
||||
namespace frontend\modules\api\controllers;
|
||||
|
||||
use frontend\modules\api\models\UserQuestionnaire;
|
||||
use frontend\modules\api\models\questionnaire\UserQuestionnaire;
|
||||
use frontend\modules\api\services\UserQuestionnaireService;
|
||||
use yii\base\InvalidConfigException;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\web\ServerErrorHttpException;
|
||||
@ -14,14 +15,11 @@ class UserQuestionnaireController extends ApiController
|
||||
public function behaviors(): array
|
||||
{
|
||||
return ArrayHelper::merge(parent::behaviors(), [
|
||||
|
||||
'verbs' => [
|
||||
'class' => \yii\filters\VerbFilter::class,
|
||||
'actions' => [
|
||||
'questionnaires-list' => ['get'],
|
||||
'questionnaire-completed' => ['get'],
|
||||
'get-points-number' => ['get'],
|
||||
'get-question-number' => ['get'],
|
||||
],
|
||||
]
|
||||
]);
|
||||
@ -73,7 +71,7 @@ class UserQuestionnaireController extends ApiController
|
||||
/**
|
||||
* @OA\Get(path="/user-questionnaire/questionnaire-completed",
|
||||
* summary="Проверка теста",
|
||||
* description="Выполнения проверки теста",
|
||||
* description="Выполнение проверки теста",
|
||||
* security={
|
||||
* {"bearerAuth": {}}
|
||||
* },
|
||||
@ -98,7 +96,7 @@ class UserQuestionnaireController extends ApiController
|
||||
* )
|
||||
*
|
||||
* @throws NotFoundHttpException
|
||||
* @throws ServerErrorHttpException
|
||||
* @throws ServerErrorHttpException|InvalidConfigException
|
||||
*/
|
||||
public function actionQuestionnaireCompleted($user_questionnaire_uuid): UserQuestionnaire
|
||||
{
|
||||
@ -108,90 +106,4 @@ class UserQuestionnaireController extends ApiController
|
||||
}
|
||||
return $userQuestionnaireModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(path="/user-questionnaire/get-points-number",
|
||||
* summary="Количество балов в тесте",
|
||||
* description="Возвращает максимальное количество балов за тест",
|
||||
* security={
|
||||
* {"bearerAuth": {}}
|
||||
* },
|
||||
* tags={"Tests"},
|
||||
* @OA\Parameter(
|
||||
* name="user_questionnaire_uuid",
|
||||
* in="query",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Возвращает максимально возможное количество балов за тест",
|
||||
* @OA\MediaType(
|
||||
* mediaType="application/json",
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="sum_point",
|
||||
* type="integer",
|
||||
* example="61",
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
*
|
||||
* ),
|
||||
* )
|
||||
* @throws ServerErrorHttpException
|
||||
*/
|
||||
public function actionGetPointsNumber($user_questionnaire_uuid): array
|
||||
{
|
||||
$questionPointsNumber = UserQuestionnaireService::getPointsNumber($user_questionnaire_uuid);
|
||||
if (empty($questionPointsNumber)) {
|
||||
throw new ServerErrorHttpException('Question points not found!');
|
||||
}
|
||||
return $questionPointsNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(path="/user-questionnaire/get-question-number",
|
||||
* summary="Число вопросов в тесте",
|
||||
* description="Возвращает число вопросов в тесте",
|
||||
* security={
|
||||
* {"bearerAuth": {}}
|
||||
* },
|
||||
* tags={"Tests"},
|
||||
* @OA\Parameter(
|
||||
* name="user_questionnaire_uuid",
|
||||
* in="query",
|
||||
* required=true,
|
||||
* @OA\Schema(
|
||||
* type="string",
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Возвращает число вопросов в тесте",
|
||||
* @OA\MediaType(
|
||||
* mediaType="application/json",
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="question_number",
|
||||
* type="integer",
|
||||
* example="61",
|
||||
* ),
|
||||
* ),
|
||||
* ),
|
||||
*
|
||||
* ),
|
||||
* )
|
||||
* @throws ServerErrorHttpException
|
||||
*/
|
||||
public function actionGetQuestionNumber($user_questionnaire_uuid): array
|
||||
{
|
||||
$questionNumber = UserQuestionnaireService::getQuestionNumber($user_questionnaire_uuid);
|
||||
if (empty($questionNumber)) {
|
||||
throw new ServerErrorHttpException('Question number not found!');
|
||||
}
|
||||
return $questionNumber;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user