|
@@ -30,8 +30,8 @@ function CheckboxesGroup(props) {
|
30
|
30
|
|
31
|
31
|
let { quiz, save, responses : resp, id:index} = props;
|
32
|
32
|
|
33
|
|
- const [checkA, setCheckA] = React.useState( 0);
|
34
|
|
- const [checkB, setCheckB] = React.useState(0);
|
|
33
|
+ const [checkA, setCheckA] = React.useState(resp[index]? resp[index].A : 0);
|
|
34
|
+ const [checkB, setCheckB] = React.useState(resp[index]? resp[index].B : 0);
|
35
|
35
|
|
36
|
36
|
const changeA = (event) => {
|
37
|
37
|
let { id, checked } = event.target
|
|
@@ -40,10 +40,12 @@ function CheckboxesGroup(props) {
|
40
|
40
|
let temp = {
|
41
|
41
|
[index]: {
|
42
|
42
|
A:id,
|
43
|
|
- B: resp[id]?.B ? resp[id].B : 0
|
|
43
|
+ B: resp[index] ? resp[index].B : 0
|
44
|
44
|
}
|
45
|
45
|
}
|
46
|
|
- save(Object.assign(resp,temp))
|
|
46
|
+ let final = Object.assign(resp,temp);
|
|
47
|
+ console.log('Change A:',final)
|
|
48
|
+ save(final)
|
47
|
49
|
}
|
48
|
50
|
};
|
49
|
51
|
|
|
@@ -54,10 +56,12 @@ function CheckboxesGroup(props) {
|
54
|
56
|
let temp = {
|
55
|
57
|
[index]: {
|
56
|
58
|
B:id,
|
57
|
|
- A: resp[id]?.A ? resp[id].A : 0
|
|
59
|
+ A: resp[index] ? resp[index].A : 0
|
58
|
60
|
}
|
59
|
61
|
}
|
60
|
|
- save(Object.assign(resp,temp))
|
|
62
|
+ let final = Object.assign(resp,temp)
|
|
63
|
+ console.log('Change B: ', final);
|
|
64
|
+ save(final)
|
61
|
65
|
}
|
62
|
66
|
};
|
63
|
67
|
|
|
@@ -124,7 +128,7 @@ export function Question({quiz, index, current, save, responses}) {
|
124
|
128
|
<CardContent>
|
125
|
129
|
<div variant="body2">
|
126
|
130
|
<List>
|
127
|
|
- <CheckboxexHeader group={index + 1} title={instrucciondepregunta}/>
|
|
131
|
+ <CheckboxexHeader group={id} title={instrucciondepregunta}/>
|
128
|
132
|
</List>
|
129
|
133
|
<CheckboxesGroup
|
130
|
134
|
id={id}
|