diff --git a/src/components/Stepper/index.js b/src/components/Stepper/index.js index e5c65f8..e48331a 100644 --- a/src/components/Stepper/index.js +++ b/src/components/Stepper/index.js @@ -1,6 +1,6 @@ -import React, {useState} from "react"; +import React, { useState } from "react"; import separate from "../../utils/separate"; -import './index.css' +import "./index.css"; function Stepper({ direction, @@ -9,10 +9,8 @@ function Stepper({ count, currentStep, steps, - onStepClick + onStepClick, }) { - - return (
{steps.map((item, index) => ( -
-
-
- { - item.active ? - - - : null - } -
-
-

{index + 1}

-

{item.title}

+
+
+
+ {item.active ? ( + + + + ) : null} +
+
+

+ {index + 1} +

+

+ {" "} + {item.title} +

+
-
- {count !== (Number(index) + 1) && ( - - - )} - -
- + {count !== Number(index) + 1 && ( + + )} +
))}
); } - export default Stepper; Stepper.defaultProps = { direction: "vertical", activeColor: "#df1452", deactiveColor: "#DBDBDB", - - }; diff --git a/src/redux/actions/exam.js b/src/redux/actions/exam.js index fe35c3f..486f921 100644 --- a/src/redux/actions/exam.js +++ b/src/redux/actions/exam.js @@ -9,6 +9,10 @@ const exam = { (data = {}) => async (dispatch) => await proxy.post("exam/parentAdd", data, { dispatch }), + preview: + (data = {}) => + async (dispatch) => + await proxy.get("exam/preview", data, { dispatch }), addExamDescription: (data = {}) => { return (dispatch) => { dispatch({ diff --git a/src/redux/reducers/exam.js b/src/redux/reducers/exam.js index 0d25b39..125e62c 100644 --- a/src/redux/reducers/exam.js +++ b/src/redux/reducers/exam.js @@ -52,20 +52,20 @@ const initialState = { ], courseBank: [ - { - id: 1, - title: 'ریاضی', - coefficient: 4, - numberOfOptions: 4, - selectedQuestions: [] - }, - { - id: 2, - title: 'شیمی', - coefficient: 3, - numberOfOptions: 3, - selectedQuestions: [] - }, + // { + // id: 1, + // title: 'ریاضی', + // coefficient: 4, + // numberOfOptions: 4, + // selectedQuestions: [] + // }, + // { + // id: 2, + // title: 'شیمی', + // coefficient: 3, + // numberOfOptions: 3, + // selectedQuestions: [] + // }, ], questionBank: [ { @@ -257,9 +257,9 @@ export default function addExamReduser(state = initialState, { type, payload }) case 'ADD_EXAM_COURSE': return { - ...state, - courses: [...state.courses, payload] - } + ...state, + courses: [...state.courses, { ...payload, selectedQuestions:[]}], + }; case 'REMOVE_EXAM_COURSE': return { ...state, @@ -267,9 +267,15 @@ export default function addExamReduser(state = initialState, { type, payload }) } case 'ADD_EXAM_QUESTIONS': + console.log("??????????????"); console.log(payload) - const othercourses = state.courses.filter(itm => itm.id !== payload.courseId) - const selectedC = state.courses.filter(itm => itm.id == payload.courseId) + console.log(state.courses); + const othercourses = state.courses.filter( + (itm) => itm.id !== payload.lessonId + ); + const selectedC = state.courses.filter( + (itm) => itm.id == payload.lessonId + ); selectedC[0] = { ...selectedC[0], selectedQuestions: [payload, ...selectedC[0].selectedQuestions] } const newCourses = [...othercourses, ...selectedC] diff --git a/src/redux/reducers/exam2.js b/src/redux/reducers/exam2.js index 16413d6..a25146b 100644 --- a/src/redux/reducers/exam2.js +++ b/src/redux/reducers/exam2.js @@ -5,16 +5,20 @@ import { toast } from "react-toastify"; const initialState = { loading: false, error: null, - info:null + info: null, + lastExamAdd: null, + preview : null }; export default function exam2(state = initialState, action) { let { type, data } = action; switch (type) { case "exam/info": return { ...state, loading: false, info: data, error: null }; + case "exam/preview": + return { ...state, loading: false, preview: data, error: null }; case "exam/parentAdd": toast.success("آزمون شما با موفقیت ثبت شد"); - return { ...state, loading: false, error: null }; + return { ...state, loading: false, error: null, lastExamAdd: data.id }; default: return state; } diff --git a/src/view/addExam/components/question.js b/src/view/addExam/components/question.js index 8181304..d15b3b4 100644 --- a/src/view/addExam/components/question.js +++ b/src/view/addExam/components/question.js @@ -4,14 +4,15 @@ import React, { useEffect } from 'react'; let optionsList = []; const Question = ({data}) => { - useEffect(()=>{ - optionsList=[]; - for (let i = 0; i < data.type; i++) { - optionsList.push(data[`option${i + 1}`]); - } - }) - console.log("==|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") - console.log(optionsList); + // useEffect(()=>{ + + // }) + optionsList = []; + for (let i = 0; i < data.type; i++) { + optionsList.push(data[`option${i + 1}`]); + } + // console.log("==|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + // console.log(optionsList); const gozine = [ 'الف', 'ب', diff --git a/src/view/addExam/views/AddQuestionsFromBank.js b/src/view/addExam/views/AddQuestionsFromBank.js index 5768e35..b19a4e7 100644 --- a/src/view/addExam/views/AddQuestionsFromBank.js +++ b/src/view/addExam/views/AddQuestionsFromBank.js @@ -32,6 +32,7 @@ const AddQuestionsFromBank = ({ removeQuestionFromBank, removeExamQuestions, getQuestionBackToBank, + submitHandler, }) => { const [name, setName] = useState(null); const [type, setType] = useState(null); @@ -171,6 +172,11 @@ const AddQuestionsFromBank = ({ let name = document.querySelector("#addLessonPartInput").value; addLesson({ name }); }; + + const nextStephandler=()=>{ + submitHandler(); + stepClick(); + } return (
{questionarePopUp && ( @@ -281,6 +287,7 @@ const AddQuestionsFromBank = ({ )}
)} + {/* ====================================================================================== */}
@@ -328,70 +335,73 @@ const AddQuestionsFromBank = ({ > {addExamState?.courses?.length > 0 && addExamState.courses.map((item, index) => ( - - {(provided) => ( -
{ - setSelectedCourse(item); - setActiveCourse(item.id); - }} - > + <> + {console.log(item)} + + {(provided) => (
{ + setSelectedCourse(item); + setActiveCourse(item.id); + }} > -
- {item?.selectedQuestions?.length} سوال +
+
+ {item?.selectedQuestions?.length} سوال +
+ +

+ { + dispatch({ + type: "REMOVE_EXAM_COURSE", + payload: item, + }); + setSelectedCourse(null); + setFakeState(fakeState + 24); + }} + > + {" "} + x{" "} + +

-

- { - dispatch({ - type: "REMOVE_EXAM_COURSE", - payload: item, - }); - setSelectedCourse(null); - setFakeState(fakeState + 24); - }} +

{item?.name}

+
+

{" "} - x{" "} - -

-
- -

{item.title}

-
-

- {" "} - ضریب {item.coefficient} -

-

- {item.numberOfOptions} گزینه -

+ ضریب {item.coefficient} +

+

+ {item.numberOfOptions} گزینه +

+
-
- )} -
+ )} + + ))}
@@ -409,6 +419,7 @@ const AddQuestionsFromBank = ({
+ {/* ====================================================================================== */} {/* Picking Question Container */} handleOnDragEnd(result)} @@ -421,10 +432,10 @@ const AddQuestionsFromBank = ({ )[0]?.selectedQuestions[result.source.index] ); } else { + console.log("MMMMMMMMMMMMMMMMMMMM"); + console.log(result); seChoosedQuestion( - addExamState.questionBank.find( - (itm) => itm.questionId == result.source.index - ) + questionList?.find((itm) => itm.id == result.source.index) ); } }} @@ -776,9 +787,7 @@ const AddQuestionsFromBank = ({