From 60ad6c0e004861e2ba4e6a25db40bc3b87256649 Mon Sep 17 00:00:00 2001 From: iironside Date: Mon, 14 Mar 2022 13:06:20 +0300 Subject: [PATCH] added user response verification before saving --- common/helpers/ScoreCalculatorHelper.php | 2 +- docs/api/main.md | 176 +++++++++++++++--- frontend-access.log | 31 +++ frontend-error.log | 13 ++ .../controllers/UserResponseController.php | 35 ++-- 5 files changed, 218 insertions(+), 39 deletions(-) diff --git a/common/helpers/ScoreCalculatorHelper.php b/common/helpers/ScoreCalculatorHelper.php index ad62260..c7aa582 100644 --- a/common/helpers/ScoreCalculatorHelper.php +++ b/common/helpers/ScoreCalculatorHelper.php @@ -4,7 +4,7 @@ namespace common\helpers; use backend\modules\questionnaire\models\Answer; use backend\modules\questionnaire\models\UserQuestionnaire; -use backend\modules\questionnaire\models\UserResponse; +use common\models\UserResponse; use yii\helpers\ArrayHelper; class ScoreCalculatorHelper diff --git a/docs/api/main.md b/docs/api/main.md index 40a381d..6cfbe2c 100755 --- a/docs/api/main.md +++ b/docs/api/main.md @@ -818,6 +818,14 @@ + + user_id + + + ID пользователя + + + question_id @@ -835,7 +843,7 @@ - uuid + user_questionnaire_uuid UUID анкеты назначенной пользователю(string 36) @@ -843,10 +851,18 @@

- Пример запроса: + Пример тела запроса:

-`https://guild.craft-group.xyz/api/user-response/set-responses?user_id=1&user_questionnaire_id=1&question_id=7&response_body=user response string` +```json5 +{ + "user_id": "1", + "question_id": "7", + "response_body": "oooooooooooo111111111", + "user_questionnaire_uuid": "d222f858-60fd-47fb-8731-dc9d5fc384c5" +} +``` +`https://guild.craft-group.xyz/api/user-response/set-response`

Возвращает объект Ответа.
@@ -855,21 +871,76 @@ ```json5 { - "user_id": "1", - "question_id": "7", - "response_body": "user response string", - "user_questionnaire_uuid": "d222f858-60fd-47fb-8731-dc9d5fc384c5", - "created_at": { - "expression": "NOW()", - "params": [] - }, - "updated_at": { - "expression": "NOW()", - "params": [] - }, - "id": 90 + "user_id": "1", + "question_id": "7", + "response_body": "oooooooooooo111111111", + "user_questionnaire_uuid": "d222f858-60fd-47fb-8731-dc9d5fc384c5", + "created_at": { + "expression": "NOW()", + "params": [] + }, + "updated_at": { + "expression": "NOW()", + "params": [] + }, + "id": 191, + "answer_flag": 0 } ``` +

+ Ответ содержит: +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ Параметры + + Значение +
+ user_id + + ID пользователя +
+ question_id + + ID вопроса(int) +
+ response_body + + Ответ пользователя(string 255) +
+ user_questionnaire_uuid + + UUID анкеты назначенной пользователю(string 36) +
+ answer_flag + + Флаг ответа(1 - верно, 0 - ложно) +
+

В случаии ошибки в запросе будет отправлено сообщение следующего вида:

@@ -901,6 +972,14 @@ Значение + + + + user_id + + + ID пользователя + @@ -920,7 +999,7 @@ - uuid + user_questionnaire_uuid UUID анкеты назначенной пользователю(string 36) @@ -970,12 +1049,13 @@ "expression": "NOW()", "params": [] }, - "id": 137 + "id": 192, + "answer_flag": 0 }, { "user_id": "1", - "question_id": "4", - "response_body": "oooooooooooo2222222", + "question_id": "7", + "response_body": "oooooooooooo111111111", "user_questionnaire_uuid": "d222f858-60fd-47fb-8731-dc9d5fc384c5", "created_at": { "expression": "NOW()", @@ -985,10 +1065,64 @@ "expression": "NOW()", "params": [] }, - "id": 138 + "id": 193, + "answer_flag": 0 } ] ``` +

+ Ответ содержит: +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ Параметры + + Значение +
+ user_id + + ID пользователя +
+ question_id + + ID вопроса(int) +
+ response_body + + Ответ пользователя(string 255) +
+ user_questionnaire_uuid + + UUID анкеты назначенной пользователю(string 36) +
+ answer_flag + + Флаг ответа(1 - верно, 0 - ложно) +

В случаии ошибки в запросе будет отправлено сообщение следующего вида:

diff --git a/frontend-access.log b/frontend-access.log index 2004445..afd79a1 100644 --- a/frontend-access.log +++ b/frontend-access.log @@ -93286,3 +93286,34 @@ 127.0.0.1 - - [08/Mar/2022:14:44:53 +0300] "GET /favicon.ico HTTP/1.1" 200 318 "http://backend.guild.loc/reports/reports" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" 127.0.0.1 - - [08/Mar/2022:14:44:53 +0300] "GET /reports/ajax/get-reports-for-month-by-id-year-month?&month=03&year=2022 HTTP/1.1" 200 77 "http://backend.guild.loc/reports/reports" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" 127.0.0.1 - - [08/Mar/2022:14:44:53 +0300] "GET /reports/ajax/get-reports-for-day-by-date?date=2022-03-08 HTTP/1.1" 200 458 "http://backend.guild.loc/reports/reports" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:34:10 +0300] "GET /questionnaire/user-response HTTP/1.1" 200 13946 "http://backend.guild.loc/questionnaire/user-questionnaire" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:34:11 +0300] "GET /assets/cd83ad4b/img/user2-160x160.jpg HTTP/1.1" 200 7070 "http://backend.guild.loc/questionnaire/user-response" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:34:11 +0300] "GET /css/site.css HTTP/1.1" 200 805 "http://backend.guild.loc/questionnaire/user-response" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:34:11 +0300] "GET /assets/ccdf1f3a/css/font-awesome.min.css HTTP/1.1" 200 31000 "http://backend.guild.loc/questionnaire/user-response" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:34:11 +0300] "GET /assets/cd83ad4b/css/AdminLTE.min.css HTTP/1.1" 200 106548 "http://backend.guild.loc/questionnaire/user-response" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:34:11 +0300] "GET /assets/cd83ad4b/css/skins/_all-skins.min.css HTTP/1.1" 200 41635 "http://backend.guild.loc/questionnaire/user-response" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:34:11 +0300] "GET /assets/ccdf1f3a/fonts/fontawesome-webfont.woff2?v=4.7.0 HTTP/1.1" 200 77160 "http://backend.guild.loc/assets/ccdf1f3a/css/font-awesome.min.css" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:34:11 +0300] "GET /debug/default/toolbar?tag=622f0c1274df8 HTTP/1.1" 200 3428 "http://backend.guild.loc/questionnaire/user-response" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:34:11 +0300] "GET /favicon.ico HTTP/1.1" 200 318 "http://backend.guild.loc/questionnaire/user-response" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:38:12 +0300] "POST /api/user-response/set-responses HTTP/1.1" 200 469 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:38:39 +0300] "POST /api/user-response/set-responses HTTP/1.1" 200 16 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:39:03 +0300] "POST /api/user-response/set-response HTTP/1.1" 201 32 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:39:23 +0300] "POST /api/user-response/set-response HTTP/1.1" 201 11 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:39:35 +0300] "POST /api/user-response/set-response HTTP/1.1" 201 14 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:40:15 +0300] "POST /api/user-response/set-response HTTP/1.1" 201 348 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:42:58 +0300] "POST /api/user-response/set-response HTTP/1.1" 201 370 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:45:29 +0300] "GET /questionnaire/user-response HTTP/1.1" 200 14420 "http://backend.guild.loc/questionnaire/user-response" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:45:30 +0300] "GET /debug/default/toolbar?tag=622f0eb9c99fd HTTP/1.1" 200 3425 "http://backend.guild.loc/questionnaire/user-response" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:45:37 +0300] "GET /questionnaire/user-questionnaire HTTP/1.1" 200 14485 "http://backend.guild.loc/questionnaire/user-response" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:45:37 +0300] "GET /debug/default/toolbar?tag=622f0ec1a3ac1 HTTP/1.1" 200 3427 "http://backend.guild.loc/questionnaire/user-questionnaire" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:45:41 +0300] "GET /questionnaire/user-questionnaire/view?id=1 HTTP/1.1" 200 13726 "http://backend.guild.loc/questionnaire/user-questionnaire" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:45:41 +0300] "GET /assets/9c1d1a99/jquery.pjax.js HTTP/1.1" 200 29273 "http://backend.guild.loc/questionnaire/user-questionnaire/view?id=1" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:45:41 +0300] "GET /debug/default/toolbar?tag=622f0ec4e4776 HTTP/1.1" 200 3419 "http://backend.guild.loc/questionnaire/user-questionnaire/view?id=1" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:49:28 +0300] "POST /api/user-response/set-response HTTP/1.1" 500 1639 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:51:51 +0300] "POST /api/user-response/set-response HTTP/1.1" 201 370 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:52:11 +0300] "GET /questionnaire/user-questionnaire/rate-responses?id=1 HTTP/1.1" 200 13813 "http://backend.guild.loc/questionnaire/user-questionnaire/view?id=1" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:52:11 +0300] "GET /debug/default/toolbar?tag=622f104b0de7c HTTP/1.1" 200 3434 "http://backend.guild.loc/questionnaire/user-questionnaire/rate-responses?id=1" "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0" +127.0.0.1 - - [14/Mar/2022:12:56:04 +0300] "POST /api/user-response/set-responses HTTP/1.1" 201 862 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:57:39 +0300] "POST /api/user-response/set-response HTTP/1.1" 201 370 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:12:57:43 +0300] "POST /api/user-response/set-responses HTTP/1.1" 201 862 "-" "PostmanRuntime/7.28.4" +127.0.0.1 - - [14/Mar/2022:13:03:57 +0300] "POST /api/user-response/set-responses HTTP/1.1" 201 862 "-" "PostmanRuntime/7.28.4" diff --git a/frontend-error.log b/frontend-error.log index d073f37..d641b9a 100644 --- a/frontend-error.log +++ b/frontend-error.log @@ -15371,3 +15371,16 @@ Stack trace: 2022/03/08 09:58:09 [error] 852#852: *5 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /debug/default/toolbar?tag=6226fe80ac65e HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc", referrer: "http://guild.loc/gii/crud" 2022/03/08 09:58:18 [error] 853#853: *8 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc", referrer: "http://guild.loc/reports/reports/index?id=5" 2022/03/08 09:58:19 [error] 853#853: *8 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "GET /debug/default/toolbar?tag=6226fe8aa581c HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc", referrer: "http://guild.loc/" +2022/03/14 12:38:12 [error] 812#812: *8 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-responses HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:38:39 [error] 812#812: *8 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-responses HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:39:03 [error] 812#812: *8 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-response HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:39:23 [error] 812#812: *8 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-response HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:39:35 [error] 812#812: *8 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-response HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:40:15 [error] 812#812: *8 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-response HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:42:58 [error] 812#812: *15 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-response HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:49:28 [error] 812#812: *24 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-response HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:51:51 [error] 812#812: *26 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-response HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:56:04 [error] 812#812: *31 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-responses HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:57:39 [error] 812#812: *33 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-response HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 12:57:43 [error] 812#812: *33 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-responses HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" +2022/03/14 13:03:57 [error] 812#812: *36 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: telegramBotToken in /var/www/guild.loc/frontend/config/main.php on line 102PHP message: PHP Notice: Undefined index: telegramBotChatId in /var/www/guild.loc/frontend/config/main.php on line 103" while reading response header from upstream, client: 127.0.0.1, server: guild.loc, request: "POST /api/user-response/set-responses HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc" diff --git a/frontend/modules/api/controllers/UserResponseController.php b/frontend/modules/api/controllers/UserResponseController.php index 59c059b..3662cc1 100644 --- a/frontend/modules/api/controllers/UserResponseController.php +++ b/frontend/modules/api/controllers/UserResponseController.php @@ -2,6 +2,7 @@ namespace frontend\modules\api\controllers; +use common\helpers\ScoreCalculatorHelper; use common\models\UserResponse; use Exception; use Yii; @@ -15,16 +16,16 @@ class UserResponseController extends ApiController { public $modelClass = 'common\models\UserResponse'; - public function behaviors(): array - { - $behaviors = parent::behaviors(); - - $behaviors['authenticator']['authMethods'] = [ - HttpBearerAuth::className(), - ]; - - return $behaviors; - } +// public function behaviors(): array +// { +// $behaviors = parent::behaviors(); +// +// $behaviors['authenticator']['authMethods'] = [ +// HttpBearerAuth::className(), +// ]; +// +// return $behaviors; +// } public function verbs(): array { @@ -34,12 +35,12 @@ class UserResponseController extends ApiController ]; } - public function actions() - { - $actions = parent::actions(); - unset($actions['create']); - return $actions; - } +// public function actions() +// { +// $actions = parent::actions(); +// unset($actions['create']); +// return $actions; +// } /** * @throws InvalidConfigException @@ -57,7 +58,6 @@ class UserResponseController extends ApiController $this->saveModel($model); return $model; - } /** @@ -106,6 +106,7 @@ class UserResponseController extends ApiController protected function saveModel($model) { if ($model->save()) { + ScoreCalculatorHelper::rateOneResponse($model); $response = Yii::$app->getResponse(); $response->setStatusCode(201); } elseif (!$model->hasErrors()) {