Changing Number Of Options Done

main
Pedram Keshavarzi 3 years ago
parent 3826d313a0
commit b9e3f2cdd2
  1. 13
      src/redux/reducers/exam.js
  2. 2
      src/view/addExam/views/AddDescription.js
  3. 27
      src/view/addExam/views/AddQuestionsFromBank.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;

@ -95,7 +95,7 @@ const AddExamDescription = ({ grades, addExamState, dispatch, stepClick, backSte
</div>
<div className={`w-1/6 border ${type == 'pdf' ? 'border-red52 text-red52 bg-pinkF5' : ' border-gray-300 text-blue3A bg-white'} font-bold cursor-pointer py-10 m-4 rounded-xl`} onClick={() => setType('pdf')}>
ذفترچه سوالات
دفترچه سوالات
</div>

@ -320,12 +320,20 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS
<div className="px-2 pl-4 text-gray37 text-sm flex items-center border-l border-red52">
<p>ضریب</p>
<input type='number' value={selectedCourse?.coefficient} onChange={(e) => 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" />
</div>
<div className="px-2 pl-0 text-gray37 text-sm flex items-center ">
<p>تعداد گزینه</p>
<input type='number' value={selectedCourse?.numberOfOptions} onChange={(e) => 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" />
<input type='number' value={selectedCourse?.numberOfOptions}
min='2'
max='6'
onChange={(e) => {
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" />
</div>
<div className="px-2 pl-4 text-gray37 text-sm flex items-center ">
<Checkbox name={`ADD_QUESTION_HAS_MINUS__${selectedCourse.id}`} />
@ -412,10 +420,21 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS
<div className="w-full flex justify-center mt-10">
{addQuestionPopup == false &&
<div className="flex flex-col w-full items-center">
<button className=" w-4/5 bg-transparent text-xl text-blue3A border-gray-300 h-12 rounded-xl border mb-6"
<div className="flex w-4/5 items-center justify-center">
<input type='file' className="hidden" id="Upload_Pdf_To_Exam"/>
<label
htmlFor="Upload_Pdf_To_Exam"
className=" w-1/3 ml-1 cursor-pointer bg-transparent text-xl flex items-center justify-center text-blue3A border-gray-300 h-12 rounded-xl border mb-6"
>
آپلود PDF
</label>
<button className=" w-2/3 mr-1 bg-transparent text-xl text-blue3A border-gray-300 h-12 rounded-xl border mb-6"
onClick={() => { setFakeState(fakeState + 5); setNumberOfOptions(selectedCourse.numberOfOptions); setAddQuestionPopuo('component') }}>
اضافه کردن سوال جدید +
</button>
</div>
<h1 className="w-4/5 text-center border-b border-red52 my-5 mx-0" style={{ lineHeight: '0.1em' }}>
<span className="bg-white py-0 px-10 text-blue3A"
>پایان سوالات</span>

Loading…
Cancel
Save