parent
a6478f5679
commit
093924033b
12 changed files with 876 additions and 537 deletions
@ -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; |
@ -1,363 +1,402 @@ |
||||
import { IoReturnUpBack } from "react-icons/io5" |
||||
import fizikpdf from '../../assets/fizik.pdf' |
||||
import samplePdf from '../../assets/sample.pdf' |
||||
import { IoReturnUpBack } from "react-icons/io5"; |
||||
import fizikpdf from "../../assets/fizik.pdf"; |
||||
import samplePdf from "../../assets/sample.pdf"; |
||||
const initialState = { |
||||
grade: 8, |
||||
groupId: 0, |
||||
name: '', |
||||
startDate: new Date(), |
||||
endDate: new Date(), |
||||
startTime: '19:0', |
||||
endTime: '', |
||||
description: '', |
||||
type: 'bank', |
||||
duration:null, |
||||
budgetFileId:null, |
||||
|
||||
questionnaires: [ |
||||
grade: 8, |
||||
groupId: 0, |
||||
name: "", |
||||
startDate: new Date(), |
||||
endDate: new Date(), |
||||
startTime: "19:0", |
||||
endTime: "", |
||||
description: "", |
||||
type: "bank", |
||||
duration: null, |
||||
budgetFileId: null, |
||||
|
||||
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, |
||||
name: 'عمومی', |
||||
fileUrl: fizikpdf, |
||||
courses: [ |
||||
|
||||
{ |
||||
id: 0, |
||||
questionnaireId: 1, |
||||
name: 'دینی', |
||||
coefficient: 4, |
||||
questionStart: 1, |
||||
questionEnd: 21 |
||||
}, |
||||
|
||||
], |
||||
answers:[ |
||||
|
||||
] |
||||
id: 1, |
||||
title: "تترا", |
||||
isAnswer: false, |
||||
}, |
||||
{ |
||||
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: [ |
||||
id: 2, |
||||
title: "سه ترا", |
||||
isAnswer: false, |
||||
}, |
||||
{ |
||||
questionId: 1, |
||||
courseId: 2, |
||||
title: 'تترا فلورید اسید چنتا اسید داره؟', |
||||
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 |
||||
}, |
||||
] |
||||
id: 3, |
||||
title: "هویج و گوجه فرنگی؟", |
||||
isAnswer: true, |
||||
}, |
||||
{ |
||||
questionId: 2, |
||||
courseId: 2, |
||||
title: 'asdaw dsfsdfiermc', |
||||
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 |
||||
}, |
||||
] |
||||
id: 4, |
||||
title: "فلور تا", |
||||
isAnswer: false, |
||||
}, |
||||
], |
||||
}, |
||||
{ |
||||
questionId: 2, |
||||
courseId: 2, |
||||
title: "asdaw dsfsdfiermc", |
||||
answeredPercentage: "83%", |
||||
score: 1, |
||||
options: [ |
||||
{ |
||||
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 |
||||
}, |
||||
] |
||||
id: 1, |
||||
title: "asdasd", |
||||
isAnswer: false, |
||||
}, |
||||
{ |
||||
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 |
||||
}, |
||||
] |
||||
id: 2, |
||||
title: "asdasd2", |
||||
isAnswer: false, |
||||
}, |
||||
|
||||
], |
||||
courses: [ |
||||
|
||||
], |
||||
questions: [ |
||||
|
||||
], |
||||
|
||||
|
||||
} |
||||
{ |
||||
id: 3, |
||||
title: "", |
||||
isAnswer: true, |
||||
}, |
||||
{ |
||||
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 default function addExamReduser(state = initialState, { type, payload }) { |
||||
switch (type) { |
||||
|
||||
case 'ADD_EXAM_GRADE_AND_GROUP': |
||||
return { |
||||
...state, |
||||
grade: payload.grade, |
||||
groupId: payload.groupId |
||||
} |
||||
|
||||
case 'ADD_EXAM_DESCRIPTION': |
||||
return { |
||||
...state, |
||||
name: payload.name, |
||||
startDate: new Date(), |
||||
endDate: new Date(), |
||||
startTime: "19:0", |
||||
endTime: "", |
||||
description: payload.description, |
||||
type: payload.type, |
||||
duration: payload.duration, |
||||
startDate: payload.startDate, |
||||
endDate: payload.endDate, |
||||
budgetFileId: payload.budgetFileId, |
||||
}; |
||||
|
||||
case 'ADD_EXAM_QUESTIONAIRES': |
||||
return { |
||||
...state, |
||||
questionnaires: [...state.questionnaires, payload] |
||||
} |
||||
case 'ADD_QUESTIONNAIRE_COURSES': |
||||
console.log(payload) |
||||
let thisQ = state.questionnaires.find(itm => itm.id == payload.questionnaireId) |
||||
let otherQ = state.questionnaires.filter(itm => itm.id !== payload.questionnaireId) |
||||
thisQ = { |
||||
...thisQ, |
||||
courses: [ ...thisQ.courses,payload] |
||||
} |
||||
console.log(thisQ) |
||||
return { |
||||
...state, |
||||
questionnaires: [...otherQ, thisQ] |
||||
} |
||||
case 'ADD_ANSWERS': |
||||
console.log(payload) |
||||
let thisQC = state.questionnaires.find(itm => itm.id == payload[0].questionnaierId) |
||||
let otherQC = state.questionnaires.filter(itm => itm.id !== payload[0].questionnaierId) |
||||
thisQC = { |
||||
...thisQC, |
||||
answers: [ ...thisQC?.answers,...payload] |
||||
} |
||||
|
||||
return { |
||||
...state, |
||||
questionnaires: [...otherQC, thisQC] |
||||
} |
||||
|
||||
case 'ADD_EXAM_COURSE': |
||||
return { |
||||
...state, |
||||
courses: [...state.courses, { ...payload, selectedQuestions:[]}], |
||||
}; |
||||
case 'REMOVE_EXAM_COURSE': |
||||
return { |
||||
...state, |
||||
courses: state.courses.filter(itm => itm.id !== payload.id) |
||||
} |
||||
|
||||
case 'ADD_EXAM_QUESTIONS': |
||||
console.log("??????????????"); |
||||
console.log(payload) |
||||
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] |
||||
|
||||
return { |
||||
...state, |
||||
courses: newCourses |
||||
|
||||
} |
||||
|
||||
|
||||
case 'REMOVE_EXAM_QUESTIONS': |
||||
const dontDeleteThese = state.courses.filter(itm => itm.id !== payload.courseId) |
||||
const courseForDelete = state.courses.filter(itm => itm.id == payload.courseId) |
||||
courseForDelete[0] = { ...courseForDelete[0], selectedQuestions: courseForDelete[0].selectedQuestions.filter(itm => itm.questionId !== payload.questionId) } |
||||
const newCoursesWithDeleted = [...dontDeleteThese, ...courseForDelete] |
||||
console.log(newCoursesWithDeleted) |
||||
console.log(courseForDelete) |
||||
console.log(dontDeleteThese) |
||||
console.log(payload) |
||||
return { |
||||
...state, |
||||
courses: newCoursesWithDeleted |
||||
|
||||
} |
||||
case 'REMOVE_QUESTION_FROM_BANK': |
||||
return { |
||||
...state, |
||||
questionBank: state.questionBank.filter(itm => itm.questionId !== payload.questionId) |
||||
} |
||||
case 'GET_QUESTION_BACK_TO_BANK': |
||||
return { |
||||
...state, |
||||
questionBank: [payload, ...state.questionBank,] |
||||
} |
||||
|
||||
case 'CHANGE_QUESTION_ORDER': |
||||
const dontChangeThese = state.courses.filter(itm => itm.id !== payload[0].courseId) |
||||
const courseForChange = state.courses.filter(itm => itm.id == payload[0].courseId) |
||||
courseForChange[0] = { ...courseForChange[0], 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 |
||||
|
||||
export default function addExamReduser( |
||||
state = initialState, |
||||
{ type, payload } |
||||
) { |
||||
switch (type) { |
||||
case "ADD_EXAM_GRADE_AND_GROUP": |
||||
return { |
||||
...state, |
||||
grade: payload.grade, |
||||
groupId: payload.groupId, |
||||
}; |
||||
|
||||
case "ADD_EXAM_DESCRIPTION": |
||||
return { |
||||
...state, |
||||
name: payload.name, |
||||
startDate: new Date(), |
||||
endDate: new Date(), |
||||
startTime: "19:0", |
||||
endTime: "", |
||||
description: payload.description, |
||||
type: payload.type, |
||||
duration: payload.duration, |
||||
startDate: payload.startDate, |
||||
endDate: payload.endDate, |
||||
budgetFileId: payload.budgetFileId, |
||||
}; |
||||
|
||||
case "ADD_EXAM_QUESTIONAIRES": |
||||
return { |
||||
...state, |
||||
questionnaires: [...state.questionnaires, payload], |
||||
}; |
||||
case "ADD_QUESTIONNAIRE_COURSES": |
||||
console.log(payload); |
||||
let thisQ = state.questionnaires.find( |
||||
(itm) => itm.id == payload.questionnaireId |
||||
); |
||||
let otherQ = state.questionnaires.filter( |
||||
(itm) => itm.id !== payload.questionnaireId |
||||
); |
||||
thisQ = { |
||||
...thisQ, |
||||
courses: [...thisQ.courses, payload], |
||||
}; |
||||
console.log(thisQ); |
||||
return { |
||||
...state, |
||||
questionnaires: [...otherQ, thisQ], |
||||
}; |
||||
case "ADD_ANSWERS": |
||||
console.log(payload); |
||||
let thisQC = state.questionnaires.find( |
||||
(itm) => itm.id == payload[0].questionnaierId |
||||
); |
||||
let otherQC = state.questionnaires.filter( |
||||
(itm) => itm.id !== payload[0].questionnaierId |
||||
); |
||||
thisQC = { |
||||
...thisQC, |
||||
answers: [...thisQC?.answers, ...payload], |
||||
}; |
||||
|
||||
return { |
||||
...state, |
||||
questionnaires: [...otherQC, thisQC], |
||||
}; |
||||
|
||||
case "ADD_EXAM_COURSE": |
||||
return { |
||||
...state, |
||||
courses: [...state.courses, { ...payload, selectedQuestions: [] }], |
||||
}; |
||||
case "REMOVE_EXAM_COURSE": |
||||
return { |
||||
...state, |
||||
courses: state.courses.filter((itm) => itm.id !== payload.id), |
||||
}; |
||||
|
||||
case "ADD_EXAM_QUESTIONS": |
||||
console.log("??????????????"); |
||||
console.log(payload); |
||||
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]; |
||||
|
||||
return { |
||||
...state, |
||||
courses: newCourses, |
||||
}; |
||||
case "ADD_EXAM_QUESTIONS2": |
||||
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 'CHANGE_QUESTIONNAIRES_ORDER': |
||||
return { |
||||
...state, |
||||
questionnaires: payload |
||||
|
||||
} |
||||
|
||||
default: |
||||
return state; |
||||
|
||||
} |
||||
|
||||
} |
||||
if(isNew){ |
||||
newList.push({ |
||||
examId: payload.examId, |
||||
list: [payload.item], |
||||
}); |
||||
} |
||||
return { |
||||
...state, |
||||
questions: newList, |
||||
}; |
||||
|
||||
case "REMOVE_EXAM_QUESTIONS": |
||||
const dontDeleteThese = state.courses.filter( |
||||
(itm) => itm.id !== payload.courseId |
||||
); |
||||
const courseForDelete = state.courses.filter( |
||||
(itm) => itm.id == payload.courseId |
||||
); |
||||
courseForDelete[0] = { |
||||
...courseForDelete[0], |
||||
selectedQuestions: courseForDelete[0].selectedQuestions.filter( |
||||
(itm) => itm.questionId !== payload.questionId |
||||
), |
||||
}; |
||||
const newCoursesWithDeleted = [...dontDeleteThese, ...courseForDelete]; |
||||
console.log(newCoursesWithDeleted); |
||||
console.log(courseForDelete); |
||||
console.log(dontDeleteThese); |
||||
console.log(payload); |
||||
return { |
||||
...state, |
||||
courses: newCoursesWithDeleted, |
||||
}; |
||||
case "REMOVE_QUESTION_FROM_BANK": |
||||
return { |
||||
...state, |
||||
questionBank: state.questionBank.filter( |
||||
(itm) => itm.questionId !== payload.questionId |
||||
), |
||||
}; |
||||
case "GET_QUESTION_BACK_TO_BANK": |
||||
return { |
||||
...state, |
||||
questionBank: [payload, ...state.questionBank], |
||||
}; |
||||
|
||||
case "CHANGE_QUESTION_ORDER": |
||||
const dontChangeThese = state.courses.filter( |
||||
(itm) => itm.id !== payload[0].courseId |
||||
); |
||||
const courseForChange = state.courses.filter( |
||||
(itm) => itm.id == payload[0].courseId |
||||
); |
||||
courseForChange[0] = { |
||||
...courseForChange[0], |
||||
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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -1,89 +1,153 @@ |
||||
import React, { useEffect, useState } from "react"; |
||||
import attachIcon from '../../../assets/img/attach-circle.svg'; |
||||
const AddQuestionPopUp = ({ titlePass, scorePass, submitOnClick, cancelOnClick, passOptionTitle, setAsAnswer, options }) => { |
||||
import { connect } from "react-redux"; |
||||
import attachIcon from "../../../assets/img/attach-circle.svg"; |
||||
import { question } from "../../../redux/actions"; |
||||
const AddQuestionPopUp = ({ |
||||
titlePass, |
||||
scorePass, |
||||
submitOnClick, |
||||
cancelOnClick, |
||||
passOptionTitle, |
||||
setAsAnswer, |
||||
options, |
||||
submitQuestion, |
||||
}) => { |
||||
const gozine = ["الف", "ب", "ج", "د", "ه", "ز"]; |
||||
|
||||
|
||||
const gozine = [ |
||||
'الف', |
||||
'ب', |
||||
'ج', |
||||
'د', |
||||
'ه', |
||||
'ز', |
||||
] |
||||
|
||||
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-1/2 flex flex-col items-center bg-white p-6 py-10 rounded-xl shadow-lg"> |
||||
<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}> |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 15.044 15.044"> |
||||
<g id="vuesax_linear_card-remove" data-name="vuesax/linear/card-remove" transform="translate(-252.46 -511.461)"> |
||||
<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)} |
||||
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-1/2 flex flex-col items-center bg-white p-6 py-10 rounded-xl shadow-lg"> |
||||
<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} |
||||
> |
||||
<svg |
||||
xmlns="http://www.w3.org/2000/svg" |
||||
width="12" |
||||
height="12" |
||||
viewBox="0 0 15.044 15.044" |
||||
> |
||||
<g |
||||
id="vuesax_linear_card-remove" |
||||
data-name="vuesax/linear/card-remove" |
||||
transform="translate(-252.46 -511.461)" |
||||
> |
||||
<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> |
||||
<p className='text-xs'>نمره :
|
||||
<input type='number' className="w-6 h-6 border border-gray-200 mr-1 rounded"
|
||||
<div className="w-full p-3 px-4 h-12 flex justify-between items-center"> |
||||
<div> |
||||
<p className="text-xs"> |
||||
نمره : |
||||
<input |
||||
type="number" |
||||
className="w-6 h-6 border border-gray-200 mr-1 rounded" |
||||
onChange={(e) => scorePass(e.target.value)} |
||||
/> |
||||
</p> |
||||
</div> |
||||
<input type='file' className="hidden" id="Add_Question_Add_Image" /> |
||||
<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> |
||||
/> |
||||
</p> |
||||
</div> |
||||
<input |
||||
type="file" |
||||
className="hidden" |
||||
id="Add_Question_Add_Image" |
||||
/> |
||||
<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 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 |
||||
</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> |
||||
<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> |
||||
); |
||||
}; |
||||
|
||||
<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> |
||||
|
||||
const mapStateToProps = (state) => ({ |
||||
|
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
}); |
||||
|
||||
) |
||||
} |
||||
const mapDispatchToProps = { |
||||
submitQuestion:question.add |
||||
}; |
||||
|
||||
export default AddQuestionPopUp; |
||||
export default connect(mapStateToProps, mapDispatchToProps)(AddQuestionPopUp); |
||||
|
Loading…
Reference in new issue