create exam api | 400

main
alireza khaji 2 years ago
parent a6478f5679
commit 093924033b
  1. 22
      src/redux/actions/exam.js
  2. 22
      src/redux/actions/examQuestion.js
  3. 2
      src/redux/actions/index.js
  4. 735
      src/redux/reducers/exam.js
  5. 8
      src/redux/reducers/exam2.js
  6. 30
      src/redux/reducers/examQuestion.js
  7. 2
      src/redux/reducers/index.js
  8. 226
      src/view/addExam/components/addQuestion.js
  9. 89
      src/view/addExam/components/question.js
  10. 225
      src/view/addExam/views/AddQuestionsFromBank.js
  11. 12
      src/view/addExam/views/ViewExam.js
  12. 40
      src/view/addExam/views/addQuestionnaireExam.js

@ -17,6 +17,10 @@ const exam = {
(data = {}) => (data = {}) =>
async (dispatch) => async (dispatch) =>
await proxy.post("exam/subexamAdd", data, { dispatch }), await proxy.post("exam/subexamAdd", data, { dispatch }),
confirm:
(data = {}) =>
async (dispatch) =>
await proxy.put("exam/confirm", data, { dispatch }),
emptySubexamList: (data = {}) => { emptySubexamList: (data = {}) => {
return (dispatch) => { return (dispatch) => {
dispatch({ dispatch({
@ -36,7 +40,7 @@ const exam = {
addExamGradeAndGroup: (data = {}) => { addExamGradeAndGroup: (data = {}) => {
return (dispatch) => { return (dispatch) => {
dispatch({ dispatch({
type: "ADD_EXAM_GRADE_AND_GROUP", type: "ADD_EXAM_GRADE_AND_GROUP",
payload: data, payload: data,
}); });
}; };
@ -65,6 +69,14 @@ const exam = {
}); });
}; };
}, },
addExamQuestion2: (data = {}) => {
return (dispatch) => {
dispatch({
type: "ADD_EXAM_QUESTIONS2",
payload: data,
});
};
},
removeQuestionFromBank: (data = {}) => { removeQuestionFromBank: (data = {}) => {
return (dispatch) => { return (dispatch) => {
dispatch({ dispatch({
@ -97,6 +109,14 @@ const exam = {
}); });
}; };
}, },
addCustomQuestion: (data = {}) => {
return (dispatch) => {
dispatch({
type: "ADD_CUSTOM_QUESTION",
payload: data,
});
};
},
}; };
export default exam; export default exam;

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

@ -18,6 +18,8 @@ export { default as examGroup } from "./examGroup";
export { default as lesson } from "./lesson"; export { default as lesson } from "./lesson";
export { default as question } from "./question"; export { default as question } from "./question";
export { default as category } from "./category"; export { default as category } from "./category";
export { default as examQuestion } from "./examQuestion";

@ -1,363 +1,402 @@
import { IoReturnUpBack } from "react-icons/io5" import { IoReturnUpBack } from "react-icons/io5";
import fizikpdf from '../../assets/fizik.pdf' import fizikpdf from "../../assets/fizik.pdf";
import samplePdf from '../../assets/sample.pdf' import samplePdf from "../../assets/sample.pdf";
const initialState = { const initialState = {
grade: 8, grade: 8,
groupId: 0, groupId: 0,
name: '', name: "",
startDate: new Date(), startDate: new Date(),
endDate: new Date(), endDate: new Date(),
startTime: '19:0', startTime: "19:0",
endTime: '', endTime: "",
description: '', description: "",
type: 'bank', type: "bank",
duration:null, duration: null,
budgetFileId:null, budgetFileId: null,
questionnaires: [ questionnaires: [
// {
// id: 1,
// name: "عمومی",
// fileUrl: fizikpdf,
// courses: [
// {
// id: 0,
// questionnaireId: 1,
// name: "دینی",
// coefficient: 4,
// questionStart: 1,
// questionEnd: 21,
// },
// ],
// answers: [],
// },
// {
// id: 2,
// name: "اختصاصی",
// fileUrl: samplePdf,
// courses: [],
// answers: [],
// },
],
answers: [],
courseBank: [
// {
// id: 1,
// title: 'ریاضی',
// coefficient: 4,
// numberOfOptions: 4,
// selectedQuestions: []
// },
// {
// id: 2,
// title: 'شیمی',
// coefficient: 3,
// numberOfOptions: 3,
// selectedQuestions: []
// },
],
questionBank: [
{
questionId: 1,
courseId: 2,
title: "تترا فلورید اسید چنتا اسید داره؟",
answeredPercentage: "83%",
score: 1,
options: [
{ {
id: 1, id: 1,
name: 'عمومی', title: "تترا",
fileUrl: fizikpdf, isAnswer: false,
courses: [
{
id: 0,
questionnaireId: 1,
name: 'دینی',
coefficient: 4,
questionStart: 1,
questionEnd: 21
},
],
answers:[
]
}, },
{ {
id: 2, id: 2,
name: 'اختصاصی', title: "سه ترا",
fileUrl: samplePdf, isAnswer: false,
courses: [], },
answers:[
]
}
],
answers: [
],
courseBank: [
// {
// id: 1,
// title: 'ریاضی',
// coefficient: 4,
// numberOfOptions: 4,
// selectedQuestions: []
// },
// {
// id: 2,
// title: 'شیمی',
// coefficient: 3,
// numberOfOptions: 3,
// selectedQuestions: []
// },
],
questionBank: [
{ {
questionId: 1, id: 3,
courseId: 2, title: "هویج و گوجه فرنگی؟",
title: 'تترا فلورید اسید چنتا اسید داره؟', isAnswer: true,
answeredPercentage: '83%',
score: 1,
options: [
{
id: 1,
title: 'تترا',
isAnswer: false
},
{
id: 2,
title: 'سه ترا',
isAnswer: false
},
{
id: 3,
title: 'هویج و گوجه فرنگی؟',
isAnswer: true
},
{
id: 4,
title: 'فلور تا',
isAnswer: false
},
]
}, },
{ {
questionId: 2, id: 4,
courseId: 2, title: "فلور تا",
title: 'asdaw dsfsdfiermc', isAnswer: false,
answeredPercentage: '83%',
score: 1,
options: [
{
id: 1,
title: 'asdasd',
isAnswer: false
},
{
id: 2,
title: 'asdasd2',
isAnswer: false
},
{
id: 3,
title: '',
isAnswer: true
},
{
id: 4,
title: 'asdasd4',
isAnswer: false
},
]
}, },
],
},
{
questionId: 2,
courseId: 2,
title: "asdaw dsfsdfiermc",
answeredPercentage: "83%",
score: 1,
options: [
{ {
questionId: 3, id: 1,
courseId: 1, title: "asdasd",
title: 'برای حل مساءل مربوط به مساحت زیر نمودار باید از کدام مبحث ریاضی استفاده کرد؟', isAnswer: false,
answeredPercentage: '43%',
score: 1,
options: [
{
id: 1,
title: 'لگاریتم طبیعی',
isAnswer: false
},
{
id: 2,
title: 'حد و مشتق',
isAnswer: false
},
{
id: 3,
title: 'قدر مطلق',
isAnswer: false
},
{
id: 4,
title: 'نخوندم 🗿',
isAnswer: true
},
]
}, },
{ {
questionId: 4, id: 2,
courseId: 2, title: "asdasd2",
title: 'asdaw dsfsdfisdfsdfsfsdfsfsdfsdfermc', isAnswer: false,
answeredPercentage: '83%',
score: 1,
options: [
{
id: 1,
title: 'asdasd',
isAnswer: false
},
{
id: 2,
title: 'asdasd2',
isAnswer: false
},
{
id: 3,
title: 'sdfsdfsdfsfd',
isAnswer: true
},
{
id: 4,
title: 'asdasd4',
isAnswer: false
},
]
}, },
{
], id: 3,
courses: [ title: "",
isAnswer: true,
], },
questions: [ {
id: 4,
], title: "asdasd4",
isAnswer: false,
},
} ],
},
{
questionId: 3,
courseId: 1,
title:
"برای حل مساءل مربوط به مساحت زیر نمودار باید از کدام مبحث ریاضی استفاده کرد؟",
answeredPercentage: "43%",
score: 1,
options: [
{
id: 1,
title: "لگاریتم طبیعی",
isAnswer: false,
},
{
id: 2,
title: "حد و مشتق",
isAnswer: false,
},
{
id: 3,
title: "قدر مطلق",
isAnswer: false,
},
{
id: 4,
title: "نخوندم 🗿",
isAnswer: true,
},
],
},
{
questionId: 4,
courseId: 2,
title: "asdaw dsfsdfisdfsdfsfsdfsfsdfsdfermc",
answeredPercentage: "83%",
score: 1,
options: [
{
id: 1,
title: "asdasd",
isAnswer: false,
},
{
id: 2,
title: "asdasd2",
isAnswer: false,
},
{
id: 3,
title: "sdfsdfsdfsfd",
isAnswer: true,
},
{
id: 4,
title: "asdasd4",
isAnswer: false,
},
],
},
],
courses: [],
questions: [],
};
export const numOfinitQs = initialState.questionBank.length; export const numOfinitQs = initialState.questionBank.length;
export default function addExamReduser(state = initialState, { type, payload }) { export default function addExamReduser(
switch (type) { state = initialState,
{ type, payload }
case 'ADD_EXAM_GRADE_AND_GROUP': ) {
return { switch (type) {
...state, case "ADD_EXAM_GRADE_AND_GROUP":
grade: payload.grade, return {
groupId: payload.groupId ...state,
} grade: payload.grade,
groupId: payload.groupId,
case 'ADD_EXAM_DESCRIPTION': };
return {
...state, case "ADD_EXAM_DESCRIPTION":
name: payload.name, return {
startDate: new Date(), ...state,
endDate: new Date(), name: payload.name,
startTime: "19:0", startDate: new Date(),
endTime: "", endDate: new Date(),
description: payload.description, startTime: "19:0",
type: payload.type, endTime: "",
duration: payload.duration, description: payload.description,
startDate: payload.startDate, type: payload.type,
endDate: payload.endDate, duration: payload.duration,
budgetFileId: payload.budgetFileId, startDate: payload.startDate,
}; endDate: payload.endDate,
budgetFileId: payload.budgetFileId,
case 'ADD_EXAM_QUESTIONAIRES': };
return {
...state, case "ADD_EXAM_QUESTIONAIRES":
questionnaires: [...state.questionnaires, payload] return {
} ...state,
case 'ADD_QUESTIONNAIRE_COURSES': questionnaires: [...state.questionnaires, payload],
console.log(payload) };
let thisQ = state.questionnaires.find(itm => itm.id == payload.questionnaireId) case "ADD_QUESTIONNAIRE_COURSES":
let otherQ = state.questionnaires.filter(itm => itm.id !== payload.questionnaireId) console.log(payload);
thisQ = { let thisQ = state.questionnaires.find(
...thisQ, (itm) => itm.id == payload.questionnaireId
courses: [ ...thisQ.courses,payload] );
} let otherQ = state.questionnaires.filter(
console.log(thisQ) (itm) => itm.id !== payload.questionnaireId
return { );
...state, thisQ = {
questionnaires: [...otherQ, thisQ] ...thisQ,
} courses: [...thisQ.courses, payload],
case 'ADD_ANSWERS': };
console.log(payload) console.log(thisQ);
let thisQC = state.questionnaires.find(itm => itm.id == payload[0].questionnaierId) return {
let otherQC = state.questionnaires.filter(itm => itm.id !== payload[0].questionnaierId) ...state,
thisQC = { questionnaires: [...otherQ, thisQ],
...thisQC, };
answers: [ ...thisQC?.answers,...payload] case "ADD_ANSWERS":
} console.log(payload);
let thisQC = state.questionnaires.find(
return { (itm) => itm.id == payload[0].questionnaierId
...state, );
questionnaires: [...otherQC, thisQC] let otherQC = state.questionnaires.filter(
} (itm) => itm.id !== payload[0].questionnaierId
);
case 'ADD_EXAM_COURSE': thisQC = {
return { ...thisQC,
...state, answers: [...thisQC?.answers, ...payload],
courses: [...state.courses, { ...payload, selectedQuestions:[]}], };
};
case 'REMOVE_EXAM_COURSE': return {
return { ...state,
...state, questionnaires: [...otherQC, thisQC],
courses: state.courses.filter(itm => itm.id !== payload.id) };
}
case "ADD_EXAM_COURSE":
case 'ADD_EXAM_QUESTIONS': return {
console.log("??????????????"); ...state,
console.log(payload) courses: [...state.courses, { ...payload, selectedQuestions: [] }],
console.log(state.courses); };
const othercourses = state.courses.filter( case "REMOVE_EXAM_COURSE":
(itm) => itm.id !== payload.lessonId return {
); ...state,
const selectedC = state.courses.filter( courses: state.courses.filter((itm) => itm.id !== payload.id),
(itm) => itm.id == payload.lessonId };
);
selectedC[0] = { ...selectedC[0], selectedQuestions: [payload, ...selectedC[0].selectedQuestions] } case "ADD_EXAM_QUESTIONS":
const newCourses = [...othercourses, ...selectedC] console.log("??????????????");
console.log(payload);
return { console.log(state.courses);
...state, const othercourses = state.courses.filter(
courses: newCourses (itm) => itm.id !== payload.lessonId
);
} const selectedC = state.courses.filter(
(itm) => itm.id == payload.lessonId
);
case 'REMOVE_EXAM_QUESTIONS': selectedC[0] = {
const dontDeleteThese = state.courses.filter(itm => itm.id !== payload.courseId) ...selectedC[0],
const courseForDelete = state.courses.filter(itm => itm.id == payload.courseId) selectedQuestions: [payload, ...selectedC[0].selectedQuestions],
courseForDelete[0] = { ...courseForDelete[0], selectedQuestions: courseForDelete[0].selectedQuestions.filter(itm => itm.questionId !== payload.questionId) } };
const newCoursesWithDeleted = [...dontDeleteThese, ...courseForDelete] const newCourses = [...othercourses, ...selectedC];
console.log(newCoursesWithDeleted)
console.log(courseForDelete) return {
console.log(dontDeleteThese) ...state,
console.log(payload) courses: newCourses,
return { };
...state, case "ADD_EXAM_QUESTIONS2":
courses: newCoursesWithDeleted let newList = state.questions;
let isNew = true;
for(let i=0;i<newList.length;i++){
if(newList[i].examId===payload.examId){
newList[i].list = [...newList[i].list, payload.item];
isNew=false
} }
case 'REMOVE_QUESTION_FROM_BANK': }
return { if(isNew){
...state, newList.push({
questionBank: state.questionBank.filter(itm => itm.questionId !== payload.questionId) examId: payload.examId,
} list: [payload.item],
case 'GET_QUESTION_BACK_TO_BANK': });
return { }
...state, return {
questionBank: [payload, ...state.questionBank,] ...state,
} questions: newList,
};
case 'CHANGE_QUESTION_ORDER':
const dontChangeThese = state.courses.filter(itm => itm.id !== payload[0].courseId) case "REMOVE_EXAM_QUESTIONS":
const courseForChange = state.courses.filter(itm => itm.id == payload[0].courseId) const dontDeleteThese = state.courses.filter(
courseForChange[0] = { ...courseForChange[0], selectedQuestions: payload } (itm) => itm.id !== payload.courseId
const newChangedCourseSort = [...dontChangeThese, ...courseForChange] );
console.log(payload) const courseForDelete = state.courses.filter(
return { (itm) => itm.id == payload.courseId
...state, );
courses: newChangedCourseSort courseForDelete[0] = {
} ...courseForDelete[0],
case 'CHANGE_COURSE_ORDER': selectedQuestions: courseForDelete[0].selectedQuestions.filter(
console.log(payload) (itm) => itm.questionId !== payload.questionId
return { ),
...state, };
courses: payload const newCoursesWithDeleted = [...dontDeleteThese, ...courseForDelete];
} console.log(newCoursesWithDeleted);
case 'ADD_CUSTOM_QUESTION': console.log(courseForDelete);
const otherCourses = state.courses.filter(itm => itm.id !== payload.courseId) console.log(dontDeleteThese);
const selectedc = state.courses.filter(itm => itm.id == payload.courseId) console.log(payload);
selectedc[0] = { ...selectedc[0], selectedQuestions: [payload, ...selectedc[0].selectedQuestions] } return {
const newcourses = [...selectedc, ...otherCourses] ...state,
return { courses: newCoursesWithDeleted,
...state, };
courses: newcourses case "REMOVE_QUESTION_FROM_BANK":
return {
} ...state,
case 'CHANGE_COURSE_NUM_OF_OPTIONS': questionBank: state.questionBank.filter(
const otherCourseS = state.courses.filter(itm => itm.id !== payload.courseId) (itm) => itm.questionId !== payload.questionId
const seLectedC = state.courses.filter(itm => itm.id == payload.courseId) ),
seLectedC[0] = { ...seLectedC[0], numberOfOptions: payload.value } };
const neWCourses = [...seLectedC, ...otherCourseS] case "GET_QUESTION_BACK_TO_BANK":
return { return {
...state, ...state,
courses: neWCourses questionBank: [payload, ...state.questionBank],
};
}
case "CHANGE_QUESTION_ORDER":
case 'CHANGE_QUESTIONNAIRES_ORDER': const dontChangeThese = state.courses.filter(
return { (itm) => itm.id !== payload[0].courseId
...state, );
questionnaires: payload const courseForChange = state.courses.filter(
(itm) => itm.id == payload[0].courseId
} );
courseForChange[0] = {
default: ...courseForChange[0],
return state; selectedQuestions: payload,
};
} const newChangedCourseSort = [...dontChangeThese, ...courseForChange];
console.log(payload);
} return {
...state,
courses: newChangedCourseSort,
};
case "CHANGE_COURSE_ORDER":
console.log(payload);
return {
...state,
courses: payload,
};
case "ADD_CUSTOM_QUESTION":
const otherCourses = state.courses.filter(
(itm) => itm.id !== payload.courseId
);
const selectedc = state.courses.filter(
(itm) => itm.id == payload.courseId
);
selectedc[0] = {
...selectedc[0],
selectedQuestions: [payload, ...selectedc[0].selectedQuestions],
};
const newcourses = [...selectedc, ...otherCourses];
return {
...state,
courses: newcourses,
};
case "CHANGE_COURSE_NUM_OF_OPTIONS":
const otherCourseS = state.courses.filter(
(itm) => itm.id !== payload.courseId
);
const seLectedC = state.courses.filter(
(itm) => itm.id == payload.courseId
);
seLectedC[0] = { ...seLectedC[0], numberOfOptions: payload.value };
const neWCourses = [...seLectedC, ...otherCourseS];
return {
...state,
courses: neWCourses,
};
case "CHANGE_QUESTIONNAIRES_ORDER":
return {
...state,
questionnaires: payload,
};
default:
return state;
}
}

@ -7,8 +7,9 @@ const initialState = {
error: null, error: null,
info: null, info: null,
lastExamAdd: null, lastExamAdd: null,
preview : null, preview: null,
subExamList:[], subExamList: [],
confirm:null
}; };
export default function exam2(state = initialState, action) { export default function exam2(state = initialState, action) {
let { type, data } = action; let { type, data } = action;
@ -17,6 +18,9 @@ export default function exam2(state = initialState, action) {
return { ...state, loading: false, info: data, error: null }; return { ...state, loading: false, info: data, error: null };
case "exam/preview": case "exam/preview":
return { ...state, loading: false, preview: data, error: null }; return { ...state, loading: false, preview: data, error: null };
case "exam/confirm":
toast.success("درخواست با موفقیت انجام شد");
return { ...state, loading: false, confirm: data, error: null };
case "exam/parentAdd": case "exam/parentAdd":
toast.success("آزمون شما با موفقیت ثبت شد"); toast.success("آزمون شما با موفقیت ثبت شد");
return { ...state, loading: false, error: null, lastExamAdd: data.id }; return { ...state, loading: false, error: null, lastExamAdd: data.id };

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

@ -18,4 +18,6 @@ export { default as examGroup } from "./examGroup";
export { default as lesson } from "./lesson"; export { default as lesson } from "./lesson";
export { default as question } from "./question"; export { default as question } from "./question";
export { default as category } from "./category"; export { default as category } from "./category";
export { default as examQuestion } from "./examQuestion";

@ -1,89 +1,153 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import attachIcon from '../../../assets/img/attach-circle.svg'; import { connect } from "react-redux";
const AddQuestionPopUp = ({ titlePass, scorePass, submitOnClick, cancelOnClick, passOptionTitle, setAsAnswer, options }) => { import attachIcon from "../../../assets/img/attach-circle.svg";
import { question } from "../../../redux/actions";
const AddQuestionPopUp = ({
const gozine = [ titlePass,
'الف', scorePass,
'ب', submitOnClick,
'ج', cancelOnClick,
'د', passOptionTitle,
'ه', setAsAnswer,
'ز', options,
] submitQuestion,
}) => {
const gozine = ["الف", "ب", "ج", "د", "ه", "ز"];
return ( return (
<div className="w-full z-10 fixed bg-black bg-opacity-20 h-screen backdrop-blur flex flex-col items-center top-0 left-0 justify-center"> <div className="w-full z-10 fixed bg-black bg-opacity-20 h-screen backdrop-blur flex flex-col items-center top-0 left-0 justify-center">
<div className="w-1/2 flex flex-col items-center bg-white p-6 py-10 rounded-xl shadow-lg"> <div className="w-1/2 flex flex-col items-center bg-white p-6 py-10 rounded-xl shadow-lg">
<div className="w-full"> <div className="w-full">
<div className="w-8 h-8 text-white text-sm rounded-full cursor-pointer flex justify-center items-center bg-red52" onClick={cancelOnClick}> <div
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 15.044 15.044"> className="w-8 h-8 text-white text-sm rounded-full cursor-pointer flex justify-center items-center bg-red52"
<g id="vuesax_linear_card-remove" data-name="vuesax/linear/card-remove" transform="translate(-252.46 -511.461)"> onClick={cancelOnClick}
<g id="card-remove" transform="translate(253.309 512.31)"> >
<path id="Vector" d="M0,13.347,13.347,0" fill="none" stroke="#fff" strokeLinecap="round" strokeWidth="2" /> <svg
<path id="Vector-2" data-name="Vector" d="M13.347,13.347,0,0" fill="none" stroke="#fff" strokeLinecap="round" strokeWidth="2" /> xmlns="http://www.w3.org/2000/svg"
</g> width="12"
</g> height="12"
</svg> viewBox="0 0 15.044 15.044"
</div> >
</div> <g
<div className='w-4/5 flex flex-col text-blue3A mt-4 mb-2 font-bold justify-between items-center'> id="vuesax_linear_card-remove"
<div className='w-11/12 flex flex-col bg-white rounded-xl border border-gray-300 shadow-sm'> data-name="vuesax/linear/card-remove"
<textarea className='w-full border-b border-gray-300 rounded-t-xl p-4 text-blue3A overflow-hideen text-right outline-none' placeholder="صورت سوال..." rows={1} transform="translate(-252.46 -511.461)"
onChange={(e) => titlePass(e.target.value)} >
<g id="card-remove" transform="translate(253.309 512.31)">
<path
id="Vector"
d="M0,13.347,13.347,0"
fill="none"
stroke="#fff"
strokeLinecap="round"
strokeWidth="2"
/>
<path
id="Vector-2"
data-name="Vector"
d="M13.347,13.347,0,0"
fill="none"
stroke="#fff"
strokeLinecap="round"
strokeWidth="2"
/>
</g>
</g>
</svg>
</div>
</div>
<div className="w-4/5 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 shadow-sm">
<textarea
className="w-full border-b border-gray-300 rounded-t-xl p-4 text-blue3A overflow-hideen text-right outline-none"
placeholder="صورت سوال..."
rows={1}
onChange={(e) => titlePass(e.target.value)}
/> />
<div className='w-full p-3 px-4 h-12 flex justify-between items-center'> <div className="w-full p-3 px-4 h-12 flex justify-between items-center">
<div> <div>
<p className='text-xs'>نمره : <p className="text-xs">
<input type='number' className="w-6 h-6 border border-gray-200 mr-1 rounded" نمره :
<input
type="number"
className="w-6 h-6 border border-gray-200 mr-1 rounded"
onChange={(e) => scorePass(e.target.value)} onChange={(e) => scorePass(e.target.value)}
/> />
</p> </p>
</div> </div>
<input type='file' className="hidden" id="Add_Question_Add_Image" /> <input
<label htmlFor="Add_Question_Add_Image" className="flex items-center"> type="file"
<p className="text-gray-500 ml-1">آپلود</p> className="hidden"
<img src={attachIcon} className="h-full w-10" /> id="Add_Question_Add_Image"
</label> />
<label
htmlFor="Add_Question_Add_Image"
className="flex items-center"
>
<p className="text-gray-500 ml-1">آپلود</p>
<img src={attachIcon} className="h-full w-10" />
</label>
</div> </div>
</div>
<div className="w-11/12 justify-between mt-4 flex flex-wrap">
{options?.map((item) => (
<div
className="my-2 flex items-center justify-center shadow-sm"
style={{ width: "calc(50% - 10px)" }}
onClick={() => setAsAnswer(item.id)}
>
<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>
<input
className={` h-12 outline-none flex items-center justify-center p-2 w-full rounded-lg rounded-r-none ${
item.isAnswer
? "bg-green-200"
: "bg-white border border-gray-300"
}`}
onChange={(e) => passOptionTitle(e.target.value, item.id)}
placeholder={`گزینه ${item.id}`}
/>
</div>
))}
</div>
<div className="w-11/12 flex justify-end">
<div className="w-1/3 mt-5 flex justify-between items-center">
<button
className=" bg-white text-xl text-red-500 border-red-500 w-full h-12 mx-1 rounded-md border"
onClick={cancelOnClick}
>
انصراف
</button>
<button
className=" bg-green-500 text-xl text-white border-green-500 w-full ml-0 mx-3 h-12 rounded-md border"
onClick={submitOnClick}
>
ثبت سوال
</button>
</div>
</div>
</div> </div>
<div className='w-11/12 justify-between mt-4 flex flex-wrap'> </div>
{
options?.map(
(item) => (
<div className='my-2 flex items-center justify-center shadow-sm' style={{width: 'calc(50% - 10px)'}} onClick={() => setAsAnswer(item.id) }>
<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>
<input className={` h-12 outline-none flex items-center justify-center p-2 w-full rounded-lg rounded-r-none ${item.isAnswer ? 'bg-green-200' : 'bg-white border border-gray-300'}`}
onChange={e => passOptionTitle(e.target.value, item.id)}
placeholder={`گزینه ${item.id}`}/>
</div>
)
)
}
</div>
<div className="w-11/12 flex justify-end">
<div className="w-1/3 mt-5 flex justify-between items-center">
<button className=" bg-white text-xl text-red-500 border-red-500 w-full h-12 mx-1 rounded-md border" onClick={cancelOnClick
}>
انصراف
</button>
<button className=" bg-green-500 text-xl text-white border-green-500 w-full ml-0 mx-3 h-12 rounded-md border" onClick={
submitOnClick
}>
ثبت سوال
</button>
</div>
</div>
</div> </div>
</div> );
</div> };
)
} const mapStateToProps = (state) => ({
});
const mapDispatchToProps = {
submitQuestion:question.add
};
export default AddQuestionPopUp; export default connect(mapStateToProps, mapDispatchToProps)(AddQuestionPopUp);

@ -3,41 +3,35 @@ import React, { useEffect } from 'react';
let optionsList = []; let optionsList = [];
const Question = ({data}) => { const Question = ({ data, mode }) => {
// useEffect(()=>{ // useEffect(()=>{
// }) // })
optionsList = []; optionsList = [];
for (let i = 0; i < data.type; i++) { for (let i = 0; i < data.type; i++) {
optionsList.push(data[`option${i + 1}`]); optionsList.push(data[`option${i + 1}`]);
} }
// console.log("==|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") // console.log("==|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
// console.log(optionsList); // console.log(optionsList);
const gozine = [ const gozine = ["الف", "ب", "ج", "د", "ه", "ز"];
'الف', 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">
'ه', {mode === 2 ? data?.title : data?.text}
'ز', </div>
] <div className="w-full p-3 px-4 flex justify-between items-center">
return ( <div>
<div className="w-full flex flex-col text-blue3A mt-4 mb-2 font-bold justify-between items-center"> <p className="text-xs">نمره : {data.score}</p>
<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>
<div className="w-full p-3 px-4 flex justify-between items-center"> <div className="text-gray-500 text-sm">
<div> درصد پاسخگویی: {data.answerPercent}
<p className="text-xs">نمره : {data.score}</p>
</div>
<div className="text-gray-500 text-sm">
درصد پاسخگویی: {data.answerPercent}
</div>
</div> </div>
</div> </div>
<div className="w-full justify-center mt-4 flex flex-wrap"> </div>
{optionsList?.map((item,index) => ( <div className="w-full justify-center mt-4 flex flex-wrap">
{mode !== 2 &&
optionsList?.map((item, index) => (
<div className="w-2/5 mx-2 my-2 flex items-center justify-center"> <div className="w-2/5 mx-2 my-2 flex items-center justify-center">
<p <p
className={` h-12 flex items-center justify-center w-16 rounded-lg rounded-l-none ${ className={` h-12 flex items-center justify-center w-16 rounded-lg rounded-l-none ${
@ -59,11 +53,32 @@ const Question = ({data}) => {
</p> </p>
</div> </div>
))} ))}
</div> {mode === 2 &&
data?.options?.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?.title}
</p>
</div>
))}
</div> </div>
); </div>
);
};
}
export default Question; export default Question;

@ -11,12 +11,14 @@ import filterIcon from "../../../assets/img/filter.svg";
import Question from "../components/question"; import Question from "../components/question";
import { numOfinitQs } from "../../../redux/reducers/exam"; import { numOfinitQs } from "../../../redux/reducers/exam";
import AddQuestionPopUp from "../components/addQuestion"; import AddQuestionPopUp from "../components/addQuestion";
import { category, exam, lesson, question } from "../../../redux/actions"; import { category, exam, examQuestion, lesson, question } from "../../../redux/actions";
import { AiOutlineCloseCircle } from "react-icons/ai"; import { AiOutlineCloseCircle } from "react-icons/ai";
import loadingGiff from "../../../assets/img/Rolling-2s-223px.gif"; import loadingGiff from "../../../assets/img/Rolling-2s-223px.gif";
import { BsCheck2All } from "react-icons/bs"; import { BsCheck2All } from "react-icons/bs";
let seCounter = 0; let seCounter = 0;
let eqCounter = 0;
let eqCounter2 = 0;
const AddQuestionsFromBank = ({ const AddQuestionsFromBank = ({
grades, grades,
addExamState, addExamState,
@ -41,7 +43,17 @@ const AddQuestionsFromBank = ({
subExamList, subExamList,
subExamLoading, subExamLoading,
emptySubexamList, emptySubexamList,
addQuestion,
addExamQuestion2,
submitQuestion,
lastNewQustionAdd,
lastExamQuestion,
examSubmitLoading,
addCustomQuestion,
}) => { }) => {
console.log("--------------------------");
console.log(addExamState?.questions);
console.log(addExamState?.courses);
const [name, setName] = useState(null); const [name, setName] = useState(null);
const [type, setType] = useState(null); const [type, setType] = useState(null);
const [description, setDescription] = useState(null); const [description, setDescription] = useState(null);
@ -62,15 +74,16 @@ const AddQuestionsFromBank = ({
}); });
const [subexamAddPermission, setSubexamAddPermission] = useState(0); const [subexamAddPermission, setSubexamAddPermission] = useState(0);
const [subexamAddPart, setSubexamAddPart] = useState(false); const [subexamAddPart, setSubexamAddPart] = useState(false);
const [SelectedCourseIndex, setSelectedCourseIndex] = useState(null);
// console.log(choosedQuestionaries) // console.log(choosedQuestionaries)
// console.log(newQuestionaire) // console.log(newQuestionaire)
// console.log(addExamState.questionnaires) // console.log(addExamState.questionnaires)
// console.log(newCourse) // console.log(newCourse)
// console.log(addExamState.questionairesCourses) // console.log(addExamState.questionairesCourses)
console.log(selectedCourse); // console.log(selectedCourse);
// console.log(answers) // console.log(answers)
console.log(choosedQuestion); // console.log(choosedQuestion);
console.log(selectedCourse.selectedQuestions); // console.log(selectedCourse.selectedQuestions);
// useEffect(()=>{ // useEffect(()=>{
// emptySubexamList(); // emptySubexamList();
@ -86,7 +99,17 @@ const AddQuestionsFromBank = ({
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 });
console.log(":u:");
console.log(choosedQuestion);
addExamQuestion(choosedQuestion); addExamQuestion(choosedQuestion);
addExamQuestion2({
examId: subExamList[SelectedCourseIndex],
item: { id: choosedQuestion.id, coefficient: 1 },
});
// addQuestion({
// examId: subExamList[SelectedCourseIndex],
// questions: choosedQuestion.id,
// });
// dispatch({ // dispatch({
// type: "REMOVE_QUESTION_FROM_BANK", // type: "REMOVE_QUESTION_FROM_BANK",
// payload: choosedQuestion, // payload: choosedQuestion,
@ -119,10 +142,10 @@ const AddQuestionsFromBank = ({
aaa.splice(destination.index, 0, removed); aaa.splice(destination.index, 0, removed);
dispatch({ type: "CHANGE_QUESTION_ORDER", payload: aaa }); dispatch({ type: "CHANGE_QUESTION_ORDER", payload: aaa });
console.log(result); // console.log(result);
console.log(source.index); // console.log(source.index);
console.log(destination.index); // console.log(destination.index);
console.log(aaa); // console.log(aaa);
} }
} }
}; };
@ -135,10 +158,10 @@ const AddQuestionsFromBank = ({
useEffect(() => { useEffect(() => {
if (activeCourse) { if (activeCourse) {
getQuestion({ getQuestion({
// lessonId: activeCourse, lessonId: activeCourse,
// gradeId: addExamState.grade, gradeId: addExamState.grade,
lessonId: 3, // lessonId: 3,
gradeId: 7, // gradeId: 7,
}); });
} }
}, [activeCourse]); }, [activeCourse]);
@ -170,11 +193,11 @@ const AddQuestionsFromBank = ({
}); });
}, [numberOfOptions]); }, [numberOfOptions]);
console.log(question); // console.log(question);
console.log( // console.log(
addExamState.courses.filter((itm) => itm.id == selectedCourse.id)[0] // addExamState.courses.filter((itm) => itm.id == selectedCourse.id)[0]
?.selectedQuestions // ?.selectedQuestions
); // );
const addLessonHandler = () => { const addLessonHandler = () => {
setAddLessonPart(true); setAddLessonPart(true);
@ -187,8 +210,8 @@ const AddQuestionsFromBank = ({
}; };
const submitLessons = () => { const submitLessons = () => {
console.log("aaaaaaaaaaaaaaaa"); // console.log("aaaaaaaaaaaaaaaa");
console.log(addExamState?.courses); // console.log(addExamState?.courses);
for (let i = 0; i < addExamState?.courses?.length; i++) { for (let i = 0; i < addExamState?.courses?.length; i++) {
addCategory({ addCategory({
title: addExamState?.courses[i].name, title: addExamState?.courses[i].name,
@ -201,10 +224,24 @@ const AddQuestionsFromBank = ({
setSubexamAddPart(true); setSubexamAddPart(true);
}; };
//
const addNewQustionhandler = () => {
setFakeState(fakeState + 5);
// setNumberOfOptions(selectedCourse.numberOfOptions);
setAddQuestionPopuo("component");
let lessonId = addExamState.courses[SelectedCourseIndex].id;
for (let i = 0; i < questionTypeList.length; i++) {
if (questionTypeList[i].lessonId === lessonId) {
setNumberOfOptions(questionTypeList[i].questionType);
}
}
};
// subexamAdd---------------------------------- // subexamAdd----------------------------------
const [questionTypeList, setQuestionTypeList] = useState([]);
const subexamAddHandler = (index) => { const subexamAddHandler = (index) => {
let inputs = document.querySelectorAll(`.subexamAddPart-input-${index}`); let inputs = document.querySelectorAll(`.subexamAddPart-input-${index}`);
console.log(inputs[2].checked); // console.log(inputs[2].checked);
seCounter = index; seCounter = index;
addSubexam({ addSubexam({
pid: examId, pid: examId,
@ -217,15 +254,48 @@ const AddQuestionsFromBank = ({
negativePoint: inputs[2].checked, negativePoint: inputs[2].checked,
ord: Number(inputs[4].value), ord: Number(inputs[4].value),
}); });
setQuestionTypeList([
...questionTypeList,
{
questionType: Number(inputs[1].value),
lessonId: addExamState.courses[index].id,
},
]);
}; };
const subexamPartFinalSubmit=()=>{ const subexamPartFinalSubmit = () => {
setSubexamAddPart(false); setSubexamAddPart(false);
} };
const nextStephandler = () => { const nextStephandler = () => {
// submitHandler(); // submitHandler();
stepClick(); for (let i = 0; i < addExamState.questions.length; i++) {
addQuestion({
examId: addExamState.questions[i].examId,
questions: addExamState.questions[i].list,
});
eqCounter++;
}
// stepClick();
}; };
useEffect(() => {
if (lastExamQuestion !== null) {
eqCounter2++;
if (eqCounter2 === eqCounter) {
stepClick();
}
}
}, [lastExamQuestion]);
//addNewQuestionToQuestionState-----------------------------------------
useEffect(() => {
if (lastNewQustionAdd) {
addExamQuestion2({
examId: subExamList[SelectedCourseIndex],
item: { id: lastNewQustionAdd, coefficient: 1 },
});
}
}, [lastNewQustionAdd]);
return ( return (
<div className="flex flex-col h-screen relative"> <div className="flex flex-col h-screen relative">
{questionarePopUp && ( {questionarePopUp && (
@ -424,7 +494,11 @@ const AddQuestionsFromBank = ({
<div <div
className="w-40 h-14 flex items-center justify-center rounded-lg bg-red52 text-white mt-10 mx-auto cursor-pointer" className="w-40 h-14 flex items-center justify-center rounded-lg bg-red52 text-white mt-10 mx-auto cursor-pointer"
onClick={subexamPartFinalSubmit} onClick={subexamPartFinalSubmit}
style={subExamList?.length!==addExamState.courses?.length ? {filter:"grayscale(100%)",pointerEvents:'none'}:null} style={
subExamList?.length !== addExamState.courses?.length
? { filter: "grayscale(100%)", pointerEvents: "none" }
: null
}
> >
ثبت نهایی ثبت نهایی
</div> </div>
@ -458,10 +532,10 @@ const AddQuestionsFromBank = ({
aaa.splice(destination.index, 0, removed); aaa.splice(destination.index, 0, removed);
dispatch({ type: "CHANGE_COURSE_ORDER", payload: aaa }); dispatch({ type: "CHANGE_COURSE_ORDER", payload: aaa });
console.log(result); // console.log(result);
console.log(source.index); // console.log(source.index);
console.log(destination.index); // console.log(destination.index);
console.log(aaa); // console.log(aaa);
} }
}} }}
> >
@ -480,7 +554,7 @@ const AddQuestionsFromBank = ({
{addExamState?.courses?.length > 0 && {addExamState?.courses?.length > 0 &&
addExamState.courses.map((item, index) => ( addExamState.courses.map((item, index) => (
<> <>
{console.log(item)} {/* {console.log(item)} */}
<Draggable <Draggable
draggableId={`COURSE_${item.id}`} draggableId={`COURSE_${item.id}`}
index={index} index={index}
@ -499,6 +573,7 @@ const AddQuestionsFromBank = ({
onClick={() => { onClick={() => {
setSelectedCourse(item); setSelectedCourse(item);
setActiveCourse(item.id); setActiveCourse(item.id);
setSelectedCourseIndex(index);
}} }}
> >
<div <div
@ -568,7 +643,7 @@ const AddQuestionsFromBank = ({
<DragDropContext <DragDropContext
onDragEnd={(result) => handleOnDragEnd(result)} onDragEnd={(result) => handleOnDragEnd(result)}
onDragStart={(result) => { onDragStart={(result) => {
console.log(result); // console.log(result);
if (result.source.droppableId == "Choosed_Questions_Form_Bank") { if (result.source.droppableId == "Choosed_Questions_Form_Bank") {
seChoosedQuestion( seChoosedQuestion(
addExamState.courses.filter( addExamState.courses.filter(
@ -576,8 +651,8 @@ const AddQuestionsFromBank = ({
)[0]?.selectedQuestions[result.source.index] )[0]?.selectedQuestions[result.source.index]
); );
} else { } else {
console.log("MMMMMMMMMMMMMMMMMMMM"); // console.log("MMMMMMMMMMMMMMMMMMMM");
console.log(result); // console.log(result);
seChoosedQuestion( seChoosedQuestion(
questionList?.find((itm) => itm.id == result.source.index) questionList?.find((itm) => itm.id == result.source.index)
); );
@ -642,7 +717,7 @@ const AddQuestionsFromBank = ({
<div <div
className="flex flex-col items-center overflow-x-hidden overflow-scroll" className="flex flex-col items-center overflow-x-hidden overflow-scroll"
style={{ height: "30vh" }} style={{ height: "40vh" }}
> >
<div className="w-11/12 "> <div className="w-11/12 ">
{addQuestionPopup === "component" && ( {addQuestionPopup === "component" && (
@ -702,11 +777,51 @@ const AddQuestionsFromBank = ({
}} }}
submitOnClick={() => { submitOnClick={() => {
setAddQuestionPopuo(false); setAddQuestionPopuo(false);
console.log(">y<");
dispatch({ console.log(question);
type: "ADD_CUSTOM_QUESTION", addCustomQuestion(question);
payload: question, // dispatch({
// type: "ADD_CUSTOM_QUESTION",
// payload: question,
// });
let answer = null;
for (
let i = 0;
i < question.options.length;
i++
) {
if (question.options[i].isAnswer) {
answer = question.options[i].title;
}
}
submitQuestion({
text: question.title,
type: numberOfOptions,
answer,
categoryId:
categoryAddList[SelectedCourseIndex],
option1:
question.options.length > 0
? question.options[0]?.title
: null,
option2:
question.options.length > 1
? question.options[1]?.title
: null,
option3:
question.options.length > 2
? question.options[2]?.title
: null,
option4:
question.options.length > 3
? question.options[3]?.title
: null,
option5:
question.options.length > 4
? question.options[4]?.title
: null,
}); });
setNumberOfOptions(null); setNumberOfOptions(null);
}} }}
cancelOnClick={() => setAddQuestionPopuo(false)} cancelOnClick={() => setAddQuestionPopuo(false)}
@ -758,7 +873,7 @@ const AddQuestionsFromBank = ({
/> />
</svg> </svg>
</div> </div>
<Question data={item} /> <Question data={item} mode={2} />
</div> </div>
)} )}
</Draggable> </Draggable>
@ -787,13 +902,7 @@ const AddQuestionsFromBank = ({
</label> </label>
<button <button
className=" w-2/3 mr-1 bg-transparent text-xl text-blue3A border-gray-300 h-12 rounded-xl border mb-6" className=" w-2/3 mr-1 bg-transparent text-xl text-blue3A border-gray-300 h-12 rounded-xl border mb-6"
onClick={() => { onClick={addNewQustionhandler}
setFakeState(fakeState + 5);
setNumberOfOptions(
selectedCourse.numberOfOptions
);
setAddQuestionPopuo("component");
}}
> >
اضافه کردن سوال جدید + اضافه کردن سوال جدید +
</button> </button>
@ -928,11 +1037,18 @@ const AddQuestionsFromBank = ({
{" "} {" "}
بازگشت به مرحله قبل{" "} بازگشت به مرحله قبل{" "}
</button> </button>
<Button {!examSubmitLoading && (
title="مرحله بعدی" <Button
className="w-1/12" title="مرحله بعدی"
onClick={nextStephandler} className="w-1/12"
/> onClick={nextStephandler}
/>
)}
{examSubmitLoading && (
<div className="w-1/12 h-12 rounded-lg bg-red52 flex items-center justify-center">
<img src={loadingGiff} alt="loadingGiff" className="h-9" />
</div>
)}
</div> </div>
</div> </div>
); );
@ -947,6 +1063,9 @@ const mapStateToProps = (state) => ({
examId: state.exam2.lastExamAdd, examId: state.exam2.lastExamAdd,
subExamList: state.exam2.subExamList, subExamList: state.exam2.subExamList,
subExamLoading: state.exam2.loading, subExamLoading: state.exam2.loading,
lastNewQustionAdd: state.question.lastAdd,
lastExamQuestion: state.examQuestion.lastAdd,
examSubmitLoading: state.examQuestion.loading
// lessonList: state.lesson.list // lessonList: state.lesson.list
}); });
@ -956,13 +1075,17 @@ const mapDispatchToProps = {
removeExamCourse: exam.removeExamCourse, removeExamCourse: exam.removeExamCourse,
getQuestion: question.list, getQuestion: question.list,
addExamQuestion: exam.addExamQuestion, addExamQuestion: exam.addExamQuestion,
addExamQuestion2: exam.addExamQuestion2,
removeQuestionFromBank: exam.removeQuestionFromBank, removeQuestionFromBank: exam.removeQuestionFromBank,
removeExamQuestions: exam.removeExamQuestions, removeExamQuestions: exam.removeExamQuestions,
getQuestionBackToBank: exam.getQuestionBackToBank, getQuestionBackToBank: exam.getQuestionBackToBank,
changeQuestionOrder: exam.changeQuestionOrder, changeQuestionOrder: exam.changeQuestionOrder,
addCategory: category.add, addCategory: category.add,
addSubexam: exam.subexamAdd, addSubexam: exam.subexamAdd,
emptySubexamList : exam.emptySubexamList emptySubexamList: exam.emptySubexamList,
addQuestion: examQuestion.add,
submitQuestion: question.add,
addCustomQuestion : exam.addCustomQuestion
}; };
export default connect( export default connect(

@ -21,6 +21,7 @@ const ViewExam = ({
examPreview, examPreview,
examId, examId,
getExamPreview, getExamPreview,
examConfirm,
}) => { }) => {
useEffect(() => { useEffect(() => {
window.scrollTo(0, 0); window.scrollTo(0, 0);
@ -71,7 +72,8 @@ const ViewExam = ({
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>"); console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>");
console.log(addExamState.startDate.month); console.log(addExamState.startDate.month);
const submitHandler = () => { const submitHandler = () => {
// stepClick(); examConfirm({id:examId});
stepClick();
}; };
const createOptions = (item) => { const createOptions = (item) => {
@ -117,7 +119,10 @@ const ViewExam = ({
</div> </div>
<div className="w-full mt-4"> <div className="w-full mt-4">
{createOptions(item).map((choice, index2) => ( {createOptions(item).map((choice, index2) => (
<div key={index2} className="w-full flex items-stretch mb-2"> <div
key={index2}
className="w-full flex items-stretch mb-2"
>
<div <div
className="w-12 py-3 rounded-r-md flex items-center justify-center bg-gray-300" className="w-12 py-3 rounded-r-md flex items-center justify-center bg-gray-300"
style={ style={
@ -178,7 +183,8 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = { const mapDispatchToProps = {
parentAdd: exam.parentAdd, parentAdd: exam.parentAdd,
getExamPreview : exam.preview getExamPreview: exam.preview,
examConfirm : exam.confirm
}; };
export default connect(mapStateToProps, mapDispatchToProps)(ViewExam); export default connect(mapStateToProps, mapDispatchToProps)(ViewExam);

@ -68,6 +68,14 @@ const AddQuestionnaireExam = ({
} }
}, [answers]); }, [answers]);
const [noteFile,setNoteFile]=useState(null);
const noteChooseFile=()=>{
let input = document.querySelector("#add-note-input-file");
input.click();
setNoteFile(input);
setFakeState(fakeState + 15);
}
return ( return (
<> <>
{questionarePopUp && ( {questionarePopUp && (
@ -120,7 +128,7 @@ const AddQuestionnaireExam = ({
<input <input
type="text" type="text"
placeholder="نام دفترچه..." placeholder="نام دفترچه..."
className="w-4/5 p-4 ml-2 rounded border border-red52 h-12 text-red26 outline-none" className="w-3/6 p-4 ml-2 rounded border border-red52 h-12 text-red26 outline-none"
onChange={(e) => onChange={(e) =>
setNewQuestionaire({ setNewQuestionaire({
...newQuestionaire, ...newQuestionaire,
@ -128,10 +136,23 @@ const AddQuestionnaireExam = ({
}) })
} }
/> />
<div
className="w-[15%] h-12 flex items-center justify-center text-sm rounded bg-red52 text-white cursor-pointer"
onClick={noteChooseFile}
>
انتخاب فایل
</div>
<div className="w-[20%] h-12 rounded border border-red53 flex items-center ltr text-xs px-2 overflow-hidden text-left text-ellipsis whitespace-normal">
{noteFile!==null ? noteFile?.value : "فایلی اضافه نشده"}
</div>
<div className="w-[10%] h-12 flex items-center justify-center text-sm rounded bg-[#111] text-white cursor-pointer">
آپلود
</div>
<input <input
type="file" type="file"
placeholder="آپلود فایل دفترچه" placeholder="آپلود فایل دفترچه"
className="bg-white items-center flex h-12 text-red26 outline-none" className="bg-white items-center flex h-12 text-red26 outline-none hidden"
id="add-note-input-file"
/> />
</div> </div>
<div className="flex w-full justify-end pt-2"> <div className="flex w-full justify-end pt-2">
@ -239,6 +260,7 @@ const AddQuestionnaireExam = ({
}} }}
/> />
)} )}
{/* ==============================top-part============================= */}
<div className="flex py-10 items-start px-10 border-b border-gray-300"> <div className="flex py-10 items-start px-10 border-b border-gray-300">
<div className="flex flex-col w-1/6"> <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"> <div className="text-blue3A text-lg font-bold text-right px-4 border-r-4 border-blue65">
@ -253,16 +275,8 @@ const AddQuestionnaireExam = ({
onDragEnd={(result) => { onDragEnd={(result) => {
const { source, destination } = result; const { source, destination } = result;
if (source.droppableId == "Choosed_Questionnaires") { if (source.droppableId == "Choosed_Questionnaires") {
// const data = {
// startIndex: choosedQuestion,
// endIndex: destination.index
// }
// dispatch({type:'CHANGE_QUESTION_ORDER', payload : data})
// console.log(data)
const aaa = [...addExamState.questionnaires]; const aaa = [...addExamState.questionnaires];
const [removed] = aaa.splice(source.index, 1); const [removed] = aaa.splice(source.index, 1);
aaa.splice(destination.index, 0, removed); aaa.splice(destination.index, 0, removed);
dispatch({ type: "CHANGE_QUESTIONNAIRES_ORDER", payload: aaa }); dispatch({ type: "CHANGE_QUESTIONNAIRES_ORDER", payload: aaa });
console.log(result); console.log(result);
@ -339,7 +353,7 @@ const AddQuestionnaireExam = ({
</div> </div>
</div> </div>
</div> </div>
{/* ====================================================================== */}
<div className="w-full flex px-10"> <div className="w-full flex px-10">
<div className="w-1/2 border-l flex flex-col border-gray-300 py-10"> <div className="w-1/2 border-l flex flex-col border-gray-300 py-10">
{selectedQuestionare.id !== null && ( {selectedQuestionare.id !== null && (
@ -354,7 +368,7 @@ const AddQuestionnaireExam = ({
<div className="w-4/5 "> <div className="w-4/5 ">
{addExamState.questionnaires {addExamState.questionnaires
.find((itm) => itm.id == selectedQuestionare.id) .find((itm) => itm.id == selectedQuestionare.id)
?.courses.map((item,index) => ( ?.courses.map((item, index) => (
<React.Fragment key={index}> <React.Fragment key={index}>
<SelectedCourse <SelectedCourse
title={item.name} title={item.name}
@ -425,5 +439,3 @@ const mapStateToProps = (state) => ({
}); });
export default connect(mapStateToProps)(AddQuestionnaireExam); export default connect(mapStateToProps)(AddQuestionnaireExam);

Loading…
Cancel
Save