|
|
|
@ -23,26 +23,18 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
|
}); |
|
|
|
|
const [showCoursesInList, setShowCoursesInList] = useState([]); |
|
|
|
|
const [choosedQuestionaries, seChoosedQuestionaries] = useState([]); |
|
|
|
|
const [selectedQuestionare, setSelectedQuestionare] = useState({ |
|
|
|
|
const [selectedCourse, setSelectedCourse] = useState({ |
|
|
|
|
id: null,
|
|
|
|
|
courses: [] |
|
|
|
|
title: '' |
|
|
|
|
}); |
|
|
|
|
const [answers, setAnswers] = useState(null); |
|
|
|
|
const [newCourse, setNewCourse] = useState({ |
|
|
|
|
id: addExamState.questionairesCourses.length + 1, |
|
|
|
|
questionnaireId: selectedQuestionare.id, |
|
|
|
|
questionnaireId: selectedCourse.id, |
|
|
|
|
questionsQuantity:20, |
|
|
|
|
name: '', |
|
|
|
|
coefficient: 4 |
|
|
|
|
}) |
|
|
|
|
const [selectedCourse, setSelectedCourse] = useState({ |
|
|
|
|
sortId: 1, |
|
|
|
|
title: 'ادبیات فارسی', |
|
|
|
|
coefficient: 3, |
|
|
|
|
questionStart: 1, |
|
|
|
|
questionEnd: 0, |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
// console.log(choosedQuestionaries)
|
|
|
|
|
// console.log(newQuestionaire)
|
|
|
|
|
// console.log(addExamState.questionnaires)
|
|
|
|
@ -86,43 +78,31 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
|
<h1 className="w-full text-right text-lg text-red52 font-bold pt-4"> |
|
|
|
|
افزودن دفترچه |
|
|
|
|
</h1> |
|
|
|
|
<div className="w-full flex items-center flex-col mt-6 px-2 "> |
|
|
|
|
<div className="flex justify-between w-full"> |
|
|
|
|
<input type='text' placeholder="نام دفترچه..." className="w-4/5 p-4 ml-2 rounded border border-red52 h-12 text-red26 outline-none"
|
|
|
|
|
onChange={e => setNewQuestionaire({...newQuestionaire, name: e.target.value})} /> |
|
|
|
|
<input type="file" placeholder="آپلود فایل دفترچه" className="bg-white items-center flex h-12 text-red26 outline-none" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div className="flex w-full justify-end pt-2"> |
|
|
|
|
<button className="px-6 py-2 rounded-md bg-red52 text-white font-bold" |
|
|
|
|
onClick={() => {dispatch({type: 'ADD_EXAM_QUESTIONAIRES', payload: newQuestionaire}); setQuestionairePopUp(false) }} |
|
|
|
|
> |
|
|
|
|
تایید |
|
|
|
|
</button> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* { |
|
|
|
|
questoinaresLists.map( |
|
|
|
|
{ |
|
|
|
|
addExamState.courseBank.map( |
|
|
|
|
(item, index) => ( |
|
|
|
|
<> |
|
|
|
|
<div className="w-full flex items-center py-2 justify-between border-b pl-8 border-gray-300"> |
|
|
|
|
<Checkbox name={`PICK_QUESTIONARE_${index}`} |
|
|
|
|
onChange={(e) =>
|
|
|
|
|
e.target.checked ?
|
|
|
|
|
seChoosedQuestionaries([...choosedQuestionaries, item]) |
|
|
|
|
dispatch({type: 'ADD_EXAM_COURSE', payload: item}) |
|
|
|
|
:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
seChoosedQuestionaries(choosedQuestionaries.filter(itm => itm.id !== item.id)) |
|
|
|
|
dispatch({type: 'REMOVE_EXAM_COURSE', payload: item}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/> |
|
|
|
|
<h2 className="text-red26 font-bold">{item.title}</h2> |
|
|
|
|
<h4>تعداد سوالات: {item.numberOfQuestions}</h4> |
|
|
|
|
<p>تعداد دروس: {item.courses.length}</p> |
|
|
|
|
<p className="cursor-pointer" onClick={() => { |
|
|
|
|
{/* <h4>تعداد سوالات: {item.numberOfQuestions}</h4> |
|
|
|
|
<p>تعداد دروس: {item.courses.length}</p> */} |
|
|
|
|
{/* <p className="cursor-pointer" onClick={() => { |
|
|
|
|
let newArray = [...showCoursesInList]; |
|
|
|
|
|
|
|
|
|
newArray[index] = !newArray[index]; |
|
|
|
@ -130,46 +110,28 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
|
|
|
|
|
|
setShowCoursesInList(newArray) |
|
|
|
|
|
|
|
|
|
}}>نمایش دروس</p> |
|
|
|
|
}}>نمایش دروس</p> */} |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
{ |
|
|
|
|
showCoursesInList[index] && <div className="w-full flex flex-col"> |
|
|
|
|
{ |
|
|
|
|
item.courses.map((course) => ( |
|
|
|
|
<div className="w-full flex items-center text-right px-8 py-1 border-b border-gray-100" key={`COURSE_IN_LIST__${course.sortId}`}> |
|
|
|
|
<p className="w-1/3"> |
|
|
|
|
{course.title} |
|
|
|
|
</p> |
|
|
|
|
<p className="w-1/3"> |
|
|
|
|
ضریب : {course.coefficient} |
|
|
|
|
</p> |
|
|
|
|
<p |
|
|
|
|
className="w-1/3" |
|
|
|
|
>از سوال {course.questionStart} تا سوال {course.questionEnd}</p> |
|
|
|
|
</div> |
|
|
|
|
)) |
|
|
|
|
} |
|
|
|
|
</div> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
</> |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
} */} |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
} |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
addCoursePopup &&
|
|
|
|
|
<AddQuestionnaireCourse |
|
|
|
|
closeOnClick={() => setAddCoursePopup(false)} |
|
|
|
|
nameOnChange={e => setNewCourse({...newCourse, name: e.target.value})} |
|
|
|
|
coefficientOnChange={e => setNewCourse({...newCourse, coefficient: e.target.vlaue})} |
|
|
|
|
questionQuantityOnChange={e => setNewCourse({...newCourse, questionsQuantity: e.target.value, questionnaireId: selectedQuestionare.id})} |
|
|
|
|
submitOnClick={() => {dispatch({type: 'ADD_QUESTIONNAIRE_COURSES', payload : newCourse}); setAddCoursePopup(false); setFakeState(fakeState + 356)} } |
|
|
|
|
/> |
|
|
|
|
// addCoursePopup &&
|
|
|
|
|
// <AddQuestionnaireCourse
|
|
|
|
|
// closeOnClick={() => setAddCoursePopup(false)}
|
|
|
|
|
// nameOnChange={e => setNewCourse({...newCourse, name: e.target.value})}
|
|
|
|
|
// coefficientOnChange={e => setNewCourse({...newCourse, coefficient: e.target.vlaue})}
|
|
|
|
|
// questionQuantityOnChange={e => setNewCourse({...newCourse, questionsQuantity: e.target.value, questionnaireId: selectedQuestionare.id})}
|
|
|
|
|
// submitOnClick={() => {dispatch({type: 'ADD_QUESTIONNAIRE_COURSES', payload : newCourse}); setAddCoursePopup(false); setFakeState(fakeState + 356)} }
|
|
|
|
|
// />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -183,27 +145,30 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
|
</div> |
|
|
|
|
<div className="w-5/6 flex flex-row"> |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
addExamState.questionnaires.map( |
|
|
|
|
{addExamState.courses.length > 0 && |
|
|
|
|
addExamState.courses.map( |
|
|
|
|
(item => ( |
|
|
|
|
<div className={`flex flex-col ${selectedQuestionare.id === item.id ? 'bg-pinkF5 border border-red52 text-red52' : 'bg-white border border-gray-300 text-blue3A'} items-center justify-center w-36 h-32 mx-2 font-bold rounded-xl cursor-pointer`} |
|
|
|
|
onClick={() => setSelectedQuestionare({id : item.id,name: item.name, courses: addExamState.questionairesCourses.filter(itm => itm.questionnaireId == item.id)})} |
|
|
|
|
<div className={`flex flex-col ${selectedCourse.id === item.id ? 'bg-pinkF5 border border-red52 text-red52' : 'bg-white border border-gray-300 text-blue3A'} items-center justify-between pb-12 pt-2 w-36 h-32 mx-2 font-bold rounded-xl cursor-pointer`} |
|
|
|
|
onClick={() => setSelectedCourse(item)} |
|
|
|
|
> |
|
|
|
|
<p className="w-full text-left px-4" onClick={() => dispatch({type: 'REMOVE_EXAM_COURSE', payload: item})}> |
|
|
|
|
x |
|
|
|
|
</p> |
|
|
|
|
|
|
|
|
|
<p className="text-red52"> |
|
|
|
|
دفترچه {item.name} |
|
|
|
|
{item.title} |
|
|
|
|
</p> |
|
|
|
|
</div> |
|
|
|
|
)) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<div className="flex flex-col bg-white items-center justify-center w-36 h-32 mx-2 font-bold border border-gray-300 text-blue3A rounded-xl cursor-pointer" onClick={() => addExamState.type == 'bank' ? console.log('bank') : setQuestionairePopUp(true)}> |
|
|
|
|
<div className="flex flex-col bg-white items-center justify-center w-36 h-32 mx-2 font-bold border border-gray-300 text-blue3A rounded-xl cursor-pointer" onClick={() => setQuestionairePopUp(true)}> |
|
|
|
|
<p className="" style={{ fontSize: '40px' }}> |
|
|
|
|
+ |
|
|
|
|
</p> |
|
|
|
|
<p className=""> |
|
|
|
|
{addExamState.type == 'bank' ? 'افزودن درس' : 'افزودن دفترچه'} |
|
|
|
|
افزودن درس |
|
|
|
|
</p> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
@ -214,7 +179,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
|
<div className="w-full flex px-10"> |
|
|
|
|
|
|
|
|
|
<div className="w-1/2 border-l flex flex-col border-gray-300 py-10"> |
|
|
|
|
{ |
|
|
|
|
{/* { |
|
|
|
|
selectedQuestionare.id !== null && (<> |
|
|
|
|
<h1 className="text-blue3A w-full font-bold text-lg text-right"> |
|
|
|
|
دفترچه {selectedQuestionare.name} |
|
|
|
@ -239,14 +204,18 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS |
|
|
|
|
<button className=" bg-gray-300 text-xl text-gray-500 border-gray-500 w-1/3 h-12 rounded-xl border" onClick={() => setAddCoursePopup(true)}> |
|
|
|
|
افزودن درس |
|
|
|
|
</button> |
|
|
|
|
</div>} |
|
|
|
|
</div>} */} |
|
|
|
|
</div> |
|
|
|
|
<div className="w-1/2 flex justify-center"> |
|
|
|
|
<div className="w-4/5 py-8"> |
|
|
|
|
{/* <AnswerSheet questionsQuantity={selectedCourse.questionsQuantity} optionsQuantity={4} selectedCourseId={selectedCourse.id} |
|
|
|
|
passAnswers={data => {setAnswers(data); setFakeState(fakeState - 2)}}/> */} |
|
|
|
|
|
|
|
|
|
<Question /> |
|
|
|
|
{selectedCourse.id !== null && |
|
|
|
|
addExamState.questionBank.filter(itm => itm.courseId == selectedCourse.id).map( |
|
|
|
|
(course) => (<Question data={course} />) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
{/* <Question /> */} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|