quiz
This commit is contained in:
parent
7e5503e576
commit
dcf0bbbe68
@ -1,7 +1,7 @@
|
||||
import moment from "moment";
|
||||
import React, { useState } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
|
||||
import { questionsSelector } from "@redux/quizSlice";
|
||||
|
||||
@ -40,7 +40,6 @@ export const TaskQuiz = ({ timer }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// setLoadingSendAnswers(true);
|
||||
// .finally(() => setLoadingSendAnswers(false));
|
||||
|
||||
@ -51,10 +50,9 @@ export const TaskQuiz = ({ timer }) => {
|
||||
data: {
|
||||
user_id: userId,
|
||||
user_questionnaire_uuid: uuid,
|
||||
userResponses: JSON.stringify(userResponses)
|
||||
userResponses: JSON.stringify(userResponses),
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
}).then(() => {
|
||||
showNotification({
|
||||
show: true,
|
||||
text: "Тест успешно пройден",
|
||||
@ -69,7 +67,7 @@ export const TaskQuiz = ({ timer }) => {
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
})
|
||||
});
|
||||
// .catch((e) => {
|
||||
// showNotification({
|
||||
// show: true,
|
||||
@ -83,7 +81,7 @@ export const TaskQuiz = ({ timer }) => {
|
||||
if (questions[index + 1]?.time_limit !== "00:00:00") setValueTimer();
|
||||
|
||||
// переход на следующий вопрос
|
||||
setIndex((prev) => questions[prev + 1] ? prev + 1 : prev);
|
||||
setIndex((prev) => (questions[prev + 1] ? prev + 1 : prev));
|
||||
};
|
||||
|
||||
const complete = (e) => {
|
||||
|
@ -3,13 +3,16 @@ import { useState } from "react";
|
||||
export const useHandlerFieldTest = ({ questions, indexQuestion }) => {
|
||||
const [userResponses, setUserResponses] = useState([]);
|
||||
const handleChangeCheckbox = (e) => {
|
||||
setUserResponses((prev) =>
|
||||
[...prev.filter((item) => item.question_id !== questions[indexQuestion].id),
|
||||
setUserResponses((prev) => [
|
||||
...prev.filter(
|
||||
(item) => item.question_id !== questions[indexQuestion].id
|
||||
),
|
||||
{
|
||||
question_id: questions[indexQuestion].id,
|
||||
response_body: e.target.value,
|
||||
answer_id: e.target.id ? e.target.id : questions[indexQuestion].id
|
||||
}])
|
||||
answer_id: e.target.id ? e.target.id : questions[indexQuestion].id,
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
// const handleFieldsForm = (e) => {
|
||||
|
Loading…
Reference in New Issue
Block a user