|
|
@@ -8,6 +8,8 @@ import {
|
|
|
} from '@mui/material'
|
|
|
|
|
|
import { deepPurple } from '@mui/material/colors';
|
|
|
+import { useDispatch, useSelector } from 'react-redux';
|
|
|
+import { setResponse } from '../../../Slices/cleaverSlice';
|
|
|
|
|
|
function LinearProgressWithLabel(props) {
|
|
|
return (
|
|
|
@@ -40,10 +42,13 @@ function CheckboxexHeader(prop) {
|
|
|
|
|
|
function CheckboxesGroup(props) {
|
|
|
|
|
|
- let { quiz, save, responses : resp, id:index} = props;
|
|
|
+ let { quiz, id : index } = props;
|
|
|
+
|
|
|
+ let resp = useSelector((state) => state.cleaver.responses)
|
|
|
|
|
|
const [checkA, setCheckA] = React.useState(resp[index]? resp[index].A : 0);
|
|
|
const [checkB, setCheckB] = React.useState(resp[index]? resp[index].B : 0);
|
|
|
+ const dispatch = useDispatch()
|
|
|
|
|
|
const changeA = (event) => {
|
|
|
let { id, checked } = event.target
|
|
|
@@ -55,9 +60,8 @@ function CheckboxesGroup(props) {
|
|
|
B: resp[index] ? resp[index].B : 0
|
|
|
}
|
|
|
}
|
|
|
- let final = Object.assign(resp,temp);
|
|
|
- // console.log('Change A:',final)
|
|
|
- save(final)
|
|
|
+ // let final = Object.assign(resp,temp);
|
|
|
+ dispatch(setResponse(temp))
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -71,9 +75,8 @@ function CheckboxesGroup(props) {
|
|
|
A: resp[index] ? resp[index].A : 0
|
|
|
}
|
|
|
}
|
|
|
- let final = Object.assign(resp,temp)
|
|
|
- // console.log('Change B: ', final);
|
|
|
- save(final)
|
|
|
+ // let final = Object.assign(resp,temp)
|
|
|
+ dispatch(setResponse(temp))
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -131,7 +134,7 @@ function CheckboxesGroup(props) {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-export function Question({quiz, index, current, save, responses, progress}) {
|
|
|
+export function Question({quiz, index, current, progress}) {
|
|
|
let { instrucciondepregunta, respuestas,id } = quiz
|
|
|
let checked = index === current;
|
|
|
|
|
|
@@ -146,12 +149,10 @@ export function Question({quiz, index, current, save, responses, progress}) {
|
|
|
<CheckboxesGroup
|
|
|
id={id}
|
|
|
quiz={respuestas}
|
|
|
- save={save}
|
|
|
- responses={responses}
|
|
|
/>
|
|
|
</div>
|
|
|
</CardContent>
|
|
|
- <LinearProgressWithLabel value={progress} />
|
|
|
+ <LinearProgressWithLabel value={progress ? parseInt(progress) : 0 } />
|
|
|
</Card>
|
|
|
</Fade>
|
|
|
);
|