exam api | 245

main
alireza khaji 2 years ago
parent 578a025af5
commit 3e9308ed62
  1. 137
      src/components/Stepper/index.js
  2. 4
      src/redux/actions/exam.js
  3. 44
      src/redux/reducers/exam.js
  4. 8
      src/redux/reducers/exam2.js
  5. 17
      src/view/addExam/components/question.js
  6. 135
      src/view/addExam/views/AddQuestionsFromBank.js
  7. 309
      src/view/addExam/views/ViewExam.js
  8. 47
      src/view/addExam/views/addQuestions.js

@ -1,6 +1,6 @@
import React, {useState} from "react";
import React, { useState } from "react";
import separate from "../../utils/separate";
import './index.css'
import "./index.css";
function Stepper({
direction,
@ -9,10 +9,8 @@ function Stepper({
count,
currentStep,
steps,
onStepClick
onStepClick,
}) {
return (
<div
className={`flex items-center ${
@ -20,69 +18,92 @@ 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"
}`}
>
<div className="flex items-center justify-start w-full">
<div
className="w-8 h-8 text-white text-sm rounded-full flex justify-center items-center"
style={{
backgroundColor:
item.active ? activeColor : '#fff',
border: item.active ? '' : '1px solid #c8c8c8'
}}
>
{
item.active ? <svg width="37" height="37" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.75 12L10.58 14.83L16.25 9.17004" stroke="#fff" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
: null
}
</div>
<div className="flex justify-center items-center">
<p className={`mr-3 ml-1 text-xl font-bold ${item.active ? 'text-red-500' : 'text-gray-400'} text-opacity-50`}>{index + 1}</p>
<p className={` giveMeEllipsis font-bold ${item.active ? 'text-red26' : 'text-gray-400'} ${direction === 'horizontal' && 'text-xs' }`}> {item.title}</p>
<div
key={index}
className={`flex items-center w-full relative ${
direction === "horizontal"
? "flex-row justify-between"
: "flex-col justify-start"
}`}
>
<div className="flex items-center justify-start w-full">
<div
className="w-8 h-8 text-white text-sm rounded-full flex justify-center items-center"
style={{
backgroundColor: item.active ? activeColor : "#fff",
border: item.active ? "" : "1px solid #c8c8c8",
}}
>
{item.active ? (
<svg
width="37"
height="37"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M7.75 12L10.58 14.83L16.25 9.17004"
stroke="#fff"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
) : null}
</div>
<div className="flex justify-center items-center">
<p
className={`mr-3 ml-1 text-xl font-bold ${
item.active ? "text-red-500" : "text-gray-400"
} text-opacity-50`}
>
{index + 1}
</p>
<p
className={` giveMeEllipsis font-bold ${
item.active ? "text-red26" : "text-gray-400"
} ${direction === "horizontal" && "text-xs"}`}
>
{" "}
{item.title}
</p>
</div>
</div>
</div>
{count !== (Number(index) + 1) && (
<span
className={`transform my-1 ${
direction === "horizontal"
? "w-full h-2 mx-4"
: "h-8 w-1 rounded-xl"
}`}
style={{
opacity: '0.5',
background: item.active ? activeColor : deactiveColor,
// borderTop: direction === "horizontal" ? `3px solid ${
// currentStep === Number(index) ? activeColor : deactiveColor
// }` : '',
// borderRight: direction === "vertical" ? `3px solid ${
// currentStep === Number(index) ? activeColor : deactiveColor
// }` : '',
transform : `${direction === "horizontal" ? 'translateY(1px)' : 'translateX(70px)'}`
}}
></span>
)}
</div>
{count !== Number(index) + 1 && (
<span
className={`transform my-1 ${
direction === "horizontal"
? "w-full h-2 mx-4"
: "h-8 w-1 rounded-xl"
}`}
style={{
opacity: "0.5",
background: item.active ? activeColor : deactiveColor,
// borderTop: direction === "horizontal" ? `3px solid ${
// currentStep === Number(index) ? activeColor : deactiveColor
// }` : '',
// borderRight: direction === "vertical" ? `3px solid ${
// currentStep === Number(index) ? activeColor : deactiveColor
// }` : '',
transform: `${
direction === "horizontal"
? "translateY(1px)"
: "translateX(70px)"
}`,
}}
></span>
)}
</div>
))}
</div>
);
}
export default Stepper;
Stepper.defaultProps = {
direction: "vertical",
activeColor: "#df1452",
deactiveColor: "#DBDBDB",
};

@ -9,6 +9,10 @@ const exam = {
(data = {}) =>
async (dispatch) =>
await proxy.post("exam/parentAdd", data, { dispatch }),
preview:
(data = {}) =>
async (dispatch) =>
await proxy.get("exam/preview", data, { dispatch }),
addExamDescription: (data = {}) => {
return (dispatch) => {
dispatch({

@ -52,20 +52,20 @@ const initialState = {
],
courseBank: [
{
id: 1,
title: 'ریاضی',
coefficient: 4,
numberOfOptions: 4,
selectedQuestions: []
},
{
id: 2,
title: 'شیمی',
coefficient: 3,
numberOfOptions: 3,
selectedQuestions: []
},
// {
// id: 1,
// title: 'ریاضی',
// coefficient: 4,
// numberOfOptions: 4,
// selectedQuestions: []
// },
// {
// id: 2,
// title: 'شیمی',
// coefficient: 3,
// numberOfOptions: 3,
// selectedQuestions: []
// },
],
questionBank: [
{
@ -257,9 +257,9 @@ export default function addExamReduser(state = initialState, { type, payload })
case 'ADD_EXAM_COURSE':
return {
...state,
courses: [...state.courses, payload]
}
...state,
courses: [...state.courses, { ...payload, selectedQuestions:[]}],
};
case 'REMOVE_EXAM_COURSE':
return {
...state,
@ -267,9 +267,15 @@ export default function addExamReduser(state = initialState, { type, payload })
}
case 'ADD_EXAM_QUESTIONS':
console.log("??????????????");
console.log(payload)
const othercourses = state.courses.filter(itm => itm.id !== payload.courseId)
const selectedC = state.courses.filter(itm => itm.id == payload.courseId)
console.log(state.courses);
const othercourses = state.courses.filter(
(itm) => itm.id !== payload.lessonId
);
const selectedC = state.courses.filter(
(itm) => itm.id == payload.lessonId
);
selectedC[0] = { ...selectedC[0], selectedQuestions: [payload, ...selectedC[0].selectedQuestions] }
const newCourses = [...othercourses, ...selectedC]

@ -5,16 +5,20 @@ import { toast } from "react-toastify";
const initialState = {
loading: false,
error: null,
info:null
info: null,
lastExamAdd: null,
preview : null
};
export default function exam2(state = initialState, action) {
let { type, data } = action;
switch (type) {
case "exam/info":
return { ...state, loading: false, info: data, error: null };
case "exam/preview":
return { ...state, loading: false, preview: data, error: null };
case "exam/parentAdd":
toast.success("آزمون شما با موفقیت ثبت شد");
return { ...state, loading: false, error: null };
return { ...state, loading: false, error: null, lastExamAdd: data.id };
default:
return state;
}

@ -4,14 +4,15 @@ 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);
// useEffect(()=>{
// })
optionsList = [];
for (let i = 0; i < data.type; i++) {
optionsList.push(data[`option${i + 1}`]);
}
// console.log("==|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
// console.log(optionsList);
const gozine = [
'الف',
'ب',

@ -32,6 +32,7 @@ const AddQuestionsFromBank = ({
removeQuestionFromBank,
removeExamQuestions,
getQuestionBackToBank,
submitHandler,
}) => {
const [name, setName] = useState(null);
const [type, setType] = useState(null);
@ -171,6 +172,11 @@ const AddQuestionsFromBank = ({
let name = document.querySelector("#addLessonPartInput").value;
addLesson({ name });
};
const nextStephandler=()=>{
submitHandler();
stepClick();
}
return (
<div className="flex flex-col h-screen relative">
{questionarePopUp && (
@ -281,6 +287,7 @@ const AddQuestionsFromBank = ({
)}
</div>
)}
{/* ====================================================================================== */}
<div className="flex py-3 items-center px-10 border-b border-gray-200">
<div className="flex flex-col w-1/6">
<div className="text-blue3A text-lg font-bold text-right px-4 border-r-4 border-blue65">
@ -328,70 +335,73 @@ const AddQuestionsFromBank = ({
>
{addExamState?.courses?.length > 0 &&
addExamState.courses.map((item, index) => (
<Draggable
draggableId={`COURSE_${item.id}`}
index={index}
key={`CHOOSED_COURSE_${item.id}`}
>
{(provided) => (
<div
{...provided.draggableProps}
{...provided.dragHandleProps}
ref={provided.innerRef}
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 pt-4 w-36 h-32 mx-2 font-bold rounded-xl cursor-pointer`}
onClick={() => {
setSelectedCourse(item);
setActiveCourse(item.id);
}}
>
<>
{console.log(item)}
<Draggable
draggableId={`COURSE_${item.id}`}
index={index}
key={`CHOOSED_COURSE_${item.id}`}
>
{(provided) => (
<div
className="w-full flex justify-between items-center "
style={{ direction: "ltr" }}
{...provided.draggableProps}
{...provided.dragHandleProps}
ref={provided.innerRef}
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 pt-4 w-36 h-32 mx-2 font-bold rounded-xl cursor-pointer`}
onClick={() => {
setSelectedCourse(item);
setActiveCourse(item.id);
}}
>
<div className=" rtl px-2 text-white bg-red52">
{item?.selectedQuestions?.length} سوال
<div
className="w-full flex justify-between items-center "
style={{ direction: "ltr" }}
>
<div className=" rtl px-2 text-white bg-red52">
{item?.selectedQuestions?.length} سوال
</div>
<p className=" text-left px-4">
<span
onClick={() => {
dispatch({
type: "REMOVE_EXAM_COURSE",
payload: item,
});
setSelectedCourse(null);
setFakeState(fakeState + 24);
}}
>
{" "}
x{" "}
</span>
</p>
</div>
<p className=" text-left px-4">
<span
onClick={() => {
dispatch({
type: "REMOVE_EXAM_COURSE",
payload: item,
});
setSelectedCourse(null);
setFakeState(fakeState + 24);
}}
<p className="text-red52">{item?.name}</p>
<div className="w-full flex justify-between px-2 pb-2">
<p
className={`w-1/2 border-l text-center text-xs ${
selectedCourse.id === item.id
? "border-red52"
: "border-gray-300"
} text-gray-400`}
>
{" "}
x{" "}
</span>
</p>
</div>
<p className="text-red52">{item.title}</p>
<div className="w-full flex justify-between px-2 pb-2">
<p
className={`w-1/2 border-l text-center text-xs ${
selectedCourse.id === item.id
? "border-red52"
: "border-gray-300"
} text-gray-400`}
>
{" "}
ضریب {item.coefficient}
</p>
<p className="w-1/2 text-center text-xs font-light text-gray-400">
{item.numberOfOptions} گزینه
</p>
ضریب {item.coefficient}
</p>
<p className="w-1/2 text-center text-xs font-light text-gray-400">
{item.numberOfOptions} گزینه
</p>
</div>
</div>
</div>
)}
</Draggable>
)}
</Draggable>
</>
))}
</div>
</div>
@ -409,6 +419,7 @@ const AddQuestionsFromBank = ({
</div>
</div>
</div>
{/* ====================================================================================== */}
{/* Picking Question Container */}
<DragDropContext
onDragEnd={(result) => handleOnDragEnd(result)}
@ -421,10 +432,10 @@ const AddQuestionsFromBank = ({
)[0]?.selectedQuestions[result.source.index]
);
} else {
console.log("MMMMMMMMMMMMMMMMMMMM");
console.log(result);
seChoosedQuestion(
addExamState.questionBank.find(
(itm) => itm.questionId == result.source.index
)
questionList?.find((itm) => itm.id == result.source.index)
);
}
}}
@ -776,9 +787,7 @@ const AddQuestionsFromBank = ({
<Button
title="مرحله بعدی"
className="w-1/12"
onClick={() => {
stepClick();
}}
onClick={nextStephandler}
/>
</div>
</div>

@ -11,13 +11,31 @@ import '@react-pdf-viewer/core/lib/styles/index.css';
import Preview from "../../../components/AnswerSheet/preview";
import { exam } from "../../../redux/actions";
import moment from "jalali-moment";
import preview from "../../../components/AnswerSheet/preview";
const ViewExam = ({ addExamState, stepClick, backStep, parentAdd }) => {
const ViewExam = ({
addExamState,
stepClick,
backStep,
parentAdd,
examPreview,
examId,
getExamPreview,
}) => {
useEffect(() => {
window.scrollTo(0, 0);
console.log("oooooooooooooooooooooooooooooo");
console.log(addExamState);
console.log(examId);
}, []);
useEffect(() => {
getExamPreview({ id: examId });
// getExamPreview({ id: 9 });
}, [examId]);
console.log(examPreview);
const grades = [
"",
"اول",
@ -46,142 +64,93 @@ const ViewExam = ({ addExamState, stepClick, backStep, parentAdd }) => {
}
let questionCount = 0;
for(let i=0;i<addExamState.courses.length;i++){
for (let i = 0; i < addExamState.courses.length; i++) {
questionCount += addExamState.courses[i].selectedQuestions.length;
}
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>");
console.log(addExamState.startDate.month);
const submitHandler=()=>{
parentAdd({
name: addExamState.name,
description: addExamState.description,
// startDate: moment(
// `${addExamState.startDate?.year}/${addExamState.startDate?.month}/${addExamState.startDate?.day} ${addExamState.startDate?.hour}:${addExamState.startDate?.minute}`
// )
// .locale("en")
// .format("YYYY-MM-DD HH:mm"),
startDate: moment
.from(
`${addExamState.startDate?.year}/${addExamState.startDate?.month}/${addExamState.startDate?.day} ${addExamState.startDate?.hour}:${addExamState.startDate?.minute}`,
"fa",
"YYYY/MM/DD HH:mm"
)
.format("YYYY-MM-DD HH:mm"),
endDate: moment
.from(
`${addExamState.endDate?.year}/${addExamState.endDate?.month}/${addExamState.endDate?.day} ${addExamState.endDate?.hour}:${addExamState.endDate?.minute}`,
"fa",
"YYYY/MM/DD HH:mm"
)
.format("YYYY-MM-DD HH:mm"),
duration: addExamState?.duration || 60,
// duration:30,
type: addExamState.type,
//questionCount: addExamState.questions.length,
questionCount,
examGroupId: addExamState.groupId,
levelCriterion: null,
budgetFileId: addExamState.budgetFileId,
});
const submitHandler = () => {
// stepClick();
}
};
const createOptions = (item) => {
let optionsList = [];
for (let i = 0; i < item.type; i++) {
optionsList.push(item[`option${i + 1}`]);
}
console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
console.log(optionsList);
return optionsList;
};
return (
<div className="w-[95%] flex flex-col mx-10">
<div className="w-4/5 py-6 flex items-center">
<h1 className="text-2xl font-bold ml-6">آزمون {addExamState.name}</h1>
<h3 className="text-gray-500"> پایه {grades[addExamState.grade]}</h3>
<h1 className="text-2xl font-bold ml-6">
آزمون {examPreview?.exam?.name}
</h1>
<h3 className="text-gray-500">
{" "}
پایه {grades[examPreview?.exam?.gradeId]}
</h3>
</div>
{addExamState.type !== "pdf" ? (
<div className="w-full flex flex-col text-right">
{addExamState.courses.map((item, index) => (
<div
className={`flex flex-col w-full py-6 border-b-2 border-gray-400`}
>
<h1 className="text-xl">سوالات {item.title}</h1>
<p className="text-gray-500 pt-2">ضریب {item.coefficient}</p>
{item.selectedQuestions.map((question, idx) => (
<div
className={`flex flex-col w-full py-4 ${
item.selectedQuestions.length !== idx + 1 &&
"border-b border-gray-200"
}`}
key={`PISHNAMAYESH__${question.questionId}`}
>
{console.log(item.selectedQuestions.length)}
{console.log(idx + 1)}
<div className="flex items-start pb-4">
<h1 className="text-xl">{question.title}</h1>
<p className="w-1/12 pr-4">{question.score} نمره</p>
<div className="w-full mt-6 pb-6 border-b">
{examPreview?.exam?.type && (
<div className="w-full">
{examPreview?.questions?.map((item, index) => (
<div
key={index}
className="w-full mb-4 border-b border-[#d3d3d3]"
>
<div className="w-full flex items-center">
<div className="w-8 h-8 bg-gray-300 flex items-center justify-center rounded-md ml-2">
{index + 1}
</div>
{question.options.map((option) => (
<div className="flex w-full my-2 items-center">
<div className="w-full text-lg text-right">
{item?.text}{" "}
<span className="text-sm">{`(نمره : ${
item?.score || 1
})`}</span>
</div>
</div>
<div className="w-full mt-4">
{createOptions(item).map((choice, index2) => (
<div key={index2} className="w-full flex items-stretch mb-2">
<div
className={`${
option.isAnswer
? "bg-green-400 text-white"
: "bg-gray-300"
} w-16 h-14 text-xl flex items-center justify-center rounded-xl rounded-l-none`}
className="w-12 py-3 rounded-r-md flex items-center justify-center bg-gray-300"
style={
choice === item.answer
? { backgroundColor: "#65A30D", color: "#fff" }
: null
}
>
{optionNum[option.id]}
{optionNum[index2 + 1]}
</div>
<div
className={`w-1/4 flex items-center px-6 ${
option.isAnswer ? "bg-green-200" : "bg-gray-200"
} h-14 rounded-xl rounded-r-none`}
className="py-3 rounded-l-md flex items-center px-2 bg-gray-200"
style={
choice === item.answer
? {
backgroundColor: "#84CC16",
color: "#fff",
width: "calc(100% - 48px)",
}
: { width: "calc(100% - 48px)" }
}
>
{option.title}
{choice}
</div>
</div>
))}
</div>
))}
</div>
))}
</div>
) : (
addExamState.type === "pdf" && (
<div className="flex flex-col w-full items-center">
<h1 className="w-full text-right pb-4 text-lg font-bold">
دفترچه ها
</h1>
<div className="w-full flex flex-wrap">
{addExamState?.questionnaires?.map((item) => (
<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-center w-36 h-32 mx-2 font-bold rounded-xl cursor-pointer`}
onClick={() => setSelectedCourse(item)}
>
<p className="text-red52">{item.name}</p>
</div>
))}
</div>
<div className="flex w-full border-t border-gray-200 mt-10">
<div
className="w-1/2 border-l border-gray-200 py-20 "
style={{ height: "750px" }}
>
<Worker workerUrl="https://unpkg.com/pdfjs-dist@2.13.216/build/pdf.worker.min.js">
<Viewer fileUrl={selectedCourse.fileUrl} />
</Worker>
</div>
<div
className="w-1/2 my-20 flex justify-center overflow-x-hidden overflow-scroll"
style={{ height: "600px" }}
>
<div className="w-2/3">
<Preview answers={selectedCourse.answers} />
</div>
</div>
</div>
))}
</div>
)
)}
)}
</div>
<div className="w-full flex justify-end font-bold mt-6">
<button
className="py-4 font-bold px-6 rounded-lg text-red52 mr-4"
@ -201,12 +170,116 @@ const ViewExam = ({ addExamState, stepClick, backStep, parentAdd }) => {
};
const mapStateToProps = (state) => ({
grades: state.publicApi.grades,
addExamState: state.addExamReduser
})
grades: state.publicApi.grades,
addExamState: state.addExamReduser,
examId: state.exam2.lastExamAdd,
examPreview:state.exam2.preview
});
const mapDispatchToProps = {
parentAdd: exam.parentAdd,
getExamPreview : exam.preview
};
export default connect(mapStateToProps, mapDispatchToProps)(ViewExam);
export default connect(mapStateToProps, mapDispatchToProps)(ViewExam);
// question.options;
// {
// addExamState.type !== "pdf" ? (
// <div className="w-full flex flex-col text-right">
// {addExamState.courses?.map((item, index) => (
// <div className={`flex flex-col w-full py-6 border-b-2 border-gray-400`}>
// <h1 className="text-xl">سوالات {item?.name}</h1>
// <p className="text-gray-500 pt-2">ضریب {item?.coefficient}</p>
// {item?.selectedQuestions?.map((question, idx) => (
// <div
// className={`flex flex-col w-full py-4 ${
// item.selectedQuestions.length !== idx + 1 &&
// "border-b border-gray-200"
// }`}
// key={`PISHNAMAYESH__${question.id}`}
// >
// {console.log(item.selectedQuestions.length)}
// {console.log(idx + 1)}
// <div className="flex items-start pb-4">
// <h1 className="text-xl">{question?.text}</h1>
// <p className="w-1/12 pr-4">{question?.score} نمره</p>
// </div>
// {createOptions(question).map((option, INDEX) => (
// <div className="flex w-full my-2 items-center">
// <div
// className={`${
// option.isAnswer
// ? "bg-green-400 text-white"
// : "bg-gray-300"
// } w-16 h-14 text-xl flex items-center justify-center rounded-xl rounded-l-none`}
// >
// {optionNum[INDEX + 1]}
// </div>
// <div
// className={`w-1/4 flex items-center px-6 ${
// option.isAnswer ? "bg-green-200" : "bg-gray-200"
// } h-14 rounded-xl rounded-r-none`}
// >
// {option}
// </div>
// </div>
// ))}
// </div>
// ))}
// </div>
// ))}
// </div>
// ) : (
// addExamState.type === "pdf" && (
// <div className="flex flex-col w-full items-center">
// <h1 className="w-full text-right pb-4 text-lg font-bold">دفترچه ها</h1>
// <div className="w-full flex flex-wrap">
// {addExamState?.questionnaires?.map((item) => (
// <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-center w-36 h-32 mx-2 font-bold rounded-xl cursor-pointer`}
// onClick={() => setSelectedCourse(item)}
// >
// <p className="text-red52">{item.name}</p>
// </div>
// ))}
// </div>
// <div className="flex w-full border-t border-gray-200 mt-10">
// <div
// className="w-1/2 border-l border-gray-200 py-20 "
// style={{ height: "750px" }}
// >
// <Worker workerUrl="https://unpkg.com/pdfjs-dist@2.13.216/build/pdf.worker.min.js">
// <Viewer fileUrl={selectedCourse.fileUrl} />
// </Worker>
// </div>
// <div
// className="w-1/2 my-20 flex justify-center overflow-x-hidden overflow-scroll"
// style={{ height: "600px" }}
// >
// <div className="w-2/3">
// <Preview answers={selectedCourse.answers} />
// </div>
// </div>
// </div>
// </div>
// )
// );
// }

@ -1,3 +1,4 @@
import moment from "jalali-moment";
import React, { useEffect, useState } from "react";
import { connect } from "react-redux";
import AnswerSheet from "../../../components/AnswerSheet";
@ -6,7 +7,7 @@ import DatePicker from "../../../components/Calendar/CalendarComponents/DatePick
import Checkbox from "../../../components/Checkbox";
import RangeDatePicker from "../../../components/RangeDatePicker";
import SelectedCourse from "../../../components/selectedCourse";
import { lesson } from "../../../redux/actions";
import { exam, lesson } from "../../../redux/actions";
import AddQuestionnaireCourse from "../components/addQuestionnaireCourse";
import AddQuestionnaireExam from "./addQuestionnaireExam";
import AddQuestionsFromBank from "./AddQuestionsFromBank";
@ -19,11 +20,51 @@ const AddQuestions = ({
lessonList,
addLesson,
lastAdd,
parentAdd,
}) => {
useEffect(() => {
getLesson();
}, [lastAdd]);
const submitHandler = () => {
let questionCount = 0;
for (let i = 0; i < addExamState.courses.length; i++) {
questionCount += addExamState.courses[i].selectedQuestions.length;
}
parentAdd({
name: addExamState.name,
description: addExamState.description,
// startDate: moment(
// `${addExamState.startDate?.year}/${addExamState.startDate?.month}/${addExamState.startDate?.day} ${addExamState.startDate?.hour}:${addExamState.startDate?.minute}`
// )
// .locale("en")
// .format("YYYY-MM-DD HH:mm"),
startDate: moment
.from(
`${addExamState.startDate?.year}/${addExamState.startDate?.month}/${addExamState.startDate?.day} ${addExamState.startDate?.hour}:${addExamState.startDate?.minute}`,
"fa",
"YYYY/MM/DD HH:mm"
)
.format("YYYY-MM-DD HH:mm"),
endDate: moment
.from(
`${addExamState.endDate?.year}/${addExamState.endDate?.month}/${addExamState.endDate?.day} ${addExamState.endDate?.hour}:${addExamState.endDate?.minute}`,
"fa",
"YYYY/MM/DD HH:mm"
)
.format("YYYY-MM-DD HH:mm"),
duration: addExamState?.duration || 60,
// duration:30,
type: addExamState.type,
//questionCount: addExamState.questions.length,
questionCount :questionCount,
examGroupId: addExamState.groupId,
levelCriterion: null,
budgetFileId: addExamState.budgetFileId,
});
// stepClick();
};
return addExamState.type == 2 ? (
<AddQuestionnaireExam stepClick={stepClick} backStep={backStep} />
) : (
@ -32,6 +73,7 @@ const AddQuestions = ({
backStep={backStep}
lessonList={lessonList}
addLesson={addLesson}
submitHandler={submitHandler}
/>
);
};
@ -45,7 +87,8 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = {
getLesson: lesson.list,
addLesson: lesson.add
addLesson: lesson.add,
parentAdd: exam.parentAdd,
};
export default connect(mapStateToProps, mapDispatchToProps)(AddQuestions);

Loading…
Cancel
Save