|
@@ -1,11 +1,22 @@
|
|
|
import React from 'react'
|
|
import React from 'react'
|
|
|
import { Service } from '../../Utils/HTTP'
|
|
import { Service } from '../../Utils/HTTP'
|
|
|
import { Question } from '../../Components/Test/Cleaver/Question.jsx'
|
|
import { Question } from '../../Components/Test/Cleaver/Question.jsx'
|
|
|
-import { Box,Button } from '@mui/material'
|
|
|
|
|
|
|
+import { Box,Button, LinearProgress } from '@mui/material'
|
|
|
import { useSelector } from 'react-redux';
|
|
import { useSelector } from 'react-redux';
|
|
|
import { useParams } from 'react-router-dom'
|
|
import { useParams } from 'react-router-dom'
|
|
|
import toast, { Toaster } from 'react-hot-toast';
|
|
import toast, { Toaster } from 'react-hot-toast';
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+function LinearProgressWithLabel(props) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Box sx={{ display: 'flex', alignItems: 'center' }}>
|
|
|
|
|
+ <Box sx={{ width: '100%', mr: 0 }}>
|
|
|
|
|
+ <LinearProgress variant="determinate" {...props} />
|
|
|
|
|
+ </Box>
|
|
|
|
|
+ </Box>
|
|
|
|
|
+ );
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export function Cleaver() {
|
|
export function Cleaver() {
|
|
|
|
|
|
|
|
let { id } = useParams();
|
|
let { id } = useParams();
|
|
@@ -36,6 +47,10 @@ export function Cleaver() {
|
|
|
}).catch(console.log)
|
|
}).catch(console.log)
|
|
|
}, [id,auth]);
|
|
}, [id,auth]);
|
|
|
|
|
|
|
|
|
|
+ const saveRespones = () => {
|
|
|
|
|
+ console.log("guardando las respuestas")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const handleAddQuestion = () => {
|
|
const handleAddQuestion = () => {
|
|
|
let currentAnswer = totalRespondidas[totalRespondidas.length - 1];
|
|
let currentAnswer = totalRespondidas[totalRespondidas.length - 1];
|
|
|
let current_resp = cleaver.responses[currentAnswer.id];
|
|
let current_resp = cleaver.responses[currentAnswer.id];
|
|
@@ -65,8 +80,14 @@ export function Cleaver() {
|
|
|
CalculateProgress()
|
|
CalculateProgress()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
- <div className="content-section question">
|
|
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <div className="content-section question">
|
|
|
|
|
+ <div style={{width:'60%', marginBottom : 35}}>
|
|
|
|
|
+ <LinearProgressWithLabel value={progress ? parseInt(progress) : 0 } />
|
|
|
|
|
+ </div>
|
|
|
<Box className="question_body">
|
|
<Box className="question_body">
|
|
|
{totalRespondidas.map((item,i) => (
|
|
{totalRespondidas.map((item,i) => (
|
|
|
<Question
|
|
<Question
|
|
@@ -75,34 +96,52 @@ export function Cleaver() {
|
|
|
quiz={item}
|
|
quiz={item}
|
|
|
index={i}
|
|
index={i}
|
|
|
current={current}
|
|
current={current}
|
|
|
- progress={progress}
|
|
|
|
|
/>)
|
|
/>)
|
|
|
)}
|
|
)}
|
|
|
</Box>
|
|
</Box>
|
|
|
|
|
|
|
|
- <div className="question_btn">
|
|
|
|
|
- <Button
|
|
|
|
|
- className="nextquestion_btn"
|
|
|
|
|
- sx={{ backgroundColor: 'var(--main)' }}
|
|
|
|
|
- variant="contained"
|
|
|
|
|
- disabled={totalRespondidas.length <= 1}
|
|
|
|
|
- onClick={handleRemoveQuestion}
|
|
|
|
|
- >
|
|
|
|
|
- Anterior
|
|
|
|
|
- </Button>
|
|
|
|
|
- <Button
|
|
|
|
|
- className="nextquestion_btn"
|
|
|
|
|
- sx={{ backgroundColor: 'var(--main)' }}
|
|
|
|
|
- variant="contained"
|
|
|
|
|
- disabled={totalPreguntas.length <= 0}
|
|
|
|
|
- onClick={handleAddQuestion}
|
|
|
|
|
- >
|
|
|
|
|
- Siguiente
|
|
|
|
|
- </Button>
|
|
|
|
|
- </div>
|
|
|
|
|
- <Toaster
|
|
|
|
|
- position="bottom-right"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ totalPreguntas.length > 0 ?
|
|
|
|
|
+ (
|
|
|
|
|
+ <div className="question_btn">
|
|
|
|
|
+ <Button
|
|
|
|
|
+ className="nextquestion_btn"
|
|
|
|
|
+ sx={{ backgroundColor: 'var(--main)' }}
|
|
|
|
|
+ variant="contained"
|
|
|
|
|
+ disabled={totalRespondidas.length <= 1}
|
|
|
|
|
+ onClick={handleRemoveQuestion}
|
|
|
|
|
+ >
|
|
|
|
|
+ Anterior
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ className="nextquestion_btn"
|
|
|
|
|
+ sx={{ backgroundColor: 'var(--main)' }}
|
|
|
|
|
+ variant="contained"
|
|
|
|
|
+ disabled={totalPreguntas.length <= 0}
|
|
|
|
|
+ onClick={handleAddQuestion}
|
|
|
|
|
+ >
|
|
|
|
|
+ Siguiente
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+
|
|
|
|
|
+ <div className="question_btn">
|
|
|
|
|
+ <Button
|
|
|
|
|
+ className="nextquestion_btn"
|
|
|
|
|
+ sx={{ backgroundColor: 'var(--main)' }}
|
|
|
|
|
+ variant="contained"
|
|
|
|
|
+ onClick={saveRespones}
|
|
|
|
|
+ >
|
|
|
|
|
+ Guardar
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ <Toaster position="bottom-right" />
|
|
|
|
|
+
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
|
|
|