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