|
|
@ -26,7 +26,8 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
const [choosedQuestion, seChoosedQuestion] = useState(null); |
|
|
|
const [choosedQuestion, seChoosedQuestion] = useState(null); |
|
|
|
const [selectedCourse, setSelectedCourse] = useState({ |
|
|
|
const [selectedCourse, setSelectedCourse] = useState({ |
|
|
|
id: null, |
|
|
|
id: null, |
|
|
|
title: '' |
|
|
|
title: '', |
|
|
|
|
|
|
|
selectedQuestions: [], |
|
|
|
}); |
|
|
|
}); |
|
|
|
const [answers, setAnswers] = useState(null); |
|
|
|
const [answers, setAnswers] = useState(null); |
|
|
|
const [newCourse, setNewCourse] = useState({ |
|
|
|
const [newCourse, setNewCourse] = useState({ |
|
|
@ -36,13 +37,17 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
name: '', |
|
|
|
name: '', |
|
|
|
coefficient: 4 |
|
|
|
coefficient: 4 |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log(choosedQuestionaries)
|
|
|
|
// console.log(choosedQuestionaries)
|
|
|
|
// console.log(newQuestionaire)
|
|
|
|
// console.log(newQuestionaire)
|
|
|
|
// console.log(addExamState.questionnaires)
|
|
|
|
// console.log(addExamState.questionnaires)
|
|
|
|
console.log(newCourse) |
|
|
|
// console.log(newCourse)
|
|
|
|
console.log(addExamState.questionairesCourses) |
|
|
|
// console.log(addExamState.questionairesCourses)
|
|
|
|
console.log(selectedCourse) |
|
|
|
console.log(selectedCourse) |
|
|
|
console.log(answers) |
|
|
|
// console.log(answers)
|
|
|
|
|
|
|
|
console.log(choosedQuestion) |
|
|
|
|
|
|
|
console.log(selectedCourse.selectedQuestions) |
|
|
|
|
|
|
|
|
|
|
|
const [fakeState, setFakeState] = useState(2); |
|
|
|
const [fakeState, setFakeState] = useState(2); |
|
|
|
|
|
|
|
|
|
|
@ -71,9 +76,24 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
}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.questions]; |
|
|
|
|
|
|
|
const [removed] = aaa.splice(aaa.indexOf(itm => itm.questionId == source.index), 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
aaa.splice(aaa.indexOf(itm=> itm.questionId == destination.index), 0, removed); |
|
|
|
|
|
|
|
dispatch({type: 'CHANGE_QUESTION_ORDER', payload: aaa}) |
|
|
|
console.log(result) |
|
|
|
console.log(result) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log(addExamState.courses.filter(itm => itm.id == selectedCourse.id)[0]?.selectedQuestions) |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
@ -197,7 +217,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
{ |
|
|
|
{ |
|
|
|
console.log(result) |
|
|
|
console.log(result) |
|
|
|
if(result.source.droppableId == 'Choosed_Questions_Form_Bank'){ |
|
|
|
if(result.source.droppableId == 'Choosed_Questions_Form_Bank'){ |
|
|
|
seChoosedQuestion(addExamState.questions.find(itm => itm.questionId == result.source.index)) |
|
|
|
seChoosedQuestion(addExamState.courses.filter(itm => itm.id == selectedCourse.id)[0]?.selectedQuestions?.find(itm => itm.questionId == result.source.index)) |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
seChoosedQuestion(addExamState.questionBank.find(itm => itm.questionId == result.source.index)) |
|
|
|
seChoosedQuestion(addExamState.questionBank.find(itm => itm.questionId == result.source.index)) |
|
|
|
} |
|
|
|
} |
|
|
@ -213,11 +233,11 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
<h1 className="text-blue3A w-full font-bold text-lg text-right"> |
|
|
|
<h1 className="text-blue3A w-full font-bold text-lg text-right"> |
|
|
|
{selectedCourse.title} |
|
|
|
{selectedCourse.title} |
|
|
|
</h1> |
|
|
|
</h1> |
|
|
|
<div className="flex flex-col items-center overflow-x-hidden overflow-scroll" style={{ height: '500px' }}> |
|
|
|
<div className="flex flex-col items-center "> |
|
|
|
<div className="w-4/5 "> |
|
|
|
<div className="w-4/5 "> |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
addExamState.questions.filter(itm => itm.courseId == selectedCourse.id).map( |
|
|
|
addExamState.courses?.filter(itm => itm.id == selectedCourse.id)[0]?.selectedQuestions?.map( |
|
|
|
(item, index) => ( |
|
|
|
(item, index) => ( |
|
|
|
<Draggable draggableId={`_${item.questionId}`} index={item.questionId} key={`CHOOSED_QUESTIONS_${index}`}> |
|
|
|
<Draggable draggableId={`_${item.questionId}`} index={item.questionId} key={`CHOOSED_QUESTIONS_${index}`}> |
|
|
|
{(provided) => ( |
|
|
|
{(provided) => ( |
|
|
@ -232,6 +252,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
{provided.placeholder} |
|
|
|
</>) |
|
|
|
</>) |
|
|
|
} |
|
|
|
} |
|
|
|
{/* {selectedQuestionare.id !== null && |
|
|
|
{/* {selectedQuestionare.id !== null && |
|
|
@ -240,7 +261,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
افزودن درس |
|
|
|
افزودن درس |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
</div>} */} |
|
|
|
</div>} */} |
|
|
|
{provided.placeholder} |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
)} |
|
|
|
)} |
|
|
@ -254,20 +275,14 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
{/* <AnswerSheet questionsQuantity={selectedCourse.questionsQuantity} optionsQuantity={4} selectedCourseId={selectedCourse.id} |
|
|
|
{/* <AnswerSheet questionsQuantity={selectedCourse.questionsQuantity} optionsQuantity={4} selectedCourseId={selectedCourse.id} |
|
|
|
passAnswers={data => {setAnswers(data); setFakeState(fakeState - 2)}}/> */} |
|
|
|
passAnswers={data => {setAnswers(data); setFakeState(fakeState - 2)}}/> */} |
|
|
|
{selectedCourse.id !== null && |
|
|
|
{selectedCourse.id !== null && |
|
|
|
addExamState.questionBank.filter(itm => itm.courseId == selectedCourse.id).map( |
|
|
|
addExamState.questionBank?.filter(itm => itm.courseId == selectedCourse.id)?.map( |
|
|
|
(course, index) => ( |
|
|
|
(course, index) => ( |
|
|
|
<Draggable draggableId={`_${course.questionId}`} index={course.questionId} key={`CHOOSED_QUESTIONS_${course.questionId}`}> |
|
|
|
<Draggable draggableId={`_${course.questionId}`} index={course.questionId} key={`CHOOSED_QUESTIONS_${course.questionId}`}> |
|
|
|
{(provided) => ( |
|
|
|
{(provided) => ( |
|
|
|
<div className="flex items-start justify-between w-full"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div {...provided.draggableProps} {...provided.dragHandleProps} ref={provided.innerRef} className="flex items-start justify-center w-full"> |
|
|
|
|
|
|
|
|
|
|
|
<div {...provided.draggableProps} {...provided.dragHandleProps} ref={provided.innerRef}> |
|
|
|
|
|
|
|
<Question data={course} /> |
|
|
|
<Question data={course} /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
)} |
|
|
|
)} |
|
|
|
</Draggable> |
|
|
|
</Draggable> |
|
|
|
) |
|
|
|
) |
|
|
|