From b9e3f2cdd2e5a493dd0dddabe2f8fb96d761cb21 Mon Sep 17 00:00:00 2001 From: Pkpedram Date: Wed, 9 Mar 2022 14:15:05 +0330 Subject: [PATCH] Changing Number Of Options Done --- src/redux/reducers/exam.js | 15 ++++++++++- src/view/addExam/views/AddDescription.js | 2 +- .../addExam/views/AddQuestionsFromBank.js | 27 ++++++++++++++++--- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/redux/reducers/exam.js b/src/redux/reducers/exam.js index 8555a5f..b52c3aa 100644 --- a/src/redux/reducers/exam.js +++ b/src/redux/reducers/exam.js @@ -194,7 +194,11 @@ export const numOfinitQs = initialState.questionBank.length; export default function addExamReduser(state = initialState, { type, payload }) { console.log(state.courses) + + + switch (type) { + case 'ADD_EXAM_GRADE_AND_GROUP': return { ...state, @@ -311,7 +315,16 @@ export default function addExamReduser(state = initialState, { type, payload }) courses: newcourses } - + case 'CHANGE_COURSE_NUM_OF_OPTIONS' : + const otherCourseS = state.courses.filter(itm => itm.id !== payload.courseId) + const seLectedC = state.courses.filter(itm => itm.id == payload.courseId) + seLectedC[0] = { ...seLectedC[0], numberOfOptions: payload.value } + const neWCourses = [ ...seLectedC, ...otherCourseS] + return{ + ...state, + courses: neWCourses + + } default: return state; diff --git a/src/view/addExam/views/AddDescription.js b/src/view/addExam/views/AddDescription.js index ba3a04c..dfe003a 100644 --- a/src/view/addExam/views/AddDescription.js +++ b/src/view/addExam/views/AddDescription.js @@ -95,7 +95,7 @@ const AddExamDescription = ({ grades, addExamState, dispatch, stepClick, backSte
setType('pdf')}> - ذفترچه سوالات + دفترچه سوالات
diff --git a/src/view/addExam/views/AddQuestionsFromBank.js b/src/view/addExam/views/AddQuestionsFromBank.js index b10ec4c..fa8717b 100644 --- a/src/view/addExam/views/AddQuestionsFromBank.js +++ b/src/view/addExam/views/AddQuestionsFromBank.js @@ -320,12 +320,20 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS

ضریب

console.log(e.target.value)} - className="w-5 h-5 flex text-center items-center pt-1 rounded border border-red5B text-sm text-gray-600 mr-2" /> + 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" />

تعداد گزینه

- console.log(e.target.value)} - className="w-5 h-5 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" />
@@ -412,10 +420,21 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS
{addQuestionPopup == false &&
- + +

پایان سوالات