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 { 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; |
||||||
|
} |
||||||
|
} |
||||||
|
@ -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 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); |
||||||
|
Loading…
Reference in new issue