|
@@ -8,6 +8,8 @@ import {
|
8
|
8
|
} from '@mui/material'
|
9
|
9
|
|
10
|
10
|
import { deepPurple } from '@mui/material/colors';
|
|
11
|
+import { useDispatch, useSelector } from 'react-redux';
|
|
12
|
+import { setResponse } from '../../../Slices/cleaverSlice';
|
11
|
13
|
|
12
|
14
|
function LinearProgressWithLabel(props) {
|
13
|
15
|
return (
|
|
@@ -40,10 +42,13 @@ function CheckboxexHeader(prop) {
|
40
|
42
|
|
41
|
43
|
function CheckboxesGroup(props) {
|
42
|
44
|
|
43
|
|
- let { quiz, save, responses : resp, id:index} = props;
|
|
45
|
+ let { quiz, id : index } = props;
|
|
46
|
+
|
|
47
|
+ let resp = useSelector((state) => state.cleaver.responses)
|
44
|
48
|
|
45
|
49
|
const [checkA, setCheckA] = React.useState(resp[index]? resp[index].A : 0);
|
46
|
50
|
const [checkB, setCheckB] = React.useState(resp[index]? resp[index].B : 0);
|
|
51
|
+ const dispatch = useDispatch()
|
47
|
52
|
|
48
|
53
|
const changeA = (event) => {
|
49
|
54
|
let { id, checked } = event.target
|
|
@@ -55,9 +60,8 @@ function CheckboxesGroup(props) {
|
55
|
60
|
B: resp[index] ? resp[index].B : 0
|
56
|
61
|
}
|
57
|
62
|
}
|
58
|
|
- let final = Object.assign(resp,temp);
|
59
|
|
- // console.log('Change A:',final)
|
60
|
|
- save(final)
|
|
63
|
+ // let final = Object.assign(resp,temp);
|
|
64
|
+ dispatch(setResponse(temp))
|
61
|
65
|
}
|
62
|
66
|
};
|
63
|
67
|
|
|
@@ -71,9 +75,8 @@ function CheckboxesGroup(props) {
|
71
|
75
|
A: resp[index] ? resp[index].A : 0
|
72
|
76
|
}
|
73
|
77
|
}
|
74
|
|
- let final = Object.assign(resp,temp)
|
75
|
|
- // console.log('Change B: ', final);
|
76
|
|
- save(final)
|
|
78
|
+ // let final = Object.assign(resp,temp)
|
|
79
|
+ dispatch(setResponse(temp))
|
77
|
80
|
}
|
78
|
81
|
};
|
79
|
82
|
|
|
@@ -131,7 +134,7 @@ function CheckboxesGroup(props) {
|
131
|
134
|
);
|
132
|
135
|
}
|
133
|
136
|
|
134
|
|
-export function Question({quiz, index, current, save, responses, progress}) {
|
|
137
|
+export function Question({quiz, index, current, progress}) {
|
135
|
138
|
let { instrucciondepregunta, respuestas,id } = quiz
|
136
|
139
|
let checked = index === current;
|
137
|
140
|
|
|
@@ -146,12 +149,10 @@ export function Question({quiz, index, current, save, responses, progress}) {
|
146
|
149
|
<CheckboxesGroup
|
147
|
150
|
id={id}
|
148
|
151
|
quiz={respuestas}
|
149
|
|
- save={save}
|
150
|
|
- responses={responses}
|
151
|
152
|
/>
|
152
|
153
|
</div>
|
153
|
154
|
</CardContent>
|
154
|
|
- <LinearProgressWithLabel value={progress} />
|
|
155
|
+ <LinearProgressWithLabel value={progress ? parseInt(progress) : 0 } />
|
155
|
156
|
</Card>
|
156
|
157
|
</Fade>
|
157
|
158
|
);
|