added questionnaire completed method
This commit is contained in:
parent
60ad6c0e00
commit
745c53ed39
@ -3,7 +3,8 @@
|
|||||||
namespace common\helpers;
|
namespace common\helpers;
|
||||||
|
|
||||||
use backend\modules\questionnaire\models\Answer;
|
use backend\modules\questionnaire\models\Answer;
|
||||||
use backend\modules\questionnaire\models\UserQuestionnaire;
|
//use backend\modules\questionnaire\models\UserQuestionnaire;
|
||||||
|
use common\models\UserQuestionnaire;
|
||||||
use common\models\UserResponse;
|
use common\models\UserResponse;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
@ -71,11 +72,11 @@ class ScoreCalculatorHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($score !== null) {
|
// if($score !== null) {
|
||||||
self::setPercentCorrectAnswers($user_correct_answers_num, $userQuestionnaire);
|
self::setPercentCorrectAnswers($user_correct_answers_num, $userQuestionnaire);
|
||||||
$userQuestionnaire->score = round($score);
|
$userQuestionnaire->score = round($score);
|
||||||
$userQuestionnaire->save();
|
$userQuestionnaire->save();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function isCorrect($answer_flag): bool
|
protected static function isCorrect($answer_flag): bool
|
||||||
@ -93,12 +94,16 @@ class ScoreCalculatorHelper
|
|||||||
|
|
||||||
protected static function setPercentCorrectAnswers($user_correct_answers_num, UserQuestionnaire $userQuestionnaire)
|
protected static function setPercentCorrectAnswers($user_correct_answers_num, UserQuestionnaire $userQuestionnaire)
|
||||||
{
|
{
|
||||||
|
if($user_correct_answers_num !== null) {
|
||||||
$all_correct_answers_num = $userQuestionnaire->numCorrectAnswersWithoutOpenQuestions();
|
$all_correct_answers_num = $userQuestionnaire->numCorrectAnswersWithoutOpenQuestions();
|
||||||
$all_correct_answers_num += $userQuestionnaire->numOpenQuestionsAnswers();
|
$all_correct_answers_num += $userQuestionnaire->numOpenQuestionsAnswers();
|
||||||
|
|
||||||
$percent = $user_correct_answers_num / $all_correct_answers_num;
|
$percent = $user_correct_answers_num / $all_correct_answers_num;
|
||||||
|
|
||||||
$userQuestionnaire->percent_correct_answers = round($percent, 2);
|
$userQuestionnaire->percent_correct_answers = round($percent, 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$userQuestionnaire->percent_correct_answers = round($user_correct_answers_num, 2);
|
||||||
|
}
|
||||||
$userQuestionnaire->save();
|
$userQuestionnaire->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -576,6 +576,63 @@
|
|||||||
"type": "yii\\web\\NotFoundHttpException"
|
"type": "yii\\web\\NotFoundHttpException"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Проверить ответы в анкете
|
||||||
|
`https://guild.craft-group.xyz/api/question/get-questions`
|
||||||
|
<p>
|
||||||
|
Для выполнения проверки анкеты необходимо отправить <b>GET</b> запрос на URL https://guild.craft-group.xyz/api/user-questionnaire/questionnaire-completed
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Требуемые параметры запроса:
|
||||||
|
</p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Параметры
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Значение
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
user_questionnaire_uuid
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
UUID анкеты назначеной пользователю
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p>
|
||||||
|
Пример запроса:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
`https://guild.craft-group.xyz/api/user-questionnaire/questionnaire-completed?user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5`
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Возвращает <b>массив</b> объектов <b>Вопросов</b>. <br>
|
||||||
|
Каждый объект <b>Вопрос</b> имеет такой вид:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
```json5
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"questionnaire_id": 1,
|
||||||
|
"user_id": 1,
|
||||||
|
"uuid": "d222f858-60fd-47fb-8731-dc9d5fc384c5",
|
||||||
|
"created_at": "2021-10-20 13:06:12",
|
||||||
|
"updated_at": {
|
||||||
|
"expression": "NOW()",
|
||||||
|
"params": []
|
||||||
|
},
|
||||||
|
"score": 4,
|
||||||
|
"status": 1,
|
||||||
|
"percent_correct_answers": 0.5,
|
||||||
|
"testing_date": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Вопросы анкеты
|
### Вопросы анкеты
|
||||||
`https://guild.craft-group.xyz/api/question/get-questions`
|
`https://guild.craft-group.xyz/api/question/get-questions`
|
||||||
<p>
|
<p>
|
||||||
|
1003
frontend-access.log
1003
frontend-access.log
File diff suppressed because it is too large
Load Diff
@ -15384,3 +15384,25 @@ Stack trace:
|
|||||||
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: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 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"
|
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"
|
||||||
|
2022/03/14 14:51:36 [error] 812#812: *43 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 /api/question/get-questions?uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 14:51:49 [error] 812#812: *43 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 /api/question/get-questions?uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 16:54:57 [error] 812#812: *507 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 /api/user-questionnaire/questionnaires-list?user_id=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 16:55:11 [error] 812#812: *507 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 /api/user-questionnaire/questionnaires-list?user_id=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:06:33 [error] 812#812: *532 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 /api/user-questionnaire/questionnaires-completed?$user_questionnaire_uuid=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:06:52 [error] 812#812: *532 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 /api/user-questionnaire/questionnaires-completed?$user_questionnaire_uuid=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:07:44 [error] 812#812: *532 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:08:17 [error] 812#812: *532 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:10:18 [error] 812#812: *537 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:10:50 [error] 812#812: *537 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:11:32 [error] 812#812: *537 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:12:39 [error] 812#812: *541 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 /api/user-questionnaire/eee?$user_questionnaire_uuid=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:13:03 [error] 812#812: *541 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:13:14 [error] 812#812: *541 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=1 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:13:35 [error] 812#812: *541 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:14:04 [error] 812#812: *541 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:14:56 [error] 812#812: *541 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:15:12 [error] 812#812: *541 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 /api/user-questionnaire/questionnaire-completed?$user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:15:36 [error] 812#812: *541 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 /api/user-questionnaire/questionnaire-completed?user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:34:40 [error] 812#812: *550 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 /api/user-questionnaire/questionnaire-completed?user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:36:37 [error] 812#812: *552 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 /api/user-questionnaire/questionnaire-completed?user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
2022/03/14 17:37:27 [error] 812#812: *552 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 /api/user-questionnaire/questionnaire-completed?user_questionnaire_uuid=d222f858-60fd-47fb-8731-dc9d5fc384c5 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php-fpm.sock:", host: "guild.loc"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace frontend\modules\api\controllers;
|
namespace frontend\modules\api\controllers;
|
||||||
|
|
||||||
|
use common\helpers\ScoreCalculatorHelper;
|
||||||
use common\models\UserQuestionnaire;
|
use common\models\UserQuestionnaire;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\filters\auth\HttpBearerAuth;
|
use yii\filters\auth\HttpBearerAuth;
|
||||||
@ -25,6 +26,7 @@ class UserQuestionnaireController extends ApiController
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'questionnaires-list' => ['get'],
|
'questionnaires-list' => ['get'],
|
||||||
|
'questionnaire-completed' => ['get'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,4 +58,26 @@ class UserQuestionnaireController extends ApiController
|
|||||||
|
|
||||||
return $userQuestionnaireModel;
|
return $userQuestionnaireModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function actionQuestionnaireCompleted()
|
||||||
|
{
|
||||||
|
// return Yii::$app->request;
|
||||||
|
$user_questionnaire_uuid = Yii::$app->request->get('user_questionnaire_uuid');
|
||||||
|
|
||||||
|
if(empty($user_questionnaire_uuid))
|
||||||
|
{
|
||||||
|
throw new NotFoundHttpException('Incorrect user ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
$userQuestionnaireModel = UserQuestionnaire::findOne(['uuid' => $user_questionnaire_uuid]);
|
||||||
|
|
||||||
|
if(empty($userQuestionnaireModel)) {
|
||||||
|
throw new NotFoundHttpException('Active questionnaire not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreCalculatorHelper::rateResponses($userQuestionnaireModel);
|
||||||
|
ScoreCalculatorHelper::calculateScore($userQuestionnaireModel);
|
||||||
|
|
||||||
|
return $userQuestionnaireModel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user