quiz
This commit is contained in:
parent
ec7d0716b3
commit
b0c9884fe4
@ -12,10 +12,12 @@ export const CardAvailableTest = ({ title, description, path, status }) => {
|
|||||||
to={`/${path}`}
|
to={`/${path}`}
|
||||||
aria-disabled={true}
|
aria-disabled={true}
|
||||||
className="card-available-test__container"
|
className="card-available-test__container"
|
||||||
style={{
|
style={
|
||||||
|
{
|
||||||
// opacity: status !== 1 ? 0.3 : 1,
|
// opacity: status !== 1 ? 0.3 : 1,
|
||||||
// pointerEvents: status !== 1 ? "none" : "all",
|
// pointerEvents: status !== 1 ? "none" : "all",
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<div className="card-available-test__top-head">
|
<div className="card-available-test__top-head">
|
||||||
<StarRating />
|
<StarRating />
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export const GetOptionTask = ({ type, answer, handleChange }) => {
|
export const GetOptionTask = ({ type, answer, handleChange }) => {
|
||||||
const {answer_body,id} = answer
|
const { answer_body, id } = answer;
|
||||||
return (
|
return (
|
||||||
<div className="form-task__group" key={id}>
|
<div className="form-task__group" key={id}>
|
||||||
<input
|
<input
|
||||||
|
@ -13,7 +13,6 @@ export const HeaderQuiz = ({ header }) => {
|
|||||||
const userId = localStorage.getItem("id");
|
const userId = localStorage.getItem("id");
|
||||||
const userInfo = useSelector(selectUserInfo);
|
const userInfo = useSelector(selectUserInfo);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{userInfo?.status === 500 ? (
|
{userInfo?.status === 500 ? (
|
||||||
|
@ -1,68 +1,72 @@
|
|||||||
|
import moment from "moment";
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { setQuestions } from "@redux/quizSlice";
|
|
||||||
import StarRating from "@components/StarRating/StarRating";
|
|
||||||
import accempt from "assets/images/quiz/accempt.png";
|
|
||||||
import iconTomer from "assets/images/quiz/timer.png";
|
|
||||||
import { apiRequest } from "@api/request";
|
|
||||||
import moment from "moment";
|
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
|
import { setQuestions } from "@redux/quizSlice";
|
||||||
|
|
||||||
|
import { apiRequest } from "@api/request";
|
||||||
|
|
||||||
import { useNotification } from "@hooks/useNotification";
|
import { useNotification } from "@hooks/useNotification";
|
||||||
|
|
||||||
export const QuizPassingInformation = ({ setStartTest, uuid, timer }) => {
|
import StarRating from "@components/StarRating/StarRating";
|
||||||
|
|
||||||
|
import accempt from "assets/images/quiz/accempt.png";
|
||||||
|
import iconTomer from "assets/images/quiz/timer.png";
|
||||||
|
|
||||||
|
export const QuizPassingInformation = ({ setStartTest, uuid, timer }) => {
|
||||||
const { restart, pause, hours, minutes, seconds, isRunning } = timer;
|
const { restart, pause, hours, minutes, seconds, isRunning } = timer;
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { showNotification } = useNotification();
|
const { showNotification } = useNotification();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const startTesting = () => {
|
const startTesting = () => {
|
||||||
apiRequest(
|
apiRequest(`/question/get-questions?uuid=${uuid}`)
|
||||||
`/question/get-questions?uuid=${uuid}`
|
|
||||||
)
|
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 400) {
|
if (res.status === 400) {
|
||||||
dispatch(setQuestions(null));
|
dispatch(setQuestions(null));
|
||||||
showNotification({
|
showNotification({
|
||||||
show: true,
|
show: true,
|
||||||
text: res?.message || "",
|
text: res?.message || "",
|
||||||
type: "error"
|
type: "error",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dispatch(setQuestions(res));
|
dispatch(setQuestions(res));
|
||||||
setStartTest(true);
|
setStartTest(true);
|
||||||
restart(moment()
|
restart(
|
||||||
|
moment()
|
||||||
.add(res[0]?.time_limit.split(":")[0], "hours")
|
.add(res[0]?.time_limit.split(":")[0], "hours")
|
||||||
.add(res[0]?.time_limit.split(":")[1], "minutes")
|
.add(res[0]?.time_limit.split(":")[1], "minutes")
|
||||||
.add(res[0]?.time_limit.split(":")[2], "seconds"), true);
|
.add(res[0]?.time_limit.split(":")[2], "seconds"),
|
||||||
|
true
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch((e) => {
|
||||||
dispatch(setQuestions(null));
|
dispatch(setQuestions(null));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkTest = () =>
|
||||||
const checkTest = () => apiRequest(
|
apiRequest(
|
||||||
`user-questionnaire/questionnaire-completed?user_questionnaire_uuid=${uuid}`
|
`user-questionnaire/questionnaire-completed?user_questionnaire_uuid=${uuid}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const completeTest = () => apiRequest(
|
const completeTest = () =>
|
||||||
"/user-questionnaire/questionnaire-completed", {
|
apiRequest("/user-questionnaire/questionnaire-completed", {
|
||||||
method: "POST"
|
method: "POST",
|
||||||
});
|
});
|
||||||
|
|
||||||
const finishQuiz = async () => {
|
const finishQuiz = async () => {
|
||||||
Promise.all([checkTest, completeTest])
|
Promise.all([checkTest, completeTest])
|
||||||
.then(function() {
|
.then(function () {
|
||||||
pause();
|
pause();
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch((e) => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="quiz-passing-information">
|
<div className="quiz-passing-information">
|
||||||
<div className="quiz-passing-information__container">
|
<div className="quiz-passing-information__container">
|
||||||
@ -79,7 +83,8 @@ export const QuizPassingInformation = ({ setStartTest, uuid, timer }) => {
|
|||||||
разработчик
|
разработчик
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{isRunning && <div className="quiz-passing-information__timer timer-quiz">
|
{isRunning && (
|
||||||
|
<div className="quiz-passing-information__timer timer-quiz">
|
||||||
<div className="quiz-passing-information__icon">
|
<div className="quiz-passing-information__icon">
|
||||||
<img src={iconTomer} alt="" />
|
<img src={iconTomer} alt="" />
|
||||||
</div>
|
</div>
|
||||||
@ -91,13 +96,14 @@ export const QuizPassingInformation = ({ setStartTest, uuid, timer }) => {
|
|||||||
":" +
|
":" +
|
||||||
minutes.toString().padStart(2, "0") +
|
minutes.toString().padStart(2, "0") +
|
||||||
":" +
|
":" +
|
||||||
seconds.toString().padStart(2, "0")
|
seconds.toString().padStart(2, "0")}
|
||||||
}
|
|
||||||
секунд
|
секунд
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>}
|
</div>
|
||||||
{!isRunning && <div className="quiz-passing-information__attempt">
|
)}
|
||||||
|
{!isRunning && (
|
||||||
|
<div className="quiz-passing-information__attempt">
|
||||||
<div className="quiz-passing-information__icon">
|
<div className="quiz-passing-information__icon">
|
||||||
<img src={accempt} alt="" />
|
<img src={accempt} alt="" />
|
||||||
</div>
|
</div>
|
||||||
@ -105,7 +111,8 @@ export const QuizPassingInformation = ({ setStartTest, uuid, timer }) => {
|
|||||||
Попыток прохождения: <br />
|
Попыток прохождения: <br />
|
||||||
<span>1 попытка</span>
|
<span>1 попытка</span>
|
||||||
</div>
|
</div>
|
||||||
</div>}
|
</div>
|
||||||
|
)}
|
||||||
<div>
|
<div>
|
||||||
{!isRunning && (
|
{!isRunning && (
|
||||||
<button
|
<button
|
||||||
@ -116,8 +123,14 @@ export const QuizPassingInformation = ({ setStartTest, uuid, timer }) => {
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{isRunning &&
|
{isRunning && (
|
||||||
<button className="quiz-passing-information__button quiz-btn" onClick={finishQuiz}>Завершить</button>}
|
<button
|
||||||
|
className="quiz-passing-information__button quiz-btn"
|
||||||
|
onClick={finishQuiz}
|
||||||
|
>
|
||||||
|
Завершить
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
|
import moment from "moment";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { questionsSelector } from "@redux/quizSlice";
|
|
||||||
import questionIcon from "assets/images/question.png";
|
|
||||||
import { GetOptionTask } from "./GetOptionTask";
|
|
||||||
import "./quiz.scss";
|
|
||||||
import { useHandlerFieldTest } from "@hooks/useHandlerFieldTest";
|
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import moment from "moment";
|
|
||||||
import { Loader } from "@components/Common/Loader/Loader";
|
import { questionsSelector } from "@redux/quizSlice";
|
||||||
|
|
||||||
import { apiRequest } from "@api/request";
|
import { apiRequest } from "@api/request";
|
||||||
|
|
||||||
|
import { useHandlerFieldTest } from "@hooks/useHandlerFieldTest";
|
||||||
import { useNotification } from "@hooks/useNotification";
|
import { useNotification } from "@hooks/useNotification";
|
||||||
|
|
||||||
export const TaskQuiz = ({ timer }) => {
|
import { Loader } from "@components/Common/Loader/Loader";
|
||||||
|
|
||||||
|
import questionIcon from "assets/images/question.png";
|
||||||
|
|
||||||
|
import { GetOptionTask } from "./GetOptionTask";
|
||||||
|
import "./quiz.scss";
|
||||||
|
|
||||||
|
export const TaskQuiz = ({ timer }) => {
|
||||||
const { restart } = timer;
|
const { restart } = timer;
|
||||||
const { uuid } = useParams();
|
const { uuid } = useParams();
|
||||||
const questions = useSelector(questionsSelector);
|
const questions = useSelector(questionsSelector);
|
||||||
@ -23,13 +28,13 @@ export const TaskQuiz = ({ timer }) => {
|
|||||||
const { values, handleChange, setValues } = useHandlerFieldTest({
|
const { values, handleChange, setValues } = useHandlerFieldTest({
|
||||||
uuid,
|
uuid,
|
||||||
questions,
|
questions,
|
||||||
indexQuestion: index
|
indexQuestion: index,
|
||||||
});
|
});
|
||||||
|
|
||||||
const nextQuestion = async (e) => {
|
const nextQuestion = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
//Проверка на существование овтетов
|
//Проверка на существование овтетов
|
||||||
if (!(values.length)) {
|
if (!values.length) {
|
||||||
alert("Вы не ответили на вопрос");
|
alert("Вы не ответили на вопрос");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -38,16 +43,16 @@ export const TaskQuiz = ({ timer }) => {
|
|||||||
setLoadingSendAnswers(true);
|
setLoadingSendAnswers(true);
|
||||||
await apiRequest(`/user-response/set-responses`, {
|
await apiRequest(`/user-response/set-responses`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: values
|
data: values,
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then((res) => {
|
||||||
if (String(res?.status)[0] !== "2") {
|
if (String(res?.status)[0] !== "2") {
|
||||||
showNotification({
|
showNotification({
|
||||||
show: true,
|
show: true,
|
||||||
text: res?.message || "",
|
text: res?.message || "",
|
||||||
type: "error"
|
type: "error",
|
||||||
});
|
});
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index === questions.length - 1) return;
|
if (index === questions.length - 1) return;
|
||||||
@ -59,11 +64,11 @@ export const TaskQuiz = ({ timer }) => {
|
|||||||
setIndex((prev) => prev + 1);
|
setIndex((prev) => prev + 1);
|
||||||
setValues([]);
|
setValues([]);
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch((e) => {
|
||||||
showNotification({
|
showNotification({
|
||||||
show: true,
|
show: true,
|
||||||
text: e?.message || "",
|
text: e?.message || "",
|
||||||
type: "error"
|
type: "error",
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(() => setLoadingSendAnswers(false));
|
.finally(() => setLoadingSendAnswers(false));
|
||||||
@ -76,17 +81,18 @@ export const TaskQuiz = ({ timer }) => {
|
|||||||
|
|
||||||
const setValueTimer = () => {
|
const setValueTimer = () => {
|
||||||
const time_limit = questions[index + 1].time_limit.split(":");
|
const time_limit = questions[index + 1].time_limit.split(":");
|
||||||
restart(moment()
|
restart(
|
||||||
|
moment()
|
||||||
.add(time_limit[0], "hours")
|
.add(time_limit[0], "hours")
|
||||||
.add(time_limit[1], "minutes")
|
.add(time_limit[1], "minutes")
|
||||||
.add(time_limit[2], "seconds"));
|
.add(time_limit[2], "seconds")
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(questions);
|
console.log(questions);
|
||||||
return (
|
return (
|
||||||
<div className="task">
|
<div className="task">
|
||||||
{
|
{questions ? (
|
||||||
questions ?
|
|
||||||
<div className="task__container">
|
<div className="task__container">
|
||||||
<div className="task__header">
|
<div className="task__header">
|
||||||
<img src={questionIcon} alt="questionIcon" />
|
<img src={questionIcon} alt="questionIcon" />
|
||||||
@ -95,10 +101,13 @@ export const TaskQuiz = ({ timer }) => {
|
|||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="task__body">
|
<div className="task__body">
|
||||||
<form className="task__form form-task"
|
<form
|
||||||
onSubmit={index !== questions.length - 1 ? nextQuestion : complete}>
|
className="task__form form-task"
|
||||||
{
|
onSubmit={
|
||||||
questions[index].question_type_id === 1 ?
|
index !== questions.length - 1 ? nextQuestion : complete
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{questions[index].question_type_id === 1 ? (
|
||||||
<div className="form-task__group">
|
<div className="form-task__group">
|
||||||
<textarea
|
<textarea
|
||||||
className="form-task__field"
|
className="form-task__field"
|
||||||
@ -106,7 +115,8 @@ export const TaskQuiz = ({ timer }) => {
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
: questions[index]?.answers?.map((answer) => (
|
) : (
|
||||||
|
questions[index]?.answers?.map((answer) => (
|
||||||
<GetOptionTask
|
<GetOptionTask
|
||||||
key={answer.id}
|
key={answer.id}
|
||||||
type={questions[index].question_type_id}
|
type={questions[index].question_type_id}
|
||||||
@ -114,25 +124,28 @@ export const TaskQuiz = ({ timer }) => {
|
|||||||
answer={answer}
|
answer={answer}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
}
|
)}
|
||||||
<div className="form-task__buttons">
|
<div className="form-task__buttons">
|
||||||
<button
|
<button
|
||||||
onClick={nextQuestion}
|
onClick={nextQuestion}
|
||||||
disabled={isLoadingSendAnswers}
|
disabled={isLoadingSendAnswers}
|
||||||
className="form-task__btn quiz-btn"
|
className="form-task__btn quiz-btn"
|
||||||
>
|
>
|
||||||
{isLoadingSendAnswers ? <Loader width={25} height={25} />
|
{isLoadingSendAnswers ? (
|
||||||
: (index !== questions.length - 1 ? "Далее" : "Завершить")
|
<Loader width={25} height={25} />
|
||||||
}
|
) : index !== questions.length - 1 ? (
|
||||||
|
"Далее"
|
||||||
|
) : (
|
||||||
|
"Завершить"
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
:
|
) : (
|
||||||
<h1>ОШибка</h1>
|
<h1>ОШибка</h1>
|
||||||
}
|
)}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,40 +1,42 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export const useHandlerFieldTest = ({uuid,questions,indexQuestion}) => {
|
export const useHandlerFieldTest = ({ uuid, questions, indexQuestion }) => {
|
||||||
const [values, setValues] = useState([])
|
const [values, setValues] = useState([]);
|
||||||
const id = localStorage.getItem("id");
|
const id = localStorage.getItem("id");
|
||||||
const handleChangeCheckbox = (e) => {
|
const handleChangeCheckbox = (e) => {
|
||||||
if (!e.target.checked) {
|
if (!e.target.checked) {
|
||||||
setValues((prev) => [
|
setValues((prev) => [
|
||||||
...prev.filter((item) => item.response_body !== e.target.value)
|
...prev.filter((item) => item.response_body !== e.target.value),
|
||||||
]);
|
]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setValues((prev) => [
|
setValues((prev) => [
|
||||||
...prev, {
|
...prev,
|
||||||
|
{
|
||||||
user_id: id,
|
user_id: id,
|
||||||
user_questionnaire_uuid: uuid,
|
user_questionnaire_uuid: uuid,
|
||||||
question_id: questions[indexQuestion].id,
|
question_id: questions[indexQuestion].id,
|
||||||
response_body: e.target.value
|
response_body: e.target.value,
|
||||||
}
|
},
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFieldsForm = (e) => {
|
const handleFieldsForm = (e) => {
|
||||||
setValues([{
|
setValues([
|
||||||
|
{
|
||||||
user_id: id,
|
user_id: id,
|
||||||
user_questionnaire_uuid: uuid,
|
user_questionnaire_uuid: uuid,
|
||||||
question_id: questions[indexQuestion].id,
|
question_id: questions[indexQuestion].id,
|
||||||
response_body: e.target.value
|
response_body: e.target.value,
|
||||||
}
|
},
|
||||||
]);
|
]);
|
||||||
}
|
};
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
if (+questions[indexQuestion].question_type_id !== 3) {
|
if (+questions[indexQuestion].question_type_id !== 3) {
|
||||||
handleFieldsForm(e)
|
handleFieldsForm(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handleChangeCheckbox(e)
|
handleChangeCheckbox(e);
|
||||||
};
|
};
|
||||||
return {handleChange,values,setValues}
|
return { handleChange, values, setValues };
|
||||||
}
|
};
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
import moment from "moment";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { Link, useNavigate, useParams } from "react-router-dom";
|
import { Link, useNavigate, useParams } from "react-router-dom";
|
||||||
|
import { useTimer } from "react-timer-hook";
|
||||||
|
|
||||||
import { completedTestSelector } from "@redux/quizSlice";
|
import { completedTestSelector } from "@redux/quizSlice";
|
||||||
|
|
||||||
import { Footer } from "@components/Common/Footer/Footer";
|
import { Footer } from "@components/Common/Footer/Footer";
|
||||||
import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs";
|
import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs";
|
||||||
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
|
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
|
||||||
@ -10,32 +14,29 @@ import { BlockCompletedTest } from "@components/features/quiz/BlockCompletedTest
|
|||||||
import { CardIntroduction } from "@components/features/quiz/Card-introduction";
|
import { CardIntroduction } from "@components/features/quiz/Card-introduction";
|
||||||
import { QuizPassingInformation } from "@components/features/quiz/Quiz-passing-information";
|
import { QuizPassingInformation } from "@components/features/quiz/Quiz-passing-information";
|
||||||
import { TaskQuiz } from "@components/features/quiz/Task";
|
import { TaskQuiz } from "@components/features/quiz/Task";
|
||||||
import { useTimer } from "react-timer-hook";
|
|
||||||
import moment from "moment";
|
|
||||||
|
|
||||||
export const PassingTests = () => {
|
export const PassingTests = () => {
|
||||||
|
|
||||||
const [startTest, setStartTest] = useState(false);
|
const [startTest, setStartTest] = useState(false);
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
const completedTest = useSelector(completedTestSelector);
|
const completedTest = useSelector(completedTestSelector);
|
||||||
const { uuid } = useParams()
|
const { uuid } = useParams();
|
||||||
|
|
||||||
const timer = useTimer({
|
const timer = useTimer({
|
||||||
expiryTimestamp: moment(),
|
expiryTimestamp: moment(),
|
||||||
autoStart: false,
|
autoStart: false,
|
||||||
onExpire: () => {
|
onExpire: () => {
|
||||||
navigate("/quiz")
|
navigate("/quiz");
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const onCloseWindow = (e) => {
|
const onCloseWindow = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if(startTest){
|
if (startTest) {
|
||||||
let confirmationMessage = "\o/";
|
let confirmationMessage = "o/";
|
||||||
(e || window.e).returnValue = confirmationMessage;
|
(e || window.e).returnValue = confirmationMessage;
|
||||||
return confirmationMessage;
|
return confirmationMessage;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const introduction = [
|
const introduction = [
|
||||||
{
|
{
|
||||||
@ -56,21 +57,23 @@ export const PassingTests = () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
function onSwitchTab(e) {
|
function onSwitchTab(e) {
|
||||||
console.log(e,document.visibilityState);
|
console.log(e, document.visibilityState);
|
||||||
if (document.visibilityState === "hidden" && startTest) {
|
if (document.visibilityState === "hidden" && startTest) {
|
||||||
alert("Убедительная просьба не покидать страницу и не переключаться. Рассчитывайте только на свои знания и умения!!!")
|
alert(
|
||||||
|
"Убедительная просьба не покидать страницу и не переключаться. Рассчитывайте только на свои знания и умения!!!"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(() => {
|
||||||
window.addEventListener("beforeunload", onCloseWindow);
|
window.addEventListener("beforeunload", onCloseWindow);
|
||||||
window.addEventListener("visibilitychange", onSwitchTab);
|
window.addEventListener("visibilitychange", onSwitchTab);
|
||||||
window.onblur = onSwitchTab
|
window.onblur = onSwitchTab;
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener("beforeunload", onCloseWindow);
|
window.removeEventListener("beforeunload", onCloseWindow);
|
||||||
window.removeEventListener("visibilitychange", onSwitchTab);
|
window.removeEventListener("visibilitychange", onSwitchTab);
|
||||||
}
|
};
|
||||||
}, [startTest])
|
}, [startTest]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="passing-tests-page">
|
<div className="passing-tests-page">
|
||||||
@ -103,7 +106,7 @@ export const PassingTests = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{startTest ? (
|
{startTest ? (
|
||||||
<TaskQuiz timer={timer}/>
|
<TaskQuiz timer={timer} />
|
||||||
) : (
|
) : (
|
||||||
<div className="passing-tests-page__introduction">
|
<div className="passing-tests-page__introduction">
|
||||||
{introduction.map((item, i) => (
|
{introduction.map((item, i) => (
|
||||||
@ -141,5 +144,3 @@ export const PassingTests = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import BackEndImg from "assets/images/partnerProfile/personalBackEnd.svg";
|
|||||||
import "./quiz-page.scss";
|
import "./quiz-page.scss";
|
||||||
|
|
||||||
export const QuizPage = () => {
|
export const QuizPage = () => {
|
||||||
const [questionnaires,setQuestionnaires] = useState([]);
|
const [questionnaires, setQuestionnaires] = useState([]);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [personalInfoItems] = useState([
|
const [personalInfoItems] = useState([
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ export const QuizPage = () => {
|
|||||||
description:
|
description:
|
||||||
"Java PHP Python C# React Vue.js NodeJs Golang Ruby JavaScript",
|
"Java PHP Python C# React Vue.js NodeJs Golang Ruby JavaScript",
|
||||||
available: true,
|
available: true,
|
||||||
img: BackEndImg
|
img: BackEndImg,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Frontend разработчики",
|
title: "Frontend разработчики",
|
||||||
@ -44,14 +44,14 @@ export const QuizPage = () => {
|
|||||||
description:
|
description:
|
||||||
"Java PHP Python C# React Vue.js NodeJs Golang Ruby JavaScript",
|
"Java PHP Python C# React Vue.js NodeJs Golang Ruby JavaScript",
|
||||||
available: true,
|
available: true,
|
||||||
img: FrontendImg
|
img: FrontendImg,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Архитектура проектов",
|
title: "Архитектура проектов",
|
||||||
link: "/registration-candidate",
|
link: "/registration-candidate",
|
||||||
description: "Потоки данных ER ERP CRM CQRS UML BPMN",
|
description: "Потоки данных ER ERP CRM CQRS UML BPMN",
|
||||||
available: true,
|
available: true,
|
||||||
img: ArchitectureImg
|
img: ArchitectureImg,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Дизайн проектов",
|
title: "Дизайн проектов",
|
||||||
@ -59,35 +59,35 @@ export const QuizPage = () => {
|
|||||||
description:
|
description:
|
||||||
"Java PHP Python C# React Vue.js NodeJs Golang Ruby JavaScript",
|
"Java PHP Python C# React Vue.js NodeJs Golang Ruby JavaScript",
|
||||||
available: true,
|
available: true,
|
||||||
img: DesignImg
|
img: DesignImg,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Тестирование проектов",
|
title: "Тестирование проектов",
|
||||||
link: "/registration-candidate",
|
link: "/registration-candidate",
|
||||||
description: "SQL Postman TestRail Kibana Ручное тестирование",
|
description: "SQL Postman TestRail Kibana Ручное тестирование",
|
||||||
available: false,
|
available: false,
|
||||||
img: TestImg
|
img: TestImg,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Администрирование проектов",
|
title: "Администрирование проектов",
|
||||||
link: "/registration-candidate",
|
link: "/registration-candidate",
|
||||||
description: "DevOps ELK Kubernetes Docker Bash Apache Oracle Git",
|
description: "DevOps ELK Kubernetes Docker Bash Apache Oracle Git",
|
||||||
available: false,
|
available: false,
|
||||||
img: AdminImg
|
img: AdminImg,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Управление проектом",
|
title: "Управление проектом",
|
||||||
link: "/registration-candidate",
|
link: "/registration-candidate",
|
||||||
description: "Scrum Kanban Agile Miro CustDev",
|
description: "Scrum Kanban Agile Miro CustDev",
|
||||||
available: false,
|
available: false,
|
||||||
img: ManageImg
|
img: ManageImg,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Копирайтинг проектов",
|
title: "Копирайтинг проектов",
|
||||||
link: "/registration-candidate",
|
link: "/registration-candidate",
|
||||||
description: "Теги Заголовок H1 Дескриптор Абзац Сценарий",
|
description: "Теги Заголовок H1 Дескриптор Абзац Сценарий",
|
||||||
available: false,
|
available: false,
|
||||||
img: CopyImg
|
img: CopyImg,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Реклама и SMM",
|
title: "Реклама и SMM",
|
||||||
@ -95,18 +95,16 @@ export const QuizPage = () => {
|
|||||||
description:
|
description:
|
||||||
"Java PHP Python C# React Vue.js NodeJs Golang Ruby JavaScript",
|
"Java PHP Python C# React Vue.js NodeJs Golang Ruby JavaScript",
|
||||||
available: false,
|
available: false,
|
||||||
img: SmmImg
|
img: SmmImg,
|
||||||
}
|
},
|
||||||
]);
|
]);
|
||||||
const userId = localStorage.getItem("id");
|
const userId = localStorage.getItem("id");
|
||||||
const [selectedCategory, setSetSelectedCategory] = useState(false);
|
const [selectedCategory, setSetSelectedCategory] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
apiRequest(
|
apiRequest(`/user-questionnaire/questionnaires-list?user_id=${userId}`)
|
||||||
`/user-questionnaire/questionnaires-list?user_id=${userId}`
|
.then((res) => setQuestionnaires(res))
|
||||||
)
|
.catch((e) => console.log(e));
|
||||||
.then(res => setQuestionnaires(res))
|
|
||||||
.catch(e => console.log(e));
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -117,7 +115,7 @@ export const QuizPage = () => {
|
|||||||
<ProfileBreadcrumbs
|
<ProfileBreadcrumbs
|
||||||
links={[
|
links={[
|
||||||
{ name: "Главная", link: "/profile-candidate" },
|
{ name: "Главная", link: "/profile-candidate" },
|
||||||
{ name: "Тестирование", link: "/quiz" }
|
{ name: "Тестирование", link: "/quiz" },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<div className="quiz-page__title main-title">
|
<div className="quiz-page__title main-title">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
|
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
import { apiRequest } from "@api/request";
|
import { apiRequest } from "@api/request";
|
||||||
import moment from "moment";
|
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
questions: null,
|
questions: null,
|
||||||
@ -11,9 +11,7 @@ const initialState = {
|
|||||||
result: null,
|
result: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchResultTest = createAsyncThunk(
|
export const fetchResultTest = createAsyncThunk("result", (uuid) =>
|
||||||
"result",
|
|
||||||
(uuid) =>
|
|
||||||
apiRequest(
|
apiRequest(
|
||||||
`/user-questionnaire/questionnaire-completed?user_questionnaire_uuid=${uuid}`
|
`/user-questionnaire/questionnaire-completed?user_questionnaire_uuid=${uuid}`
|
||||||
)
|
)
|
||||||
@ -28,19 +26,16 @@ export const quizSlice = createSlice({
|
|||||||
},
|
},
|
||||||
setCompleteTest: (state) => {
|
setCompleteTest: (state) => {
|
||||||
state.completedTest = true;
|
state.completedTest = true;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
extraReducers: {
|
extraReducers: {
|
||||||
[fetchResultTest.fulfilled]: (state, action) => {
|
[fetchResultTest.fulfilled]: (state, action) => {
|
||||||
state.result = action.payload;
|
state.result = action.payload;
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const {
|
export const { setQuestions } = quizSlice.actions;
|
||||||
setQuestions,
|
|
||||||
} = quizSlice.actions;
|
|
||||||
|
|
||||||
|
|
||||||
export const questionnairesSelector = (state) => state.quiz.questionnaires;
|
export const questionnairesSelector = (state) => state.quiz.questionnaires;
|
||||||
export const questionsSelector = (state) => state.quiz.questions;
|
export const questionsSelector = (state) => state.quiz.questions;
|
||||||
@ -49,5 +44,4 @@ export const completedTestSelector = (state) => state.quiz.completedTest;
|
|||||||
export const selectResult = (state) => state.quiz.result;
|
export const selectResult = (state) => state.quiz.result;
|
||||||
export const selectedTest = (state) => state.quiz.selectedTest;
|
export const selectedTest = (state) => state.quiz.selectedTest;
|
||||||
|
|
||||||
|
|
||||||
export default quizSlice.reducer;
|
export default quizSlice.reducer;
|
||||||
|
Loading…
Reference in New Issue
Block a user