From bed10f4245b28c94bb7618e32a74e69d952afcb3 Mon Sep 17 00:00:00 2001 From: Alireza khaji Date: Wed, 29 Jun 2022 16:50:00 +0430 Subject: [PATCH] parentAdd api, examGroupList api, lessonList api | 420 --- src/redux/actions/exam.js | 22 +- src/redux/actions/examGroup.js | 21 + src/redux/actions/index.js | 2 + src/redux/actions/lesson.js | 23 + src/redux/reducers/exam.js | 6 +- src/redux/reducers/exam2.js | 1 + src/redux/reducers/examGroup.js | 24 + src/redux/reducers/index.js | 3 + src/redux/reducers/lesson.js | 24 + .../components/addQuestionnaireCourse.js | 154 +- src/view/addExam/views/AddDescription.js | 161 ++- src/view/addExam/views/AddGradeGroup.js | 188 ++- .../addExam/views/AddQuestionsFromBank.js | 1264 +++++++++-------- src/view/addExam/views/ViewExam.js | 26 +- .../addExam/views/addQuestionnaireExam.js | 600 ++++---- src/view/addExam/views/addQuestions.js | 46 +- 16 files changed, 1562 insertions(+), 1003 deletions(-) create mode 100644 src/redux/actions/examGroup.js create mode 100644 src/redux/actions/lesson.js create mode 100644 src/redux/reducers/examGroup.js create mode 100644 src/redux/reducers/lesson.js diff --git a/src/redux/actions/exam.js b/src/redux/actions/exam.js index fe01c92..21e1cc3 100644 --- a/src/redux/actions/exam.js +++ b/src/redux/actions/exam.js @@ -9,6 +9,26 @@ const exam = { (data = {}) => async (dispatch) => await proxy.post("exam/parentAdd", data, { dispatch }), + addExamDescription:(data = {}) =>{ + return(dispatch)=>{ + dispatch({ + type: "ADD_EXAM_DESCRIPTION", + payload:data + }); + } + }, + addExamGradeAndGroup:(data = {}) =>{ + return(dispatch)=>{ + dispatch({ + type: "ADD_EXAM_GRADE_AND_GROUP", + payload: data, + }); + } + } }; -export default exam; \ No newline at end of file +export default exam; + + + +// ADD_EXAM_DESCRIPTION; \ No newline at end of file diff --git a/src/redux/actions/examGroup.js b/src/redux/actions/examGroup.js new file mode 100644 index 0000000..fdcea18 --- /dev/null +++ b/src/redux/actions/examGroup.js @@ -0,0 +1,21 @@ + + +import proxy from "../proxy"; + + +const examGroup = { + info: + (data = {}) => + async (dispatch) => + await proxy.get("examGroup/info", data, { dispatch }), + list: + (data = {}) => + async (dispatch) => + await proxy.get("examGroup/list", data, { dispatch }), + add: + (data = {}) => + async (dispatch) => + await proxy.post("examGroup/add", data, { dispatch }), +}; + +export default examGroup; \ No newline at end of file diff --git a/src/redux/actions/index.js b/src/redux/actions/index.js index 0950b45..ab0077d 100644 --- a/src/redux/actions/index.js +++ b/src/redux/actions/index.js @@ -14,6 +14,8 @@ export {default as qr} from "./qr"; export { default as userTransaction } from "./userTransaction"; export { default as term } from "./term"; export { default as exam } from "./exam"; +export { default as examGroup } from "./examGroup"; +export { default as lesson } from "./lesson"; diff --git a/src/redux/actions/lesson.js b/src/redux/actions/lesson.js new file mode 100644 index 0000000..bfe7f35 --- /dev/null +++ b/src/redux/actions/lesson.js @@ -0,0 +1,23 @@ + + +import proxy from "../proxy"; +const lesson = { + info: + (data = {}) => + async (dispatch) => + await proxy.get("lesson/info", data, { dispatch }), + list: + (data = {}) => + async (dispatch) => + await proxy.get("lesson/list", data, { dispatch }), + add: + (data = {}) => + async (dispatch) => + await proxy.post("lesson/add", data, { dispatch }), + delete: + (data = {}) => + async (dispatch) => + await proxy.delete("lesson/delete", data, { dispatch }), +}; + +export default lesson; \ No newline at end of file diff --git a/src/redux/reducers/exam.js b/src/redux/reducers/exam.js index 12dabd9..0d25b39 100644 --- a/src/redux/reducers/exam.js +++ b/src/redux/reducers/exam.js @@ -12,6 +12,7 @@ const initialState = { description: '', type: 'bank', duration:null, + budgetFileId:null, questionnaires: [ { @@ -217,8 +218,9 @@ export default function addExamReduser(state = initialState, { type, payload }) description: payload.description, type: payload.type, duration: payload.duration, - startDate:payload.startDate, - endDate:payload.endDate + startDate: payload.startDate, + endDate: payload.endDate, + budgetFileId: payload.budgetFileId, }; case 'ADD_EXAM_QUESTIONAIRES': diff --git a/src/redux/reducers/exam2.js b/src/redux/reducers/exam2.js index 43b2e59..16413d6 100644 --- a/src/redux/reducers/exam2.js +++ b/src/redux/reducers/exam2.js @@ -13,6 +13,7 @@ export default function exam2(state = initialState, action) { case "exam/info": return { ...state, loading: false, info: data, error: null }; case "exam/parentAdd": + toast.success("آزمون شما با موفقیت ثبت شد"); return { ...state, loading: false, error: null }; default: return state; diff --git a/src/redux/reducers/examGroup.js b/src/redux/reducers/examGroup.js new file mode 100644 index 0000000..66c2b72 --- /dev/null +++ b/src/redux/reducers/examGroup.js @@ -0,0 +1,24 @@ + + + +import { toast } from "react-toastify"; + +const initialState = { + loading: false, + error: null, + info: null, + list:null +}; +export default function examGroup(state = initialState, action) { + let { type, data } = action; + switch (type) { + case "examGroup/info": + return { ...state, loading: false, info: data, error: null }; + case "examGroup/add": + return { ...state, loading: false, error: null }; + case "examGroup/list": + return { ...state, loading: false, error: null,list:data }; + default: + return state; + } +} \ No newline at end of file diff --git a/src/redux/reducers/index.js b/src/redux/reducers/index.js index 58f1dc1..23f22fb 100644 --- a/src/redux/reducers/index.js +++ b/src/redux/reducers/index.js @@ -14,3 +14,6 @@ export {default as addExamReduser} from "./exam"; export { default as userTransaction } from "./userTransaction"; export { default as term } from "./term"; export { default as exam2 } from "./exam2"; +export { default as examGroup } from "./examGroup"; +export { default as lesson } from "./lesson"; + diff --git a/src/redux/reducers/lesson.js b/src/redux/reducers/lesson.js new file mode 100644 index 0000000..b96e380 --- /dev/null +++ b/src/redux/reducers/lesson.js @@ -0,0 +1,24 @@ + + + +import { toast } from "react-toastify"; + +const initialState = { + loading: false, + error: null, + info: null, + list: null, +}; +export default function lesson(state = initialState, action) { + let { type, data } = action; + switch (type) { + case "lesson/info": + return { ...state, loading: false, info: data, error: null }; + case "lesson/add": + return { ...state, loading: false, error: null }; + case "lesson/list": + return { ...state, loading: false, error: null, list: data }; + default: + return state; + } +} \ No newline at end of file diff --git a/src/view/addExam/components/addQuestionnaireCourse.js b/src/view/addExam/components/addQuestionnaireCourse.js index 700c761..0711217 100644 --- a/src/view/addExam/components/addQuestionnaireCourse.js +++ b/src/view/addExam/components/addQuestionnaireCourse.js @@ -1,57 +1,103 @@ import React from "react"; -const AddQuestionnaireCourse = ({submitOnClick, nameOnChange, questionStart, questionEnd, coefficientOnChange, closeOnClick}) => { - return( -
-
-
-
- - - - - - - - -
-
-

- افزودن درس -

-
-
- - - - - - -
-
- -
+const AddQuestionnaireCourse = ({ + submitOnClick, + nameOnChange, + questionStart, + questionEnd, + coefficientOnChange, + closeOnClick, +}) => { + return ( +
+
+
+
+ + + + + + + + +
+
+

+ افزودن درس +

+
+
+ + + + + +
+
+ +
+
+
+
+ ); +}; - - -
-
-
- ) -} - -export default AddQuestionnaireCourse; \ No newline at end of file +export default AddQuestionnaireCourse; diff --git a/src/view/addExam/views/AddDescription.js b/src/view/addExam/views/AddDescription.js index f621e16..9b4d222 100644 --- a/src/view/addExam/views/AddDescription.js +++ b/src/view/addExam/views/AddDescription.js @@ -1,5 +1,5 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; import Button from "../../../components/Button"; import DatePicker from "react-multi-date-picker"; @@ -8,48 +8,80 @@ import persian from "react-date-object/calendars/persian" import persian_fa from "react-date-object/locales/persian_fa" import InputIcon from "react-multi-date-picker/components/input_icon" import RangeDatePicker from "../../../components/RangeDatePicker"; +import FileInput from "../../../components/fileInput"; +import { exam, file } from "../../../redux/actions"; -const AddExamDescription = ({ grades, addExamState, dispatch, stepClick, backStep }) => { - const [name, setName] = useState(null); - const [type, setType] = useState(null); - const [description, setDescription] = useState(null); - const [duration,setDuration]=useState(null); - const [date, setDate] = useState({ format: "MM/DD/YYYY" }); - const [startDate,setStartDate]=useState(null); - const [endDate, setEndDate] = useState(null); +const AddExamDescription = ({ + grades, + addExamState, + dispatch, + stepClick, + backStep, + uploadImg, + loading, + lastUploadId, + addExamDescription, +}) => { + const [name, setName] = useState(null); + const [type, setType] = useState(null); + const [description, setDescription] = useState(null); + const [duration, setDuration] = useState(null); + const [date, setDate] = useState({ format: "MM/DD/YYYY" }); + const [startDate, setStartDate] = useState(null); + const [endDate, setEndDate] = useState(null); + // const [budgetFileId,setBudgetFileId]=useState(null); - const payload = { - name: name, - description: description, - type: type, - duration, - startDate, - endDate, - }; - console.log("uuuuuuuuuuu") - const CostumeDatePickerInput = ({ openCalendar, value, handleValueChange, title,index }) => { - return ( - changeHandler(e)} - placeholder={title} - className="create-exame-date-input w-full h-14 rounded-lg p-3 border border-gray-200 text-blue3A outline-blue-300" - /> - ); - } - - const dateChangeHandler=(index)=>{ - let inputs = document.querySelectorAll(".create-exame-date-input"); - console.log(inputs[index].value); - let dateList = inputs[index].value.split(" ")[0].split("/"); - let timeList = inputs[index].value.split(" ")[1].split(":"); - console.log(dateList); - console.log(timeList); - console.log(Number(dateList[0])); - } + const payload = { + name: name, + description: description, + type: type, + duration, + startDate, + endDate, + budgetFileId: lastUploadId, + }; + console.log("uuuuuuuuuuu"); + const CostumeDatePickerInput = ({ + openCalendar, + value, + handleValueChange, + title, + index, + }) => { return ( - <> + changeHandler(e)} + placeholder={title} + className="create-exame-date-input w-full h-14 rounded-lg p-3 border border-gray-200 text-blue3A outline-blue-300" + /> + ); + }; + + const dateChangeHandler = (index) => { + let inputs = document.querySelectorAll(".create-exame-date-input"); + console.log(inputs[index].value); + let dateList = inputs[index].value.split(" ")[0].split("/"); + let timeList = inputs[index].value.split(" ")[1].split(":"); + console.log(dateList); + console.log(timeList); + console.log(Number(dateList[0])); + }; + const [file, setFile] = useState(null); + const uploadImghandler1 = (e) => { + console.log(e); + setFile(e); + uploadImg({ + file: e, + }); + // setUploadImgNumber(1); + }; + + // useEffect(() => {}, [lastUploadId]); + return ( + <> +
@@ -153,7 +185,29 @@ const AddExamDescription = ({ grades, addExamState, dispatch, stepClick, backSte
-
+ +
+
+
+ بودجه‌بندی آزمون +
+

+ لطفا عکس بودجه‌بندی آزمون را آپلود کنید. +

+
+
+ uploadImghandler1(e)} + deleteHandler={(e) => setFile(null)} + loading={loading} + /> +
+
+ +
- - ); -} +
+ + ); +}; const mapStateToProps = (state) => ({ - grades: state.publicApi.grades, - addExamState: state.addExamReduser -}) + grades: state.publicApi.grades, + addExamState: state.addExamReduser, + loading: state.file.loading, + lastUploadId: state.file.lastUpload, +}); + +const mapDispatchToProps = { + uploadImg: file.upload, + addExamDescription : exam.addExamDescription +}; -export default connect(mapStateToProps)(AddExamDescription); \ No newline at end of file +export default connect(mapStateToProps, mapDispatchToProps)(AddExamDescription); \ No newline at end of file diff --git a/src/view/addExam/views/AddGradeGroup.js b/src/view/addExam/views/AddGradeGroup.js index e2be940..31cecfb 100644 --- a/src/view/addExam/views/AddGradeGroup.js +++ b/src/view/addExam/views/AddGradeGroup.js @@ -1,88 +1,132 @@ - -import React, { useState } from "react"; +import React, { useMemo, useState } from "react"; +import { useEffect } from "react"; import { connect } from "react-redux"; import Button from "../../../components/Button"; -import { exam } from "../../../redux/actions"; +import { exam, examGroup } from "../../../redux/actions"; -const AddGradeGroup = ({grades, addExamState, dispatch, stepClick}) => { - const [examGrade, setExamGrade] = useState(null); - const [group, setGroup] = useState(null); - console.log(addExamState) - const payload = {grade: examGrade, groupId: group}; - - return( - <> -
-
-
- انتخاب پایه تحصیلی - -
-

لطفا یک پایه تحصیلی برای آزمون انتخاب کنید

-
+const AddGradeGroup = ({ + grades, + addExamState, + dispatch, + stepClick, + getExamGroupList, + examGroupAdd, + examGroupList, +}) => { + const [examGrade, setExamGrade] = useState(null); + const [group, setGroup] = useState(null); + console.log(addExamState); + const payload = { grade: examGrade, groupId: group }; -
- - - { - grades.map((item) =>( -
setExamGrade(item.id)}> - پایه {item.title} - + useEffect(() => { + getExamGroupList(); + }, []); -
- )) - } -
-
+ // useEffect(()=>{}) -
-
-
- انتخاب گروه تحصیلی - -
-

لطفا یک گروه تحصیلی برای آزمون انتخاب کنید

-
+ return ( +
+
+
+
+ انتخاب پایه تحصیلی +
+

+ لطفا یک پایه تحصیلی برای آزمون انتخاب کنید +

+
-
- -
setGroup(1)}> - ابر ‌ذهن - - -
-
setGroup(2)}> - تیزهوشان - - -
- -
+
+ {grades.map((item) => ( +
setExamGrade(item.id)} + > + پایه {item.title}
-
+ ))} +
+
-
+
+ ); +}; const mapStateToProps = (state) => ({ - grades: state.publicApi.grades, - addExamState: state.addExamReduser -}) + grades: state.publicApi.grades, + addExamState: state.addExamReduser, + examGroupList: state.examGroup.list, +}); +const mapDispatchToProps = { + getExamGroupList: examGroup.list, + examGroupAdd: examGroup.add, + addExamGradeAndGroup: exam.addExamGradeAndGroup, +}; +export default connect(mapStateToProps, mapDispatchToProps)(AddGradeGroup); -export default connect(mapStateToProps)(AddGradeGroup); \ No newline at end of file +{ + /*
setGroup(1)} + > + ابر ‌ذهن +
+
setGroup(2)} + > + تیزهوشان +
*/ +} diff --git a/src/view/addExam/views/AddQuestionsFromBank.js b/src/view/addExam/views/AddQuestionsFromBank.js index 91fbf93..86ec83b 100644 --- a/src/view/addExam/views/AddQuestionsFromBank.js +++ b/src/view/addExam/views/AddQuestionsFromBank.js @@ -1,71 +1,251 @@ - import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; -import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd'; +import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd"; import AnswerSheet from "../../../components/AnswerSheet"; import Button from "../../../components/Button"; import DatePicker from "../../../components/Calendar/CalendarComponents/DatePicker"; import Checkbox from "../../../components/Checkbox"; import RangeDatePicker from "../../../components/RangeDatePicker"; import SelectedCourse from "../../../components/selectedCourse"; -import filterIcon from '../../../assets/img/filter.svg' +import filterIcon from "../../../assets/img/filter.svg"; import Question from "../components/question"; import { numOfinitQs } from "../../../redux/reducers/exam"; import AddQuestionPopUp from "../components/addQuestion"; - -const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backStep }) => { - const [name, setName] = useState(null); - const [type, setType] = useState(null); - const [description, setDescription] = useState(null); - const [questionarePopUp, setQuestionairePopUp] = useState(false); - const [addQuestionPopup, setAddQuestionPopuo] = useState(false); - const [newQuestionaire, setNewQuestionaire] = useState({ - id: addExamState.questionnaires.length + 1, - name: '', - fileUrl: '', - }); - const [showCoursesInList, setShowCoursesInList] = useState([]); - const [choosedQuestion, seChoosedQuestion] = useState(null); - const [selectedCourse, setSelectedCourse] = useState({ - id: null, - title: '', - selectedQuestions: [], +import { lesson } from "../../../redux/actions"; + +const AddQuestionsFromBank = ({ + grades, + addExamState, + dispatch, + stepClick, + backStep, + lessonList, + addLesson, +}) => { + const [name, setName] = useState(null); + const [type, setType] = useState(null); + const [description, setDescription] = useState(null); + const [questionarePopUp, setQuestionairePopUp] = useState(false); + const [addQuestionPopup, setAddQuestionPopuo] = useState(false); + const [newQuestionaire, setNewQuestionaire] = useState({ + id: addExamState.questionnaires.length + 1, + name: "", + fileUrl: "", + }); + const [showCoursesInList, setShowCoursesInList] = useState([]); + const [choosedQuestion, seChoosedQuestion] = useState(null); + const [selectedCourse, setSelectedCourse] = useState({ + id: null, + title: "", + selectedQuestions: [], + }); + + // console.log(choosedQuestionaries) + // console.log(newQuestionaire) + // console.log(addExamState.questionnaires) + // console.log(newCourse) + // console.log(addExamState.questionairesCourses) + console.log(selectedCourse); + // console.log(answers) + console.log(choosedQuestion); + console.log(selectedCourse.selectedQuestions); + + const [fakeState, setFakeState] = useState(2); + + + + + const payload = { name: name, description: description, type: type }; + + const handleOnDragEnd = (result) => { + const { source, destination } = result; + + if (source.droppableId !== destination?.droppableId) { + if (destination?.droppableId == "Choosed_Questions_Form_Bank") { + dispatch({ type: "ADD_EXAM_QUESTIONS", payload: choosedQuestion }); + dispatch({ + type: "REMOVE_QUESTION_FROM_BANK", + payload: choosedQuestion, + }); + } else { + dispatch({ type: "REMOVE_EXAM_QUESTIONS", payload: choosedQuestion }); + dispatch({ + type: "GET_QUESTION_BACK_TO_BANK", + payload: choosedQuestion, + }); + } + } else { + if (source.droppableId == "Choosed_Questions_Form_Bank") { + // const data = { + // startIndex: choosedQuestion, + // endIndex: destination.index + // } + // dispatch({type:'CHANGE_QUESTION_ORDER', payload : data}) + // console.log(data) + + const aaa = [ + ...addExamState.courses.filter( + (itm) => itm.id == selectedCourse.id + )[0]?.selectedQuestions, + ]; + const [removed] = aaa.splice(source.index, 1); + + aaa.splice(destination.index, 0, removed); + dispatch({ type: "CHANGE_QUESTION_ORDER", payload: aaa }); + console.log(result); + console.log(source.index); + console.log(destination.index); + console.log(aaa); + } + } + }; + + const [sortedQuestionBank, setSortedQuestionBank] = useState( + addExamState.questionBank + ); + + useEffect(() => { + setSortedQuestionBank(addExamState.questionBank); + }, [addExamState]); + + const [numberOfOptions, setNumberOfOptions] = useState(null); + const [options, setOptions] = useState([]); + const [question, setQuestion] = useState({ + title: "", + options: [], + }); + useEffect(() => { + const arr = []; + for (var i = 1; i <= numberOfOptions; i++) { + arr.push({ + id: i, + title: "", + isAnswer: false, + }); + } + setOptions(arr); + setQuestion({ + ...question, + options: arr, + courseId: selectedCourse.id, + questionId: numOfinitQs + addExamState.questionBank.length + fakeState, }); - - - - // console.log(choosedQuestionaries) - // console.log(newQuestionaire) - // console.log(addExamState.questionnaires) - // console.log(newCourse) - // console.log(addExamState.questionairesCourses) - console.log(selectedCourse) - // console.log(answers) - console.log(choosedQuestion) - console.log(selectedCourse.selectedQuestions) - - const [fakeState, setFakeState] = useState(2); - - - - - const payload = { name: name, description: description, type: type }; - - const handleOnDragEnd = (result) => { - const { source, destination } = result; - - if (source.droppableId !== destination?.droppableId) { - if (destination?.droppableId == 'Choosed_Questions_Form_Bank') { - dispatch({ type: 'ADD_EXAM_QUESTIONS', payload: choosedQuestion }) - dispatch({ type: 'REMOVE_QUESTION_FROM_BANK', payload: choosedQuestion }) - - } else { - dispatch({ type: 'REMOVE_EXAM_QUESTIONS', payload: choosedQuestion }) - dispatch({ type: 'GET_QUESTION_BACK_TO_BANK', payload: choosedQuestion }) - } - - } else { - if (source.droppableId == 'Choosed_Questions_Form_Bank') { + }, [numberOfOptions]); + + console.log(question); + console.log( + addExamState.courses.filter((itm) => itm.id == selectedCourse.id)[0] + ?.selectedQuestions + ); + return ( +
+ {questionarePopUp && ( +
+
+
+
setQuestionairePopUp(false)} + > + + + + + + + + +
+
+

+ افزودن درس +

+ + {lessonList?.map((item, index) => ( + <> +
+ + e.target.checked + ? dispatch({ type: "ADD_EXAM_COURSE", payload: item }) + : dispatch({ + type: "REMOVE_EXAM_COURSE", + payload: item, + }) + } + /> +

{item?.name}

+
+ + ))} +
+ +
+
+
+ )} + {addQuestionPopup === "component" && ( + // setAddQuestionPopuo(false)} + // submitOnClick={data => { + // dispatch({type: 'ADD_CUSTOM_QUESTION', payload: { + // ...data, + // questionId:addExamState.questionBank.length + 1 , + // courseId: selectedCourse.id, + // }}) + // console.log({ + // ...data, + // questionId: addExamState.questionBank.length + 1, + // courseId: selectedCourse.id, + // }) + // }} + // /> + <> + )} +
+
+
+ تنظیمات آزمون +
+

+ لطفا مشخضات آزمون را تکمیل کنید +

+
+
+ { + const { source, destination } = result; + if (source.droppableId == "Choosed_Courses_Form_Bank") { // const data = { // startIndex: choosedQuestion, // endIndex: destination.index @@ -73,520 +253,496 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS // dispatch({type:'CHANGE_QUESTION_ORDER', payload : data}) // console.log(data) - const aaa = [...addExamState.courses.filter(itm => itm.id == selectedCourse.id)[0]?.selectedQuestions]; + const aaa = [...addExamState.courses]; const [removed] = aaa.splice(source.index, 1); aaa.splice(destination.index, 0, removed); - dispatch({ type: 'CHANGE_QUESTION_ORDER', payload: aaa }) - console.log(result) - console.log(source.index) - console.log(destination.index) - console.log(aaa) - - } - } - } - - - const [sortedQuestionBank, setSortedQuestionBank] = useState(addExamState.questionBank); - - useEffect(() => { - setSortedQuestionBank(addExamState.questionBank) - }, [addExamState]) - - const [numberOfOptions, setNumberOfOptions] = useState(null); - const [options, setOptions] = useState([]) - const [question, setQuestion] = useState({ - title: '', - options: [], - - - }) - useEffect(() => { - - const arr = []; - for (var i = 1; i <= numberOfOptions; i++) { - arr.push({ - id: i, - title: '', - isAnswer: false - }) - } - setOptions(arr) - setQuestion({ - ...question, - options: arr, - courseId: selectedCourse.id, - questionId: numOfinitQs + addExamState.questionBank.length + fakeState, - }) - - }, [numberOfOptions]) + dispatch({ type: "CHANGE_COURSE_ORDER", payload: aaa }); + console.log(result); + console.log(source.index); + console.log(destination.index); + console.log(aaa); + } + }} + > + + {(provided) => ( +
+ {provided.placeholder} +
+ {addExamState.courses.length > 0 && + addExamState.courses.map((item, index) => ( + + {(provided) => ( +
setSelectedCourse(item)} + > +
+
+ {item.selectedQuestions.length} سوال +
- console.log(question) - console.log(addExamState.courses.filter(itm => itm.id == selectedCourse.id)[0]?.selectedQuestions) - return ( -
- { - questionarePopUp &&
-
-
-
setQuestionairePopUp(false)}> - - - - - - - - +

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

+
+ +

{item.title}

+
+

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

+

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

+
-
-

- افزودن درس -

- - - - { - addExamState.courseBank.map( - (item, index) => ( - <> -
- - e.target.checked ? - dispatch({ type: 'ADD_EXAM_COURSE', payload: item }) - : - - - dispatch({ type: 'REMOVE_EXAM_COURSE', payload: item }) - - - } - - /> -

{item.title}

- {/*

تعداد سوالات: {item.numberOfQuestions}

-

تعداد دروس: {item.courses.length}

*/} - {/*

{ - let newArray = [...showCoursesInList]; - - newArray[index] = !newArray[index]; - - - setShowCoursesInList(newArray) - - }}>نمایش دروس

*/} - -
- - - - ) - ) - } -
- -
-
- - - + )} + + ))} +
- } - { - addQuestionPopup === 'component' && - // setAddQuestionPopuo(false)} - // submitOnClick={data => { - // dispatch({type: 'ADD_CUSTOM_QUESTION', payload: { - // ...data, - // questionId:addExamState.questionBank.length + 1 , - // courseId: selectedCourse.id, - // }}) - // console.log({ - // ...data, - // questionId: addExamState.questionBank.length + 1, - // courseId: selectedCourse.id, - // }) - // }} - // /> - <> - - - } -
-
-
- تنظیمات آزمون - + )} + + +
setQuestionairePopUp(true)} + > +

+ + +

+

افزودن درس

+
+
+
+ {/* Picking Question Container */} + handleOnDragEnd(result)} + onDragStart={(result) => { + console.log(result); + if (result.source.droppableId == "Choosed_Questions_Form_Bank") { + seChoosedQuestion( + addExamState.courses.filter( + (itm) => itm.id == selectedCourse.id + )[0]?.selectedQuestions[result.source.index] + ); + } else { + seChoosedQuestion( + addExamState.questionBank.find( + (itm) => itm.questionId == result.source.index + ) + ); + } + }} + > +
+ {/* Picked Qeustions From Bank */} + + {(provided) => ( +
+ {selectedCourse.id !== null && ( + <> + {/* Picked Questions Top Bar */} +
+

+ سوالات {selectedCourse.title} +

+
+

ضریب

+ console.log(e.target.value)} + className="w-5 h-5 placeholder:text-blue3A flex text-center items-center pt-1 rounded border border-red5B text-sm text-gray-600 mr-2" + /> +
+
+

تعداد گزینه

+ { + setSelectedCourse({ + ...selectedCourse, + numberOfOptions: e.target.value, + }); + dispatch({ + type: "CHANGE_COURSE_NUM_OF_OPTIONS", + payload: { + courseId: selectedCourse.id, + value: parseInt(e.target.value), + }, + }); + }} + className="w-5 h-5 flex text-center placeholder:text-blue3A items-center pt-1 rounded border border-red5B text-sm text-gray-600 mr-2" + /> +
+
+ +

نمره منفی

+
-

لطفا مشخضات آزمون را تکمیل کنید

-
-
- { - const { source, destination } = result; - if (source.droppableId == 'Choosed_Courses_Form_Bank') { - // const data = { - // startIndex: choosedQuestion, - // endIndex: destination.index - // } - // dispatch({type:'CHANGE_QUESTION_ORDER', payload : data}) - // console.log(data) - - const aaa = [...addExamState.courses]; - const [removed] = aaa.splice(source.index, 1); - aaa.splice(destination.index, 0, removed); - dispatch({ type: 'CHANGE_COURSE_ORDER', payload: aaa }) - console.log(result) - console.log(source.index) - console.log(destination.index) - console.log(aaa) - - } - }} +
- - {(provided) => ( -
- {provided.placeholder} -
- {addExamState.courses.length > 0 && - addExamState.courses.map( - (item, index) => ( - - {(provided) => ( -
setSelectedCourse(item)} - > -
-
- {item.selectedQuestions.length} سوال -
- -

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

- -
- -

- {item.title} -

-
-

ضریب {item.coefficient}

-

{item.numberOfOptions} گزینه

-
-
- - )} - -
- )) - - } - -
- +
+ {addQuestionPopup === "component" && ( + + setQuestion({ + ...question, + title: title, + }) + } + options={question.options} + setAsAnswer={(e) => { + let thisOption = question.options.find( + (itm) => itm.id == e + ); + thisOption.isAnswer = !thisOption.isAnswer; + let otherOptions = question.options.filter( + (itm) => itm.id !== e + ); + + let newArr = []; + otherOptions.map((item) => + newArr.push({ ...item, isAnswer: false }) + ); + // console.log(newArr) + + let newOptions = [...newArr, thisOption]; + // console.log(newOptions); + + let newNewOptions = newOptions.sort(function ( + a, + b + ) { + return a.id - b.id; + }); + // console.log(options == newOptions) + setQuestion({ + ...question, + options: [...newNewOptions], + }); + }} + scorePass={(score) => + setQuestion({ + ...question, + score: parseInt(score), + }) + } + passOptionTitle={(optionTitle, id) => { + let thisOption = question.options.find( + (itm) => itm.id == id + ); + thisOption.title = optionTitle; + setQuestion({ + ...question, + options: [...options], + }); + }} + submitOnClick={() => { + setAddQuestionPopuo(false); + + dispatch({ + type: "ADD_CUSTOM_QUESTION", + payload: question, + }); + setNumberOfOptions(null); + }} + cancelOnClick={() => setAddQuestionPopuo(false)} + /> + )} + {addExamState.courses + ?.filter((itm) => itm.id == selectedCourse.id)[0] + ?.selectedQuestions?.map((item, index) => ( + + {(provided) => ( +
+
+ + + + + +
+
- )} - - -
setQuestionairePopUp(true)}> -

- + -

-

- افزودن درس -

+ )} + + ))} + {provided.placeholder} +
- - - + + )} + {selectedCourse.id !== null && ( +
+ {addQuestionPopup == false && ( +
+
+ + + +
+

+ + پایان سوالات + +

+
+ )} +
+ )} +
+ )} +
+
+ {selectedCourse.id !== null ? ( + <> +
+
+
+ +

انتخاب همه

+
+
+ + +
+
+ +
+ {}} + className="w-full h-10 flex px-4 items-center pt-1 outline-none rounded-md border border-gray-300 text-sm text-gray-600 mr-2" + /> +
- -
- {/* Picking Question Container */} - handleOnDragEnd(result)} - onDragStart={(result) => { - console.log(result) - if (result.source.droppableId == 'Choosed_Questions_Form_Bank') { - seChoosedQuestion(addExamState.courses.filter(itm => itm.id == selectedCourse.id)[0]?.selectedQuestions[result.source.index]) - } else { - seChoosedQuestion(addExamState.questionBank.find(itm => itm.questionId == result.source.index)) - } - }}> - -
- {/* Picked Qeustions From Bank */} - - {(provided) => ( - - -
- { - selectedCourse.id !== null && (<> - - {/* Picked Questions Top Bar */} -
-

- سوالات {selectedCourse.title} -

-
-

ضریب

- console.log(e.target.value)} - className="w-5 h-5 placeholder:text-blue3A flex text-center items-center pt-1 rounded border border-red5B text-sm text-gray-600 mr-2" /> -
-
-

تعداد گزینه

- { - setSelectedCourse({...selectedCourse, numberOfOptions: e.target.value}) - dispatch({type:'CHANGE_COURSE_NUM_OF_OPTIONS', payload:{ - courseId: selectedCourse.id, - value: parseInt(e.target.value) - }})}} - className="w-5 h-5 flex text-center placeholder:text-blue3A items-center pt-1 rounded border border-red5B text-sm text-gray-600 mr-2" /> -
-
- -

نمره منفی

-
- -
- - -
-
- { - addQuestionPopup === 'component' && - setQuestion({ - ...question, - title: title - })} - options={question.options} - setAsAnswer={e => { - let thisOption = question.options.find(itm => itm.id == e) - thisOption.isAnswer = !thisOption.isAnswer - let otherOptions = question.options.filter(itm => itm.id !== e); - - let newArr = []; - otherOptions.map((item) => newArr.push({...item, isAnswer: false})) - // console.log(newArr) - - let newOptions = [...newArr, thisOption]; - // console.log(newOptions); - - let newNewOptions = newOptions.sort(function(a, b) { - return a.id - b.id - }); - // console.log(options == newOptions) - setQuestion({ - ...question, - options: [...newNewOptions] - }) - - }} - scorePass={score => setQuestion( - { - ...question, - score: parseInt(score) - } - )} - passOptionTitle={(optionTitle, id) => { - let thisOption = question.options.find(itm => itm.id == id) - thisOption.title = optionTitle - setQuestion({ - ...question, - options: [...options] - }) - }} - submitOnClick={() => { - setAddQuestionPopuo(false) - - dispatch({ type: 'ADD_CUSTOM_QUESTION', payload: question }); - setNumberOfOptions(null) - - }} - cancelOnClick={() => setAddQuestionPopuo(false)} - /> - } - - { - addExamState.courses?.filter(itm => itm.id == selectedCourse.id)[0]?.selectedQuestions?.map( - (item, index) => ( - - {(provided) => ( -
-
- - - - - - -
- -
- )} -
- ) - ) - } - {provided.placeholder} -
- -
- - ) - } - {selectedCourse.id !== null && -
- {addQuestionPopup == false && -
-
- - - - - -
-

- پایان سوالات -

-
- - } -
} - -
- - )} -
-
- {selectedCourse.id !== null ? - <> -
-
-
- -

انتخاب همه

-
-
- - -
-
- - -
- - { - - }} - className="w-full h-10 flex px-4 items-center pt-1 outline-none rounded-md border border-gray-300 text-sm text-gray-600 mr-2" /> -
- - + + {(provided) => ( +
+
+ {sortedQuestionBank + ?.filter((itm) => itm.courseId == selectedCourse.id) + ?.map((course, index) => ( + + {(provided) => ( +
+
+ + + + + +
+
- - {(provided) => ( - -
- - - -
- { - sortedQuestionBank?.filter(itm => itm.courseId == selectedCourse.id)?.map( - (course, index) => ( - - {(provided) => ( - -
-
- - - - - - -
- -
- )} -
- ) - ) - } - -
- - + )} + + ))} +
- {/* */} - {provided.placeholder} -
- - - - )} - - - : -
- -
- } + {/* */} + {provided.placeholder}
- - -
- - - -
- -
- + )} + + + ) : ( +
+ )} +
- ) -} +
+ +
+ +
+
+ ); +}; const mapStateToProps = (state) => ({ - grades: state.publicApi.grades, - addExamState: state.addExamReduser -}) - -export default connect(mapStateToProps)(AddQuestionsFromBank); \ No newline at end of file + grades: state.publicApi.grades, + addExamState: state.addExamReduser, +// lessonList: state.lesson.list +}); + +const mapDispatchToProps = { +// getLesson:lesson.list +}; + +export default connect( + mapStateToProps, + mapDispatchToProps +)(AddQuestionsFromBank); diff --git a/src/view/addExam/views/ViewExam.js b/src/view/addExam/views/ViewExam.js index 2be6268..6760ad2 100644 --- a/src/view/addExam/views/ViewExam.js +++ b/src/view/addExam/views/ViewExam.js @@ -10,6 +10,7 @@ import { Viewer } from '@react-pdf-viewer/core'; import '@react-pdf-viewer/core/lib/styles/index.css'; import Preview from "../../../components/AnswerSheet/preview"; import { exam } from "../../../redux/actions"; +import moment from "jalali-moment"; const ViewExam = ({ addExamState, stepClick, backStep, parentAdd }) => { useEffect(() => { @@ -50,13 +51,30 @@ const ViewExam = ({ addExamState, stepClick, backStep, parentAdd }) => { } console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>"); - console.log(addExamState.startDate); + console.log(addExamState.startDate.month); const submitHandler=()=>{ parentAdd({ name: addExamState.name, description: addExamState.description, - startDate: addExamState.startDate, - endDate: addExamState.endDate, + // startDate: moment( + // `${addExamState.startDate?.year}/${addExamState.startDate?.month}/${addExamState.startDate?.day} ${addExamState.startDate?.hour}:${addExamState.startDate?.minute}` + // ) + // .locale("en") + // .format("YYYY-MM-DD HH:mm"), + startDate: moment + .from( + `${addExamState.startDate?.year}/${addExamState.startDate?.month}/${addExamState.startDate?.day} ${addExamState.startDate?.hour}:${addExamState.startDate?.minute}`, + "fa", + "YYYY/MM/DD HH:mm" + ) + .format("YYYY-MM-DD HH:mm"), + endDate: moment + .from( + `${addExamState.endDate?.year}/${addExamState.endDate?.month}/${addExamState.endDate?.day} ${addExamState.endDate?.hour}:${addExamState.endDate?.minute}`, + "fa", + "YYYY/MM/DD HH:mm" + ) + .format("YYYY-MM-DD HH:mm"), duration: addExamState?.duration || 60, // duration:30, type: addExamState.type, @@ -64,7 +82,7 @@ const ViewExam = ({ addExamState, stepClick, backStep, parentAdd }) => { questionCount, examGroupId: addExamState.groupId, levelCriterion: null, - budgetFileId:null + budgetFileId: addExamState.budgetFileId, }); // stepClick(); } diff --git a/src/view/addExam/views/addQuestionnaireExam.js b/src/view/addExam/views/addQuestionnaireExam.js index a27cd30..0700dd8 100644 --- a/src/view/addExam/views/addQuestionnaireExam.js +++ b/src/view/addExam/views/addQuestionnaireExam.js @@ -1,4 +1,3 @@ - import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; import AnswerSheet from "../../../components/AnswerSheet"; @@ -13,98 +12,144 @@ import { Droppable } from "react-beautiful-dnd"; import { Draggable } from "react-beautiful-dnd"; import { toMap } from "draft-js/lib/DefaultDraftBlockRenderMap"; -const AddQuestionnaireExam = ({ grades, addExamState, dispatch, stepClick, backStep }) => { - - const [questionarePopUp, setQuestionairePopUp] = useState(false); - const [addCoursePopup, setAddCoursePopup] = useState(false); - const [newQuestionaire, setNewQuestionaire] = useState({ - id: addExamState.questionnaires.length + 1, - name: '', - fileUrl: '', - }); - const [showCoursesInList, setShowCoursesInList] = useState([]); - const [choosedQuestionaries, seChoosedQuestionaries] = useState([]); - const [selectedQuestionare, setSelectedQuestionare] = useState({ - id: null, - courses: [] - }); - const [answers, setAnswers] = useState(null); - const [newCourse, setNewCourse] = useState({ - id: selectedQuestionare.courses.length + selectedQuestionare.id + 1, - questionnaireId: selectedQuestionare.id, - questionsQuantity: 20, - name: '', - coefficient: 4 - }) - const [selectedCourse, setSelectedCourse] = useState({ - sortId: 1, - title: 'ادبیات فارسی', - coefficient: 3, - questionStart: 1, - questionEnd: 0, - - }) - // console.log(choosedQuestionaries) - // console.log(newQuestionaire) - // console.log(addExamState.questionnaires) - console.log(newCourse) - console.log(selectedQuestionare) - console.log(selectedCourse.id) - console.log(answers) - - const [fakeState, setFakeState] = useState(2); - useEffect(() => { - setSelectedCourse(selectedCourse) - setFakeState(fakeState + 15) - }, [addExamState]) - - useEffect(() => { - // questoinaresLists.map(item => showCoursesInList.push(false)); - if (answers !== null && answers !== []) { - answers.map(item => dispatch({ type: 'ADD_ANSWERS', payload: item })) - } - - }, [answers]) - - - - - return ( - <> - { - questionarePopUp &&
-
-
-
setQuestionairePopUp(false)}> - - - - - - - - -
-
-

- افزودن دفترچه -

-
-
- setNewQuestionaire({ ...newQuestionaire, name: e.target.value })} /> - -
-
- -
- - {/* { +const AddQuestionnaireExam = ({ + grades, + addExamState, + dispatch, + stepClick, + backStep, +}) => { + const [questionarePopUp, setQuestionairePopUp] = useState(false); + const [addCoursePopup, setAddCoursePopup] = useState(false); + const [newQuestionaire, setNewQuestionaire] = useState({ + id: addExamState.questionnaires.length + 1, + name: "", + fileUrl: "", + }); + const [showCoursesInList, setShowCoursesInList] = useState([]); + const [choosedQuestionaries, seChoosedQuestionaries] = useState([]); + const [selectedQuestionare, setSelectedQuestionare] = useState({ + id: null, + courses: [], + }); + const [answers, setAnswers] = useState(null); + const [newCourse, setNewCourse] = useState({ + id: selectedQuestionare.courses.length + selectedQuestionare.id + 1, + questionnaireId: selectedQuestionare.id, + questionsQuantity: 20, + name: "", + coefficient: 4, + }); + const [selectedCourse, setSelectedCourse] = useState({ + sortId: 1, + title: "ادبیات فارسی", + coefficient: 3, + questionStart: 1, + questionEnd: 0, + }); + // console.log(choosedQuestionaries) + // console.log(newQuestionaire) + // console.log(addExamState.questionnaires) + console.log(newCourse); + console.log(selectedQuestionare); + console.log(selectedCourse.id); + console.log(answers); + + const [fakeState, setFakeState] = useState(2); + useEffect(() => { + setSelectedCourse(selectedCourse); + setFakeState(fakeState + 15); + }, [addExamState]); + + useEffect(() => { + // questoinaresLists.map(item => showCoursesInList.push(false)); + if (answers !== null && answers !== []) { + answers.map((item) => dispatch({ type: "ADD_ANSWERS", payload: item })); + } + }, [answers]); + + return ( + <> + {questionarePopUp && ( +
+
+
+
setQuestionairePopUp(false)} + > + + + + + + + + +
+
+

+ افزودن دفترچه +

+
+
+ + setNewQuestionaire({ + ...newQuestionaire, + name: e.target.value, + }) + } + /> + +
+
+ +
+ + {/* { questoinaresLists.map( (item, index) => ( <> @@ -159,173 +204,218 @@ const AddQuestionnaireExam = ({ grades, addExamState, dispatch, stepClick, backS ) ) } */} - -
-
+
+
+
+ )} + {addCoursePopup && ( + setAddCoursePopup(false)} + nameOnChange={(e) => + setNewCourse({ ...newCourse, name: e.target.value }) + } + coefficientOnChange={(e) => + setNewCourse({ ...newCourse, coefficient: e.target.vlaue }) + } + questionEnd={(e) => + setNewCourse({ + ...newCourse, + questionEnd: e.target.value, + questionnaireId: selectedQuestionare.id, + }) + } + questionStart={(e) => + setNewCourse({ + ...newCourse, + questionStart: e.target.value, + questionnaireId: selectedQuestionare.id, + id: selectedQuestionare.id + selectedCourse.id + 1, + }) + } + submitOnClick={() => { + dispatch({ type: "ADD_QUESTIONNAIRE_COURSES", payload: newCourse }); + setAddCoursePopup(false); + setFakeState(fakeState + 356); + }} + /> + )} +
+
+
+ تنظیمات آزمون +
+

+ لطفا مشخضات آزمون را تکمیل کنید +

+
+
+ { + const { source, destination } = result; + if (source.droppableId == "Choosed_Questionnaires") { + // const data = { + // startIndex: choosedQuestion, + // endIndex: destination.index + // } + // dispatch({type:'CHANGE_QUESTION_ORDER', payload : data}) + // console.log(data) + + const aaa = [...addExamState.questionnaires]; + const [removed] = aaa.splice(source.index, 1); + + aaa.splice(destination.index, 0, removed); + dispatch({ type: "CHANGE_QUESTIONNAIRES_ORDER", payload: aaa }); + console.log(result); + console.log(source.index); + console.log(destination.index); + console.log(aaa); + } + }} + > + + {(provided) => ( +
+
+ {addExamState.questionnaires.map((item, index) => ( + + {(provided) => ( +
+ setSelectedQuestionare({ + id: item.id, + name: item.name, + courses: item.courses, + }) + } + > +

دفترچه {item.name}

+
+ )} +
+ ))} +
+ + {provided.placeholder}
+ )} +
+
+ +
+ addExamState.type == "bank" + ? console.log("bank") + : setQuestionairePopUp(true) } - { - addCoursePopup && - setAddCoursePopup(false)} - nameOnChange={e => setNewCourse({ ...newCourse, name: e.target.value })} - coefficientOnChange={e => setNewCourse({ ...newCourse, coefficient: e.target.vlaue })} - questionEnd={e => setNewCourse({ ...newCourse, questionEnd: e.target.value, questionnaireId: selectedQuestionare.id })} - questionStart={e => setNewCourse({ ...newCourse, questionStart: e.target.value, questionnaireId: selectedQuestionare.id, id: selectedQuestionare.id + selectedCourse.id + 1 })} - submitOnClick={() => { dispatch({ type: 'ADD_QUESTIONNAIRE_COURSES', payload: newCourse }); setAddCoursePopup(false); setFakeState(fakeState + 356) }} - /> - - - } -
-
-
- تنظیمات آزمون - -
-

لطفا مشخضات آزمون را تکمیل کنید

-
-
- { - const { source, destination } = result; - if (source.droppableId == 'Choosed_Questionnaires') { - // const data = { - // startIndex: choosedQuestion, - // endIndex: destination.index - // } - // dispatch({type:'CHANGE_QUESTION_ORDER', payload : data}) - // console.log(data) - - const aaa = [...addExamState.questionnaires]; - const [removed] = aaa.splice(source.index, 1); - - aaa.splice(destination.index, 0, removed); - dispatch({ type: 'CHANGE_QUESTIONNAIRES_ORDER', payload: aaa }) - console.log(result) - console.log(source.index) - console.log(destination.index) - console.log(aaa) - - } + > +

+ + +

+

+ {addExamState.type == "bank" ? "افزودن درس" : "افزودن دفترچه"} +

+
+
+
+ +
+
+ {selectedQuestionare.id !== null && ( + <> +

+ دفترچه {selectedQuestionare.name} +

+
+
+ {addExamState.questionnaires + .find((itm) => itm.id == selectedQuestionare.id) + ?.courses.map((item) => ( + { + setSelectedCourse(item); + console.log(selectedCourse); }} - > - - {(provided) => ( -
- -
- { - addExamState.questionnaires.map( - ((item, index) => ( - - {(provided) => ( - -
setSelectedQuestionare({ id: item.id, name: item.name, courses: item.courses})} - > - -

- دفترچه {item.name} -

-
- - )} - -
- )) - ) - - } - -
- - {provided.placeholder} -
- )} -
- - -
addExamState.type == 'bank' ? console.log('bank') : setQuestionairePopUp(true)}> -

- + -

-

- {addExamState.type == 'bank' ? 'افزودن درس' : 'افزودن دفترچه'} -

-
- -
- -
- -
- -
- { - selectedQuestionare.id !== null && (<> -

- دفترچه {selectedQuestionare.name} -

-
-
- - { - addExamState.questionnaires.find(itm => itm.id == selectedQuestionare.id)?.courses.map( - (item) => ( - { setSelectedCourse(item); console.log(selectedCourse) }} /> - ) - ) - } -
-
- ) - } - {selectedQuestionare.id !== null && -
- -
} -
-
-
- dispatch({type: 'ADD_ANSWERS', payload: data})} /> -
+ /> + ))}
- +
+ + )} + {selectedQuestionare.id !== null && ( +
+
- - -
- -
- - - ) -} + )} +
+
+
+ + dispatch({ type: "ADD_ANSWERS", payload: data }) + } + /> +
+
+
+ +
+ +
+ + ); +}; const mapStateToProps = (state) => ({ - grades: state.publicApi.grades, - addExamState: state.addExamReduser -}) + grades: state.publicApi.grades, + addExamState: state.addExamReduser, +}); -export default connect(mapStateToProps)(AddQuestionnaireExam); \ No newline at end of file +export default connect(mapStateToProps)(AddQuestionnaireExam); diff --git a/src/view/addExam/views/addQuestions.js b/src/view/addExam/views/addQuestions.js index d677113..b2f0638 100644 --- a/src/view/addExam/views/addQuestions.js +++ b/src/view/addExam/views/addQuestions.js @@ -1,4 +1,3 @@ - import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; import AnswerSheet from "../../../components/AnswerSheet"; @@ -7,21 +6,44 @@ import DatePicker from "../../../components/Calendar/CalendarComponents/DatePick import Checkbox from "../../../components/Checkbox"; import RangeDatePicker from "../../../components/RangeDatePicker"; import SelectedCourse from "../../../components/selectedCourse"; +import { lesson } from "../../../redux/actions"; import AddQuestionnaireCourse from "../components/addQuestionnaireCourse"; import AddQuestionnaireExam from "./addQuestionnaireExam"; import AddQuestionsFromBank from "./AddQuestionsFromBank"; -const AddQuestions = ({ addExamState, stepClick, backStep }) => { - return( - addExamState.type == 'pdf' ? - : - - ) -} +const AddQuestions = ({ + addExamState, + stepClick, + backStep, + getLesson, + lessonList, + addLesson, +}) => { + useEffect(() => { + getLesson(); + }, []); + + return addExamState.type == 2 ? ( + + ) : ( + + ); +}; const mapStateToProps = (state) => ({ - grades: state.publicApi.grades, - addExamState: state.addExamReduser -}) + grades: state.publicApi.grades, + addExamState: state.addExamReduser, + lessonList: state.lesson.list, +}); + +const mapDispatchToProps = { + getLesson: lesson.list, + addLesson: lesson.add +}; -export default connect(mapStateToProps)(AddQuestions); \ No newline at end of file +export default connect(mapStateToProps, mapDispatchToProps)(AddQuestions);