|
@@ -2,19 +2,20 @@ import React, { useMemo } from 'react'
|
2
|
2
|
import { Service } from '../../Utils/HTTP'
|
3
|
3
|
import useAuth from '../../Auth/useAuth.js';
|
4
|
4
|
import { Question } from '../../Components/Test/Cleaver/Question.jsx'
|
5
|
|
-import { Box,Button, Collapse, List } from '@mui/material'
|
|
5
|
+import { Box,Button, Collapse, List, Slide } from '@mui/material'
|
6
|
6
|
import { TransitionGroup } from 'react-transition-group';
|
7
|
|
-import * as Scroll from 'react-scroll';
|
|
7
|
+// import * as Scroll from 'react-scroll';
|
8
|
8
|
|
9
|
9
|
export function Cleaver() {
|
10
|
10
|
|
11
|
|
-var scroll = Scroll.animateScroll;
|
|
11
|
+// var scroll = Scroll.animateScroll;
|
12
|
12
|
|
13
|
13
|
let auth = useAuth();
|
14
|
14
|
let token = useMemo(() => auth.getToken(), [auth])
|
15
|
15
|
|
16
|
16
|
const [totalRespondidas, setRespondidas] = React.useState([]);
|
17
|
17
|
const [totalPreguntas, setPreguntas] = React.useState([]);
|
|
18
|
+ const [current, setCurrent] = React.useState(0);
|
18
|
19
|
|
19
|
20
|
|
20
|
21
|
React.useEffect(() => {
|
|
@@ -28,38 +29,27 @@ var scroll = Scroll.animateScroll;
|
28
|
29
|
}, [token]);
|
29
|
30
|
|
30
|
31
|
const handleAddQuestion = () => {
|
31
|
|
- let op = { smooth: true, duration: 200, delay :1, offset :20}
|
32
|
|
- scroll.scrollToBottom(op);
|
|
32
|
+ // let op = { smooth: true, duration: 200, delay :1, offset :20}
|
|
33
|
+ // scroll.scrollToBottom(op);
|
33
|
34
|
let currentAnswer = totalRespondidas[totalRespondidas.length - 1];
|
34
|
35
|
const nextHiddenItem = totalPreguntas.filter(({id}) => id !== currentAnswer.id );
|
35
|
36
|
if (nextHiddenItem) {
|
36
|
37
|
setPreguntas(nextHiddenItem);
|
37
|
38
|
let temp = nextHiddenItem.shift()
|
38
|
39
|
setRespondidas([...totalRespondidas,temp]);
|
|
40
|
+ setCurrent(current+1);
|
39
|
41
|
}
|
40
|
|
-
|
41
|
|
- // console.log("RESPONDIDAS: ", totalRespondidas.length)
|
42
|
|
- // console.log("RESTANTES: ", totalPreguntas.length)
|
43
|
42
|
};
|
44
|
43
|
|
45
|
44
|
return (
|
46
|
|
-
|
47
|
45
|
<div className="content-section question">
|
48
|
|
- <div className="main">
|
49
|
|
- <Box sx={{ mt: 1 }}>
|
50
|
|
- <List >
|
51
|
|
- <TransitionGroup >
|
52
|
|
- {totalRespondidas.map((item) => (
|
53
|
|
- <Collapse key={item.id} >
|
54
|
|
- <Question key={item.id} id={item.id} quiz={item} />
|
55
|
|
- </Collapse>
|
56
|
|
- ))
|
57
|
|
- }
|
58
|
|
- </TransitionGroup>
|
59
|
|
- </List>
|
60
|
|
- </Box>
|
|
46
|
+ <Box className="question_body">
|
|
47
|
+ {totalRespondidas.map((item,i) => (
|
|
48
|
+ <Question key={item.id} id={item.id} quiz={item} index={i} current={current} /> )
|
|
49
|
+ )}
|
|
50
|
+ </Box>
|
61
|
51
|
|
62
|
|
- <div className="question_btn">
|
|
52
|
+ <div className="question_btn">
|
63
|
53
|
<Button
|
64
|
54
|
className="nextquestion_btn"
|
65
|
55
|
sx={{ backgroundColor: 'var(--main)' }}
|
|
@@ -67,12 +57,21 @@ var scroll = Scroll.animateScroll;
|
67
|
57
|
disabled={totalPreguntas.length <= 0}
|
68
|
58
|
onClick={handleAddQuestion}
|
69
|
59
|
>
|
70
|
|
- Siguiente Pregunta
|
|
60
|
+ Anterior
|
|
61
|
+ </Button>
|
|
62
|
+ <Button
|
|
63
|
+ className="nextquestion_btn"
|
|
64
|
+ sx={{ backgroundColor: 'var(--main)' }}
|
|
65
|
+ variant="contained"
|
|
66
|
+ disabled={totalPreguntas.length <= 0}
|
|
67
|
+ onClick={handleAddQuestion}
|
|
68
|
+ >
|
|
69
|
+ Siguiente
|
71
|
70
|
</Button>
|
72
|
|
- </div>
|
73
|
|
-
|
74
|
71
|
</div>
|
75
|
72
|
</div>
|
76
|
73
|
)
|
77
|
74
|
|
78
|
75
|
}
|
|
76
|
+
|
|
77
|
+
|