refactored quiz slice, site loads
This commit is contained in:
@@ -10,25 +10,26 @@ import { mixUp, startTesting, stopTesting } from './quizSlice';
|
||||
|
||||
function QuizStats() {
|
||||
|
||||
const checkTask = (index: number): string => {
|
||||
useSelector((state: RootState) => state.lists.lists[index]);
|
||||
const correctCount = (index: number):number => {
|
||||
let quiz = useSelector((state: RootState) => state.quiz);
|
||||
let state = store.getState();
|
||||
if (state.lists.correctAnswers.length <= index) {
|
||||
return "";
|
||||
if (state.quiz.correctAnswers.length <= index) {
|
||||
return 0;
|
||||
}
|
||||
let correctCounter = state.lists.lists[index].reduce((prev, answ, i) => prev + Number(state.lists.correctAnswers[index][i] === answ), 0)
|
||||
return quiz.userAnswers[index].reduce((prev, answ, i) => prev + Number(quiz.correctAnswers[index][i] === answ), 0);
|
||||
}
|
||||
|
||||
if (correctCounter == state.lists.lists[index].length) {
|
||||
const quizPartText = (counter:number, len:number):string=>{
|
||||
if (counter == len) {
|
||||
return "все ответы верные"
|
||||
}
|
||||
return `верно ${correctCounter}/${state.lists.lists[index].length}`
|
||||
|
||||
return `верно ${counter}/${len}`
|
||||
}
|
||||
return (
|
||||
<Container sx={{ margin: "auto" }}>
|
||||
<h3>Результаты теста</h3>
|
||||
<Typography>Задание 1: {checkTask(0)}</Typography>
|
||||
<Typography>Задание 2: {checkTask(1)}</Typography>
|
||||
{/* <Typography>Задание 1: {checkTask(0)}</Typography> */}
|
||||
{/* <Typography>Задание 2: {checkTask(1)}</Typography> */}
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
@@ -42,6 +43,7 @@ function Quiz() {
|
||||
dispatch(mixUp());
|
||||
dispatch(startTesting());
|
||||
}
|
||||
|
||||
const checkQuiz = () => {
|
||||
setDisplayingResults(true);
|
||||
dispatch(stopTesting());
|
||||
@@ -55,7 +57,7 @@ function Quiz() {
|
||||
<Typography variant="h5" gutterBottom>
|
||||
{index + 1}. {item.title}
|
||||
</Typography>
|
||||
<Matching index={index} tasks={item.tasks} />
|
||||
{[<Matching index={index} tasks={item.tasks} />,<>S</>,<>c</>][(["M","S","C"].indexOf(item.type))]}
|
||||
</Box>
|
||||
))}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user