|
@@ -1,11 +1,22 @@
|
1
|
1
|
import React from 'react'
|
2
|
2
|
import { Service } from '../../Utils/HTTP'
|
3
|
3
|
import { Question } from '../../Components/Test/Cleaver/Question.jsx'
|
4
|
|
-import { Box,Button } from '@mui/material'
|
|
4
|
+import { Box,Button, LinearProgress } from '@mui/material'
|
5
|
5
|
import { useSelector } from 'react-redux';
|
6
|
6
|
import { useParams } from 'react-router-dom'
|
7
|
7
|
import toast, { Toaster } from 'react-hot-toast';
|
8
|
8
|
|
|
9
|
+
|
|
10
|
+function LinearProgressWithLabel(props) {
|
|
11
|
+ return (
|
|
12
|
+ <Box sx={{ display: 'flex', alignItems: 'center' }}>
|
|
13
|
+ <Box sx={{ width: '100%', mr: 0 }}>
|
|
14
|
+ <LinearProgress variant="determinate" {...props} />
|
|
15
|
+ </Box>
|
|
16
|
+ </Box>
|
|
17
|
+ );
|
|
18
|
+}
|
|
19
|
+
|
9
|
20
|
export function Cleaver() {
|
10
|
21
|
|
11
|
22
|
let { id } = useParams();
|
|
@@ -36,6 +47,10 @@ export function Cleaver() {
|
36
|
47
|
}).catch(console.log)
|
37
|
48
|
}, [id,auth]);
|
38
|
49
|
|
|
50
|
+ const saveRespones = () => {
|
|
51
|
+ console.log("guardando las respuestas")
|
|
52
|
+ }
|
|
53
|
+
|
39
|
54
|
const handleAddQuestion = () => {
|
40
|
55
|
let currentAnswer = totalRespondidas[totalRespondidas.length - 1];
|
41
|
56
|
let current_resp = cleaver.responses[currentAnswer.id];
|
|
@@ -65,8 +80,14 @@ export function Cleaver() {
|
65
|
80
|
CalculateProgress()
|
66
|
81
|
}
|
67
|
82
|
|
|
83
|
+
|
|
84
|
+
|
68
|
85
|
return (
|
69
|
|
- <div className="content-section question">
|
|
86
|
+ <div>
|
|
87
|
+ <div className="content-section question">
|
|
88
|
+ <div style={{width:'60%', marginBottom : 35}}>
|
|
89
|
+ <LinearProgressWithLabel value={progress ? parseInt(progress) : 0 } />
|
|
90
|
+ </div>
|
70
|
91
|
<Box className="question_body">
|
71
|
92
|
{totalRespondidas.map((item,i) => (
|
72
|
93
|
<Question
|
|
@@ -75,34 +96,52 @@ export function Cleaver() {
|
75
|
96
|
quiz={item}
|
76
|
97
|
index={i}
|
77
|
98
|
current={current}
|
78
|
|
- progress={progress}
|
79
|
99
|
/>)
|
80
|
100
|
)}
|
81
|
101
|
</Box>
|
82
|
102
|
|
83
|
|
- <div className="question_btn">
|
84
|
|
- <Button
|
85
|
|
- className="nextquestion_btn"
|
86
|
|
- sx={{ backgroundColor: 'var(--main)' }}
|
87
|
|
- variant="contained"
|
88
|
|
- disabled={totalRespondidas.length <= 1}
|
89
|
|
- onClick={handleRemoveQuestion}
|
90
|
|
- >
|
91
|
|
- Anterior
|
92
|
|
- </Button>
|
93
|
|
- <Button
|
94
|
|
- className="nextquestion_btn"
|
95
|
|
- sx={{ backgroundColor: 'var(--main)' }}
|
96
|
|
- variant="contained"
|
97
|
|
- disabled={totalPreguntas.length <= 0}
|
98
|
|
- onClick={handleAddQuestion}
|
99
|
|
- >
|
100
|
|
- Siguiente
|
101
|
|
- </Button>
|
102
|
|
- </div>
|
103
|
|
- <Toaster
|
104
|
|
- position="bottom-right"
|
105
|
|
- />
|
|
103
|
+ {
|
|
104
|
+ totalPreguntas.length > 0 ?
|
|
105
|
+ (
|
|
106
|
+ <div className="question_btn">
|
|
107
|
+ <Button
|
|
108
|
+ className="nextquestion_btn"
|
|
109
|
+ sx={{ backgroundColor: 'var(--main)' }}
|
|
110
|
+ variant="contained"
|
|
111
|
+ disabled={totalRespondidas.length <= 1}
|
|
112
|
+ onClick={handleRemoveQuestion}
|
|
113
|
+ >
|
|
114
|
+ Anterior
|
|
115
|
+ </Button>
|
|
116
|
+ <Button
|
|
117
|
+ className="nextquestion_btn"
|
|
118
|
+ sx={{ backgroundColor: 'var(--main)' }}
|
|
119
|
+ variant="contained"
|
|
120
|
+ disabled={totalPreguntas.length <= 0}
|
|
121
|
+ onClick={handleAddQuestion}
|
|
122
|
+ >
|
|
123
|
+ Siguiente
|
|
124
|
+ </Button>
|
|
125
|
+ </div>
|
|
126
|
+ ) : (
|
|
127
|
+
|
|
128
|
+ <div className="question_btn">
|
|
129
|
+ <Button
|
|
130
|
+ className="nextquestion_btn"
|
|
131
|
+ sx={{ backgroundColor: 'var(--main)' }}
|
|
132
|
+ variant="contained"
|
|
133
|
+ onClick={saveRespones}
|
|
134
|
+ >
|
|
135
|
+ Guardar
|
|
136
|
+ </Button>
|
|
137
|
+ </div>
|
|
138
|
+ )
|
|
139
|
+
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ <Toaster position="bottom-right" />
|
|
143
|
+
|
|
144
|
+ </div>
|
106
|
145
|
</div>
|
107
|
146
|
)
|
108
|
147
|
|