|
|
@ -10,6 +10,7 @@ import RangeDatePicker from "../../../components/RangeDatePicker"; |
|
|
|
import SelectedCourse from "../../../components/selectedCourse"; |
|
|
|
import SelectedCourse from "../../../components/selectedCourse"; |
|
|
|
import AddQuestionnaireCourse from "../components/addQuestionnaireCourse"; |
|
|
|
import AddQuestionnaireCourse from "../components/addQuestionnaireCourse"; |
|
|
|
import Question from "../components/question"; |
|
|
|
import Question from "../components/question"; |
|
|
|
|
|
|
|
import { numOfinitQs } from "../../../redux/reducers/exam"; |
|
|
|
import AddQuestionPopUp from "../components/addQuestion"; |
|
|
|
import AddQuestionPopUp from "../components/addQuestion"; |
|
|
|
|
|
|
|
|
|
|
|
const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backStep }) => { |
|
|
|
const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backStep }) => { |
|
|
@ -30,14 +31,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
title: '', |
|
|
|
title: '', |
|
|
|
selectedQuestions: [], |
|
|
|
selectedQuestions: [], |
|
|
|
}); |
|
|
|
}); |
|
|
|
const [answers, setAnswers] = useState(null); |
|
|
|
|
|
|
|
const [newCourse, setNewCourse] = useState({ |
|
|
|
|
|
|
|
id: addExamState.questionairesCourses.length + 1, |
|
|
|
|
|
|
|
questionnaireId: selectedCourse.id, |
|
|
|
|
|
|
|
questionsQuantity: 20, |
|
|
|
|
|
|
|
name: '', |
|
|
|
|
|
|
|
coefficient: 4 |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log(choosedQuestionaries)
|
|
|
|
// console.log(choosedQuestionaries)
|
|
|
@ -53,21 +47,15 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
const [fakeState, setFakeState] = useState(2); |
|
|
|
const [fakeState, setFakeState] = useState(2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
// questoinaresLists.map(item => showCoursesInList.push(false));
|
|
|
|
|
|
|
|
if (answers !== null && answers !== []) { |
|
|
|
|
|
|
|
answers.map(item => dispatch({ type: 'ADD_ANSWERS', payload: item })) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, [answers]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const payload = { name: name, description: description, type: type }; |
|
|
|
const payload = { name: name, description: description, type: type }; |
|
|
|
|
|
|
|
|
|
|
|
const handleOnDragEnd = (result) => { |
|
|
|
const handleOnDragEnd = (result) => { |
|
|
|
const { source, destination } = result; |
|
|
|
const { source, destination } = result; |
|
|
|
|
|
|
|
|
|
|
|
if (source.droppableId !== destination.droppableId) { |
|
|
|
if (source.droppableId !== destination?.droppableId) { |
|
|
|
if (destination.droppableId == 'Choosed_Questions_Form_Bank') { |
|
|
|
if (destination?.droppableId == 'Choosed_Questions_Form_Bank') { |
|
|
|
dispatch({ type: 'ADD_EXAM_QUESTIONS', payload: choosedQuestion }) |
|
|
|
dispatch({ type: 'ADD_EXAM_QUESTIONS', payload: choosedQuestion }) |
|
|
|
dispatch({ type: 'REMOVE_QUESTION_FROM_BANK', payload: choosedQuestion }) |
|
|
|
dispatch({ type: 'REMOVE_QUESTION_FROM_BANK', payload: choosedQuestion }) |
|
|
|
|
|
|
|
|
|
|
@ -99,6 +87,38 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(question) |
|
|
|
console.log(addExamState.courses.filter(itm => itm.id == selectedCourse.id)[0]?.selectedQuestions) |
|
|
|
console.log(addExamState.courses.filter(itm => itm.id == selectedCourse.id)[0]?.selectedQuestions) |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
@ -166,10 +186,23 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
} |
|
|
|
} |
|
|
|
{ |
|
|
|
{ |
|
|
|
addQuestionPopup &&
|
|
|
|
addQuestionPopup === 'component' &&
|
|
|
|
<AddQuestionPopUp
|
|
|
|
// <AddQuestionPopUp
|
|
|
|
closeOnClick={() => setAddQuestionPopuo(false)} |
|
|
|
// closeOnClick={() => 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,
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// }}
|
|
|
|
|
|
|
|
// />
|
|
|
|
|
|
|
|
<></> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -210,7 +243,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
{(provided) => ( |
|
|
|
{(provided) => ( |
|
|
|
<div className="flex"> |
|
|
|
<div className="flex"> |
|
|
|
{provided.placeholder} |
|
|
|
{provided.placeholder} |
|
|
|
<div className=" flex" {...provided.droppableProps} ref={provided.innerRef}> |
|
|
|
<div className=" flex " {...provided.droppableProps} ref={provided.innerRef}> |
|
|
|
{addExamState.courses.length > 0 && |
|
|
|
{addExamState.courses.length > 0 && |
|
|
|
addExamState.courses.map( |
|
|
|
addExamState.courses.map( |
|
|
|
(item, index) => ( |
|
|
|
(item, index) => ( |
|
|
@ -267,7 +300,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
seChoosedQuestion(addExamState.questionBank.find(itm => itm.questionId == result.source.index)) |
|
|
|
seChoosedQuestion(addExamState.questionBank.find(itm => itm.questionId == result.source.index)) |
|
|
|
} |
|
|
|
} |
|
|
|
}}> |
|
|
|
}}> |
|
|
|
<div className="w-full flex px-10"> |
|
|
|
<div className="w-full flex px-10 pl-0"> |
|
|
|
<Droppable droppableId="Choosed_Questions_Form_Bank"> |
|
|
|
<Droppable droppableId="Choosed_Questions_Form_Bank"> |
|
|
|
{(provided) => ( |
|
|
|
{(provided) => ( |
|
|
|
|
|
|
|
|
|
|
@ -278,8 +311,50 @@ 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 "> |
|
|
|
<div className="flex flex-col items-center overflow-x-hidden overflow-scroll" style={{height: '550px'}}> |
|
|
|
<div className="w-4/5 "> |
|
|
|
<div className="w-4/5 "> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
addQuestionPopup === 'component' &&
|
|
|
|
|
|
|
|
<AddQuestionPopUp
|
|
|
|
|
|
|
|
titlePass={title => setQuestion({ |
|
|
|
|
|
|
|
...question, |
|
|
|
|
|
|
|
title: title |
|
|
|
|
|
|
|
})} |
|
|
|
|
|
|
|
options={question.options} |
|
|
|
|
|
|
|
setAsAnswer={e => { |
|
|
|
|
|
|
|
let thisOption = question.options.find(itm => itm.id == e) |
|
|
|
|
|
|
|
thisOption.isAnswer = !thisOption.isAnswer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setQuestion({ |
|
|
|
|
|
|
|
...question, |
|
|
|
|
|
|
|
options : [...options] |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
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( |
|
|
|
addExamState.courses?.filter(itm => itm.id == selectedCourse.id)[0]?.selectedQuestions?.map( |
|
|
@ -303,20 +378,42 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
} |
|
|
|
} |
|
|
|
{selectedCourse.id !== null && |
|
|
|
{selectedCourse.id !== null && |
|
|
|
<div className="w-full flex justify-center mt-10"> |
|
|
|
<div className="w-full flex justify-center mt-10"> |
|
|
|
<button className=" bg-gray-300 text-xl text-gray-500 border-gray-500 w-1/3 h-12 rounded-xl border" onClick={() => setAddQuestionPopuo(true)}> |
|
|
|
{addQuestionPopup == false ? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<button className=" bg-gray-300 text-xl text-gray-500 border-gray-500 w-1/3 h-12 rounded-xl border" onClick={() => setAddQuestionPopuo('select')}> |
|
|
|
افزودن سوال |
|
|
|
افزودن سوال |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
: |
|
|
|
|
|
|
|
addQuestionPopup === 'select' && |
|
|
|
|
|
|
|
<select onChange={(e) => { setFakeState(fakeState + 5); setNumberOfOptions(e.target.value); setAddQuestionPopuo('component')}}> |
|
|
|
|
|
|
|
<option>تعداد گزینه ها</option> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
[1,2,3,4,5,6].map( |
|
|
|
|
|
|
|
item => <option>{item}</option> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
</div>} |
|
|
|
</div>} |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
)} |
|
|
|
)} |
|
|
|
</Droppable> |
|
|
|
</Droppable> |
|
|
|
<div className="w-1/2 flex justify-center"> |
|
|
|
<div className="w-1/2 flex flex-col items-center justify-start"> |
|
|
|
|
|
|
|
<div className="w-full h-16 mb-1 bg-green-400 border-b border-gray-200"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
<Droppable droppableId="QUESTIONS_IN_BANK"> |
|
|
|
<Droppable droppableId="QUESTIONS_IN_BANK"> |
|
|
|
{(provided) => ( |
|
|
|
{(provided) => ( |
|
|
|
|
|
|
|
|
|
|
|
<div className="w-full py-8 flex flex-col items-center "> |
|
|
|
<div className="w-full py-1 flex flex-col items-center overflow-x-hidden overflow-scroll" > |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{selectedCourse.id !== null && <> |
|
|
|
{selectedCourse.id !== null && <> |
|
|
|