소스 검색

progress and save responses mok

amenpunk 2 년 전
부모
커밋
4ca3ae711b
2개의 변경된 파일65개의 추가작업 그리고 37개의 파일을 삭제
  1. 0 11
      src/Components/Test/Cleaver/Question.jsx
  2. 65 26
      src/Pages/Pruebas/Cleaver.jsx

+ 0 - 11
src/Components/Test/Cleaver/Question.jsx

@@ -3,22 +3,12 @@ import { Remove as RemoveIcon, Add as AddIcon } from '@mui/icons-material';
3 3
 import {
4 4
   Card,CardContent,Avatar,Checkbox,List,Tooltip,Fade,
5 5
   ListItem,ListItemButton,ListItemIcon,ListItemText,
6
-  Box,LinearProgress,
7 6
 } from '@mui/material'
8 7
 
9 8
 import { deepPurple } from '@mui/material/colors';
10 9
 import { useDispatch, useSelector } from 'react-redux';
11 10
 import { setResponse  } from '../../../Slices/cleaverSlice';
12 11
 
13
-function LinearProgressWithLabel(props) {
14
-  return (
15
-    <Box sx={{ display: 'flex', alignItems: 'center' }}>
16
-      <Box sx={{ width: '100%', mr: 0 }}>
17
-        <LinearProgress variant="determinate" {...props} />
18
-      </Box>
19
-    </Box>
20
-  );
21
-}
22 12
 
23 13
 function CheckboxexHeader(prop) {
24 14
   return (
@@ -147,7 +137,6 @@ export function Question({quiz, index, current, progress}) {
147 137
               />
148 138
           </div>
149 139
         </CardContent>
150
-        <LinearProgressWithLabel value={progress ? parseInt(progress) : 0 } />
151 140
       </Card>
152 141
     </Fade>
153 142
   );

+ 65 - 26
src/Pages/Pruebas/Cleaver.jsx

@@ -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