lessonAdd,questionList api | 330

main
alireza khaji 2 years ago
parent bed10f4245
commit 578a025af5
  1. 1
      src/components/Stepper/index.js
  2. 235
      src/components/nav/minimalNav.js
  3. 72
      src/redux/actions/exam.js
  4. 1
      src/redux/actions/index.js
  5. 25
      src/redux/actions/question.js
  6. 2
      src/redux/reducers/index.js
  7. 9
      src/redux/reducers/lesson.js
  8. 31
      src/redux/reducers/question.js
  9. 77
      src/view/addExam/components/question.js
  10. 167
      src/view/addExam/views/AddQuestionsFromBank.js
  11. 80
      src/view/addExam/views/addQuestionnaireExam.js
  12. 4
      src/view/addExam/views/addQuestions.js

@ -21,6 +21,7 @@ function Stepper({
>
{steps.map((item, index) => (
<div
key={index}
className={`flex items-center w-full relative ${
direction === "horizontal" ? "flex-row justify-between" : "flex-col justify-start"
}`}

@ -1,155 +1,140 @@
import React, {useState} from "react";
import React, { useState } from "react";
import { Link } from "react-router-dom";
// assets
import avatar from "../../assets/img/avatar/pexels-jan-kopřiva-3525908.jpg";
import dropDownIcon from '../../assets/img/arrow-down.svg'
import homeIcon from './home-2.svg'
import optionsIcon from './element-3.svg'
import notificationIcon from './notification.svg';
import walleteIcon from './empty-wallet.svg';
import discountIcon from './discount-shape.svg';
import userIcon from './profile.svg';
import receiptIcon from './receipt-text.svg';
import settingIcon from './setting-2.svg';
import exitIcon from './vuesax-linear-logout.svg'
const MinimalNav = ({logOut}) => {
let initai_navId = 1;
import dropDownIcon from "../../assets/img/arrow-down.svg";
import homeIcon from "./home-2.svg";
import optionsIcon from "./element-3.svg";
import notificationIcon from "./notification.svg";
import walleteIcon from "./empty-wallet.svg";
import discountIcon from "./discount-shape.svg";
import userIcon from "./profile.svg";
import receiptIcon from "./receipt-text.svg";
import settingIcon from "./setting-2.svg";
import exitIcon from "./vuesax-linear-logout.svg";
const MinimalNav = ({ logOut }) => {
let initai_navId = 1;
const [navId, setNavId] = useState(initai_navId);
const chaneNav = (id) => {
setNavId(id);
let top = 100 / 6 + (id - 1) * 100 / 6 * 3 / 4;
console.log(top)
let top = 100 / 6 + ((((id - 1) * 100) / 6) * 3) / 4;
console.log(top);
document.querySelector(".back-item-img").style.top = `${top}%`;
};
const menuOptions = [
{
icon: homeIcon,
link: '/adminpanel',
id : 1
},
{
icon: optionsIcon,
link: '/adminpanel',
id : 2
{
icon: homeIcon,
link: "/adminpanel",
id: 1,
},
{
icon: notificationIcon,
link: '/adminpanel',
id : 3
icon: optionsIcon,
link: "/adminpanel",
id: 2,
},
{
icon: walleteIcon,
link: '/adminpanel',
id : 4
icon: notificationIcon,
link: "/adminpanel",
id: 3,
},
{
icon: discountIcon,
link: '/adminpanel',
id : 5
icon: walleteIcon,
link: "/adminpanel",
id: 4,
},
{
icon: receiptIcon,
link: '/adminpanel',
id : 6
icon: discountIcon,
link: "/adminpanel",
id: 5,
},
{
icon: walleteIcon,
link: '/adminpanel',
id : 7
icon: receiptIcon,
link: "/adminpanel",
id: 6,
},
{
icon: userIcon,
link: '/adminpanel',
id : 8
icon: walleteIcon,
link: "/adminpanel",
id: 7,
},
{
icon: settingIcon,
link: '/adminpanel',
id : 9
icon: userIcon,
link: "/adminpanel",
id: 8,
},
{
icon: exitIcon,
link: '/',
id: 10
icon: settingIcon,
link: "/adminpanel",
id: 9,
},
]
return(
<div className="nav h-full w-[4.5%] fixed top-0 right-0 z-20 overflow-hidden bg-white border-l border-l-color1">
<div className="h-[10%] mb-6 mt-4 flex flex-col justify-center items-center">
<img src={avatar} alt="user" className="logo w-12 h-12 rounded-full" />
<img src={dropDownIcon} alt="choose User Icon" className="w-6" />
</div>
{/* ------------ */}
<div className="flex flex-col items-center w-full h-full">
{
menuOptions.slice(0,3).map(
(item, index) => (
<Link to={item.link} className="w-full flex justify-center items-center h-[7%]" onClick={() => setNavId(item.id)}>
<img src={item.icon} className="w-2/5"/>
<div
className="back-item-img w-1 rounded-xl h-12 bg-red52 absolute right-0 z-20 transition-all duration-300"
style={
navId != item.id ? {display: 'none'} : null
}
></div>
</Link>
)
)
}
<div className="h-1 w-4/5 rounded-xl bg-red82OP my-4"></div>
{
menuOptions.slice(3,7).map(
(item, index) => (
<Link to={item.link} className="w-full flex justify-center items-center h-[7%]" onClick={() => setNavId(item.id)}>
<img src={item.icon} className="w-2/5"/>
<div
className="back-item-img w-1 rounded-xl h-12 bg-red52 absolute right-0 z-20 transition-all duration-300"
style={
navId != item.id ? {display: 'none'} : null
}
></div>
</Link>
)
)
}
<div className="h-1 w-4/5 rounded-xl bg-red82OP my-4"></div>
{
menuOptions.slice(7,12).map(
(item, index) => (
<Link to={item.link} className="w-full flex justify-center items-center h-[7%]" onClick={() => setNavId(item.id)}>
<img src={item.icon} className="w-2/5"/>
<div
className="back-item-img w-1 rounded-xl h-12 bg-red52 absolute right-0 z-20 transition-all duration-300"
style={
navId != item.id ? {display: 'none'} : null
}
></div>
</Link>
)
)
}
</div>
</div>
)
}
export default MinimalNav;
{
icon: exitIcon,
link: "/",
id: 10,
},
];
return (
<div className="nav h-full w-[4.5%] fixed top-0 right-0 z-20 overflow-hidden bg-white border-l border-l-color1">
<div className="h-[10%] mb-6 mt-4 flex flex-col justify-center items-center">
<img src={avatar} alt="user" className="logo w-12 h-12 rounded-full" />
<img src={dropDownIcon} alt="choose User Icon" className="w-6" />
</div>
{/* ------------ */}
<div className="flex flex-col items-center w-full h-full">
{menuOptions.slice(0, 3).map((item, index) => (
<Link
key={index}
to={item.link}
className="w-full flex justify-center items-center h-[7%]"
onClick={() => setNavId(item.id)}
>
<img src={item.icon} className="w-2/5" />
<div
className="back-item-img w-1 rounded-xl h-12 bg-red52 absolute right-0 z-20 transition-all duration-300"
style={navId != item.id ? { display: "none" } : null}
></div>
</Link>
))}
<div className="h-1 w-4/5 rounded-xl bg-red82OP my-4"></div>
{menuOptions.slice(3, 7).map((item, index) => (
<Link
key={index}
to={item.link}
className="w-full flex justify-center items-center h-[7%]"
onClick={() => setNavId(item.id)}
>
<img src={item.icon} className="w-2/5" />
<div
className="back-item-img w-1 rounded-xl h-12 bg-red52 absolute right-0 z-20 transition-all duration-300"
style={navId != item.id ? { display: "none" } : null}
></div>
</Link>
))}
<div className="h-1 w-4/5 rounded-xl bg-red82OP my-4"></div>
{menuOptions.slice(7, 12).map((item, index) => (
<Link
key={index}
to={item.link}
className="w-full flex justify-center items-center h-[7%]"
onClick={() => setNavId(item.id)}
>
<img src={item.icon} className="w-2/5" />
<div
className="back-item-img w-1 rounded-xl h-12 bg-red52 absolute right-0 z-20 transition-all duration-300"
style={navId != item.id ? { display: "none" } : null}
></div>
</Link>
))}
</div>
</div>
);
};
export default MinimalNav;

@ -9,22 +9,78 @@ const exam = {
(data = {}) =>
async (dispatch) =>
await proxy.post("exam/parentAdd", data, { dispatch }),
addExamDescription:(data = {}) =>{
return(dispatch)=>{
addExamDescription: (data = {}) => {
return (dispatch) => {
dispatch({
type: "ADD_EXAM_DESCRIPTION",
payload:data
payload: data,
});
}
};
},
addExamGradeAndGroup:(data = {}) =>{
return(dispatch)=>{
addExamGradeAndGroup: (data = {}) => {
return (dispatch) => {
dispatch({
type: "ADD_EXAM_GRADE_AND_GROUP",
payload: data,
});
}
}
};
},
addExamCourse: (data = {}) => {
return (dispatch) => {
dispatch({
type: "ADD_EXAM_COURSE",
payload: data,
});
};
},
removeExamCourse: (data = {}) => {
return (dispatch) => {
dispatch({
type: "REMOVE_EXAM_COURSE",
payload: data,
});
};
},
addExamQuestion: (data = {}) => {
return (dispatch) => {
dispatch({
type: "ADD_EXAM_QUESTIONS",
payload: data,
});
};
},
removeQuestionFromBank: (data = {}) => {
return (dispatch) => {
dispatch({
type: "REMOVE_QUESTION_FROM_BANK",
payload: data,
});
};
},
removeExamQuestions: (data = {}) => {
return (dispatch) => {
dispatch({
type: "REMOVE_EXAM_QUESTIONS",
payload: data,
});
};
},
getQuestionBackToBank: (data = {}) => {
return (dispatch) => {
dispatch({
type: "GET_QUESTION_BACK_TO_BANK",
payload: data,
});
};
},
changeQuestionOrder: (data = {}) => {
return (dispatch) => {
dispatch({
type: "CHANGE_QUESTION_ORDER",
payload: data,
});
};
},
};
export default exam;

@ -16,6 +16,7 @@ export { default as term } from "./term";
export { default as exam } from "./exam";
export { default as examGroup } from "./examGroup";
export { default as lesson } from "./lesson";
export { default as question } from "./question";

@ -0,0 +1,25 @@
import proxy from "../proxy";
const question = {
info:
(data = {}) =>
async (dispatch) =>
await proxy.get("question/info", data, { dispatch }),
list:
(data = {}) =>
async (dispatch) =>
await proxy.get("question/list", data, { dispatch }),
add:
(data = {}) =>
async (dispatch) =>
await proxy.post("question/add", data, { dispatch }),
delete:
(data = {}) =>
async (dispatch) =>
await proxy.delete("question/delete", data, { dispatch }),
};
export default question;

@ -16,4 +16,6 @@ export { default as term } from "./term";
export { default as exam2 } from "./exam2";
export { default as examGroup } from "./examGroup";
export { default as lesson } from "./lesson";
export { default as question } from "./question";

@ -8,6 +8,7 @@ const initialState = {
error: null,
info: null,
list: null,
lastAdd:null
};
export default function lesson(state = initialState, action) {
let { type, data } = action;
@ -15,9 +16,15 @@ export default function lesson(state = initialState, action) {
case "lesson/info":
return { ...state, loading: false, info: data, error: null };
case "lesson/add":
return { ...state, loading: false, error: null };
toast.success("درخواست با موفقیت انجام شد")
return { ...state, loading: false, error: null, lastAdd:data.id };
case "lesson/list":
return { ...state, loading: false, error: null, list: data };
case "lesson/loading":
return { ...state, loading: true };
case "lesson/error":
toast.error(data.message);
return { ...state, loading: false, error: data.message };
default:
return state;
}

@ -0,0 +1,31 @@
import { toast } from "react-toastify";
const initialState = {
loading: false,
error: null,
info: null,
list: null,
lastAdd: null,
};
export default function question(state = initialState, action) {
let { type, data } = action;
switch (type) {
case "question/info":
return { ...state, loading: false, info: data, error: null };
case "question/add":
toast.success("درخواست با موفقیت انجام شد");
return { ...state, loading: false, error: null, lastAdd: data.id };
case "question/list":
return { ...state, loading: false, error: null, list: data };
case "question/loading":
return { ...state, loading: true };
case "question/error":
toast.error(data.message);
return { ...state, loading: false, error: data.message };
default:
return state;
}
}

@ -1,10 +1,17 @@
import React from 'react';
import React, { useEffect } from 'react';
let optionsList = [];
const Question = ({data}) => {
useEffect(()=>{
optionsList=[];
for (let i = 0; i < data.type; i++) {
optionsList.push(data[`option${i + 1}`]);
}
})
console.log("==|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
console.log(optionsList);
const gozine = [
'الف',
'ب',
@ -13,35 +20,47 @@ const Question = ({data}) => {
'ه',
'ز',
]
return(
<div className='w-full flex flex-col text-blue3A mt-4 mb-2 font-bold justify-between items-center'>
<div className='w-11/12 flex flex-col bg-white rounded-xl border border-gray-300'>
<div className='w-full border-b border-gray-300 p-4 text-blue3A text-right'>
{data.title}
</div>
<div className='w-full p-3 px-4 flex justify-between items-center'>
<div>
<p className='text-xs'>نمره : {data.score}</p>
</div>
<div className='text-gray-500 text-sm'>
درصد پاسخگویی: {data.answeredPercentage}
</div>
</div>
return (
<div className="w-full flex flex-col text-blue3A mt-4 mb-2 font-bold justify-between items-center">
<div className="w-11/12 flex flex-col bg-white rounded-xl border border-gray-300">
<div className="w-full border-b border-gray-300 p-4 text-blue3A text-right">
{data?.text}
</div>
<div className="w-full p-3 px-4 flex justify-between items-center">
<div>
<p className="text-xs">نمره : {data.score}</p>
</div>
<div className='w-full justify-center mt-4 flex flex-wrap'>
{
data.options.map(
(item) => (
<div className='w-2/5 mx-2 my-2 flex items-center justify-center'>
<p className={` h-12 flex items-center justify-center w-16 rounded-lg rounded-l-none ${item.isAnswer ? 'text-white bg-green-400' : 'bg-gray-200 border border-gray-300'}`}>{gozine[item.id - 1]}</p>
<p className={` h-12 flex items-center justify-center w-full rounded-lg rounded-r-none ${item.isAnswer ? 'bg-green-200' : 'bg-white border border-gray-300'}`}>{item.title}</p>
</div>
)
)
}
<div className="text-gray-500 text-sm">
درصد پاسخگویی: {data.answerPercent}
</div>
</div>
</div>
<div className="w-full justify-center mt-4 flex flex-wrap">
{optionsList?.map((item,index) => (
<div className="w-2/5 mx-2 my-2 flex items-center justify-center">
<p
className={` h-12 flex items-center justify-center w-16 rounded-lg rounded-l-none ${
item.isAnswer
? "text-white bg-green-400"
: "bg-gray-200 border border-gray-300"
}`}
>
{gozine[index]}
</p>
<p
className={` h-12 flex items-center justify-center w-full rounded-lg rounded-r-none ${
item.isAnswer
? "bg-green-200"
: "bg-white border border-gray-300"
}`}
>
{item}
</p>
</div>
))}
</div>
)
</div>
);
}

@ -11,7 +11,9 @@ import filterIcon from "../../../assets/img/filter.svg";
import Question from "../components/question";
import { numOfinitQs } from "../../../redux/reducers/exam";
import AddQuestionPopUp from "../components/addQuestion";
import { lesson } from "../../../redux/actions";
import { exam, lesson, question } from "../../../redux/actions";
import { AiOutlineCloseCircle } from "react-icons/ai";
import loadingGiff from "../../../assets/img/Rolling-2s-223px.gif";
const AddQuestionsFromBank = ({
grades,
@ -21,12 +23,22 @@ const AddQuestionsFromBank = ({
backStep,
lessonList,
addLesson,
addLessonLoading,
addExamCourse,
removeExamCourse,
getQuestion,
questionList,
addExamQuestion,
removeQuestionFromBank,
removeExamQuestions,
getQuestionBackToBank,
}) => {
const [name, setName] = useState(null);
const [type, setType] = useState(null);
const [description, setDescription] = useState(null);
const [questionarePopUp, setQuestionairePopUp] = useState(false);
const [addQuestionPopup, setAddQuestionPopuo] = useState(false);
const [addLessonPart, setAddLessonPart] = useState(false);
const [newQuestionaire, setNewQuestionaire] = useState({
id: addExamState.questionnaires.length + 1,
name: "",
@ -52,9 +64,6 @@ const AddQuestionsFromBank = ({
const [fakeState, setFakeState] = useState(2);
const payload = { name: name, description: description, type: type };
const handleOnDragEnd = (result) => {
@ -62,17 +71,21 @@ const AddQuestionsFromBank = ({
if (source.droppableId !== destination?.droppableId) {
if (destination?.droppableId == "Choosed_Questions_Form_Bank") {
dispatch({ type: "ADD_EXAM_QUESTIONS", payload: choosedQuestion });
dispatch({
type: "REMOVE_QUESTION_FROM_BANK",
payload: choosedQuestion,
});
// dispatch({ type: "ADD_EXAM_QUESTIONS", payload: choosedQuestion });
addExamQuestion(choosedQuestion);
// dispatch({
// type: "REMOVE_QUESTION_FROM_BANK",
// payload: choosedQuestion,
// });
removeQuestionFromBank(choosedQuestion);
} else {
dispatch({ type: "REMOVE_EXAM_QUESTIONS", payload: choosedQuestion });
dispatch({
type: "GET_QUESTION_BACK_TO_BANK",
payload: choosedQuestion,
});
// dispatch({ type: "REMOVE_EXAM_QUESTIONS", payload: choosedQuestion });
removeExamQuestions(choosedQuestion);
// dispatch({
// type: "GET_QUESTION_BACK_TO_BANK",
// payload: choosedQuestion,
// });
getQuestionBackToBank(choosedQuestion);
}
} else {
if (source.droppableId == "Choosed_Questions_Form_Bank") {
@ -104,6 +117,17 @@ const AddQuestionsFromBank = ({
addExamState.questionBank
);
const [activeCourse, setActiveCourse] = useState(null);
useEffect(() => {
if (activeCourse) {
getQuestion({
// lessonId: activeCourse,
// gradeId: addExamState.grade,
lessonId: 3,
gradeId: 7,
});
}
}, [activeCourse]);
useEffect(() => {
setSortedQuestionBank(addExamState.questionBank);
}, [addExamState]);
@ -137,6 +161,16 @@ const AddQuestionsFromBank = ({
addExamState.courses.filter((itm) => itm.id == selectedCourse.id)[0]
?.selectedQuestions
);
const addLessonHandler = () => {
setAddLessonPart(true);
setQuestionairePopUp(false);
};
const addLessonPartBtnHandler = () => {
let name = document.querySelector("#addLessonPartInput").value;
addLesson({ name });
};
return (
<div className="flex flex-col h-screen relative">
{questionarePopUp && (
@ -186,51 +220,66 @@ const AddQuestionsFromBank = ({
</h1>
{lessonList?.map((item, index) => (
<>
<React.Fragment key={index}>
<div className="w-full flex items-center py-2 justify-start border-b pl-8 border-gray-200">
<Checkbox
name={`PICK_QUESTIONARE_${index}`}
onChange={(e) =>
e.target.checked
? dispatch({ type: "ADD_EXAM_COURSE", payload: item })
: dispatch({
type: "REMOVE_EXAM_COURSE",
payload: item,
})
? addExamCourse(item)
: removeExamCourse(item)
}
/>
<h2 className="text-red26 font-bold mr-4">{item?.name}</h2>
</div>
</>
</React.Fragment>
))}
<div className="w-full pt-4 flex justify-end px-5">
<button
className="p-2 px-4 bg-red52 text-white rounded-md shadow-md"
onClick={addLessonHandler}
>
افزودن درس جدید
</button>
<button
className="p-2 px-4 bg-red52 text-white rounded-md shadow-md mr-2"
onClick={() => setQuestionairePopUp(false)}
>
افزودن
ثبت دروس
</button>
</div>
</div>
</div>
)}
{addQuestionPopup === "component" && (
// <AddQuestionPopUp
// 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,
// })
// }}
// />
<></>
{addLessonPart && (
<div className="w-full z-10 fixed h-screen backdrop-blur flex items-center top-0 justify-center ">
<AiOutlineCloseCircle
className="text-4xl text-red-600 cursor-pointer absolute top-6 left-20 z-20"
onClick={() => setAddLessonPart(false)}
/>
<input
type="text"
id="addLessonPartInput"
className="w-1/3 h-10 rounded px-2 border"
placeholder="نام درس"
/>
{!addLessonLoading && (
<div
className="h-10 w-20 px-2 flex items-center justify-center text-white bg-red52 rounded-md mr-2 cursor-pointer"
onClick={addLessonPartBtnHandler}
>
افزودن
</div>
)}
{addLessonLoading && (
<div
className="h-10 w-20 px-2 flex items-center justify-center text-white bg-red52 rounded-md mr-2"
onClick={addLessonPartBtnHandler}
>
<img src={loadingGiff} alt="loadingGiff" className="h-7" />
</div>
)}
</div>
)}
<div className="flex py-3 items-center px-10 border-b border-gray-200">
<div className="flex flex-col w-1/6">
@ -277,7 +326,7 @@ const AddQuestionsFromBank = ({
{...provided.droppableProps}
ref={provided.innerRef}
>
{addExamState.courses.length > 0 &&
{addExamState?.courses?.length > 0 &&
addExamState.courses.map((item, index) => (
<Draggable
draggableId={`COURSE_${item.id}`}
@ -294,14 +343,17 @@ const AddQuestionsFromBank = ({
? "bg-pinkF5 border border-red52 text-red52"
: "bg-white border border-gray-300 text-blue3A"
} items-center justify-between pt-4 w-36 h-32 mx-2 font-bold rounded-xl cursor-pointer`}
onClick={() => setSelectedCourse(item)}
onClick={() => {
setSelectedCourse(item);
setActiveCourse(item.id);
}}
>
<div
className="w-full flex justify-between items-center "
style={{ direction: "ltr" }}
>
<div className=" rtl px-2 text-white bg-red52">
{item.selectedQuestions.length} سوال
{item?.selectedQuestions?.length} سوال
</div>
<p className=" text-left px-4">
@ -640,20 +692,20 @@ const AddQuestionsFromBank = ({
{(provided) => (
<div
className="w-full py-1 flex flex-col items-center overflow-x-hidden overflow-scroll"
style={{ height: "30vh" }}
style={{ height: "50vh" }}
>
<div
className="w-11/12"
{...provided.droppableProps}
ref={provided.innerRef}
>
{sortedQuestionBank
?.filter((itm) => itm.courseId == selectedCourse.id)
?.map((course, index) => (
{/* sortedQuestionBan-------------- */}
{questionList?.map((course, index) => (
<React.Fragment key={index}>
<Draggable
draggableId={`_${course.questionId}`}
index={course.questionId}
key={`CHOOSED_QUESTIONS_${course.questionId}`}
draggableId={`_${course.id}`}
index={course.id}
key={`CHOOSED_QUESTIONS_${course.id}`}
>
{(provided) => (
<div
@ -696,7 +748,8 @@ const AddQuestionsFromBank = ({
</div>
)}
</Draggable>
))}
</React.Fragment>
))}
</div>
{/* <Question /> */}
@ -735,11 +788,21 @@ const AddQuestionsFromBank = ({
const mapStateToProps = (state) => ({
grades: state.publicApi.grades,
addExamState: state.addExamReduser,
// lessonList: state.lesson.list
addLessonLoading: state.lesson.loading,
questionList: state.question.list,
// lessonList: state.lesson.list
});
const mapDispatchToProps = {
// getLesson:lesson.list
addLesson: lesson.add,
addExamCourse: exam.addExamCourse,
removeExamCourse: exam.removeExamCourse,
getQuestion: question.list,
addExamQuestion: exam.addExamQuestion,
removeQuestionFromBank: exam.removeQuestionFromBank,
removeExamQuestions: exam.removeExamQuestions,
getQuestionBackToBank: exam.getQuestionBackToBank,
changeQuestionOrder: exam.changeQuestionOrder,
};
export default connect(

@ -284,33 +284,35 @@ const AddQuestionnaireExam = ({
ref={provided.innerRef}
>
{addExamState.questionnaires.map((item, index) => (
<Draggable
draggableId={`QUESTIONNAIRE_${item.id}`}
index={index}
key={`CHOOSED_QUESTIONNAIRE_${item.id}`}
>
{(provided) => (
<div
{...provided.draggableProps}
{...provided.dragHandleProps}
ref={provided.innerRef}
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: item.courses,
})
}
>
<p className="text-red52">دفترچه {item.name}</p>
</div>
)}
</Draggable>
<React.Fragment key={index}>
<Draggable
draggableId={`QUESTIONNAIRE_${item.id}`}
index={index}
key={`CHOOSED_QUESTIONNAIRE_${item.id}`}
>
{(provided) => (
<div
{...provided.draggableProps}
{...provided.dragHandleProps}
ref={provided.innerRef}
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: item.courses,
})
}
>
<p className="text-red52">دفترچه {item.name}</p>
</div>
)}
</Draggable>
</React.Fragment>
))}
</div>
@ -352,16 +354,20 @@ const AddQuestionnaireExam = ({
<div className="w-4/5 ">
{addExamState.questionnaires
.find((itm) => itm.id == selectedQuestionare.id)
?.courses.map((item) => (
<SelectedCourse
title={item.name}
coefficient={item.coefficient}
questionQuantity={item.questionEnd - item.questionStart}
onClick={() => {
setSelectedCourse(item);
console.log(selectedCourse);
}}
/>
?.courses.map((item,index) => (
<React.Fragment key={index}>
<SelectedCourse
title={item.name}
coefficient={item.coefficient}
questionQuantity={
item.questionEnd - item.questionStart
}
onClick={() => {
setSelectedCourse(item);
console.log(selectedCourse);
}}
/>
</React.Fragment>
))}
</div>
</div>

@ -18,10 +18,11 @@ const AddQuestions = ({
getLesson,
lessonList,
addLesson,
lastAdd,
}) => {
useEffect(() => {
getLesson();
}, []);
}, [lastAdd]);
return addExamState.type == 2 ? (
<AddQuestionnaireExam stepClick={stepClick} backStep={backStep} />
@ -39,6 +40,7 @@ const mapStateToProps = (state) => ({
grades: state.publicApi.grades,
addExamState: state.addExamReduser,
lessonList: state.lesson.list,
lastAdd: state.lesson.lastAdd,
});
const mapDispatchToProps = {

Loading…
Cancel
Save