diff --git a/src/redux/reducers/exam.js b/src/redux/reducers/exam.js index 6c9d2ef..07d4c84 100644 --- a/src/redux/reducers/exam.js +++ b/src/redux/reducers/exam.js @@ -47,9 +47,13 @@ const initialState = { courseBank: [ { - id: 2, + id: 1, title: 'ریاضی' - } + }, + { + id: 2, + title: 'شیمی' + }, ], questionBank: [ { @@ -80,7 +84,66 @@ const initialState = { isAnswer: false }, ] - } + }, + { + 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:'asdasd3', + isAnswer: true + }, + { + id: 4, + title:'asdasd4', + isAnswer: false + }, + ] + }, + { + questionId: 3, + courseId: 1, + title:'asdaw dsfsdfiermc', + answeredPercentage: '43%', + score: 1, + options: [ + { + id: 1, + title:'asdasd', + isAnswer: false + }, + { + id: 2, + title:'asdasd2', + isAnswer: false + }, + { + id: 3, + title:'asdasd3', + isAnswer: true + }, + { + id: 4, + title:'asdasd4', + isAnswer: false + }, + ] + }, + ], courses: [ @@ -143,6 +206,17 @@ export default function addExamReduser(state = initialState, { type, payload }) ] } + case 'ADD_EXAM_COURSE': + return { + ...state, + courses: [...state.courses, payload] + } + case 'REMOVE_EXAM_COURSE': + return { + ...state, + courses: state.courses.filter(itm => itm.id !== payload.id) + } + default: return state; diff --git a/src/view/addExam/components/question.js b/src/view/addExam/components/question.js index 6e73332..a884651 100644 --- a/src/view/addExam/components/question.js +++ b/src/view/addExam/components/question.js @@ -3,37 +3,37 @@ import React from 'react'; -const Question = () => { +const Question = ({data}) => { - const data = { - questionId: 1, - courseId: 2, - title:'آیا به نظر شما این کار کار درستی است؟', - answeredPercentage: '13', - score: 1, - options: [ - { - id: 1, - title:'بله', - isAnswer: false - }, - { - id: 2, - title:'نظر خاصی ندارم', - isAnswer: false - }, - { - id: 3, - title:'خیر', - isAnswer: true - }, - { - id: 4, - title:'هویج و گوجه فرنگی؟', - isAnswer: false - }, - ] - }; + // const data = { + // questionId: 1, + // courseId: 2, + // title:'آیا به نظر شما این کار کار درستی است؟', + // answeredPercentage: '13', + // score: 1, + // options: [ + // { + // id: 1, + // title:'بله', + // isAnswer: false + // }, + // { + // id: 2, + // title:'نظر خاصی ندارم', + // isAnswer: false + // }, + // { + // id: 3, + // title:'خیر', + // isAnswer: true + // }, + // { + // id: 4, + // title:'هویج و گوجه فرنگی؟', + // isAnswer: false + // }, + // ] + // }; const gozine = [ 'الف', 'ب', @@ -43,7 +43,7 @@ const Question = () => { 'ز', ] return( -
+
{data.title} diff --git a/src/view/addExam/views/AddQuestionsFromBank.js b/src/view/addExam/views/AddQuestionsFromBank.js index 6dd7dd7..dfb8917 100644 --- a/src/view/addExam/views/AddQuestionsFromBank.js +++ b/src/view/addExam/views/AddQuestionsFromBank.js @@ -23,26 +23,18 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS }); const [showCoursesInList, setShowCoursesInList] = useState([]); const [choosedQuestionaries, seChoosedQuestionaries] = useState([]); - const [selectedQuestionare, setSelectedQuestionare] = useState({ + const [selectedCourse, setSelectedCourse] = useState({ id: null, - courses: [] + title: '' }); const [answers, setAnswers] = useState(null); const [newCourse, setNewCourse] = useState({ id: addExamState.questionairesCourses.length + 1, - questionnaireId: selectedQuestionare.id, + questionnaireId: selectedCourse.id, questionsQuantity:20, name: '', coefficient: 4 }) - const [selectedCourse, setSelectedCourse] = useState({ - sortId: 1, - title: 'ادبیات فارسی', - coefficient: 3, - questionStart: 1, - questionEnd: 0, - - }) // console.log(choosedQuestionaries) // console.log(newQuestionaire) // console.log(addExamState.questionnaires) @@ -86,43 +78,31 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS

افزودن دفترچه

-
-
- setNewQuestionaire({...newQuestionaire, name: e.target.value})} /> - -
-
- -
+ + - {/* { - questoinaresLists.map( + { + addExamState.courseBank.map( (item, index) => ( <>
e.target.checked ? - seChoosedQuestionaries([...choosedQuestionaries, item]) + dispatch({type: 'ADD_EXAM_COURSE', payload: item}) : - seChoosedQuestionaries(choosedQuestionaries.filter(itm => itm.id !== item.id)) + dispatch({type: 'REMOVE_EXAM_COURSE', payload: item}) } />

{item.title}

-

تعداد سوالات: {item.numberOfQuestions}

-

تعداد دروس: {item.courses.length}

-

{ + {/*

تعداد سوالات: {item.numberOfQuestions}

+

تعداد دروس: {item.courses.length}

*/} + {/*

{ let newArray = [...showCoursesInList]; newArray[index] = !newArray[index]; @@ -130,46 +110,28 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS setShowCoursesInList(newArray) - }}>نمایش دروس

+ }}>نمایش دروس

*/}
- { - showCoursesInList[index] &&
- { - item.courses.map((course) => ( -
-

- {course.title} -

-

- ضریب : {course.coefficient} -

-

از سوال {course.questionStart} تا سوال {course.questionEnd}

-
- )) - } -
- } + ) ) - } */} - -
-
+ } +
+ +
} { - addCoursePopup && - setAddCoursePopup(false)} - nameOnChange={e => setNewCourse({...newCourse, name: e.target.value})} - coefficientOnChange={e => setNewCourse({...newCourse, coefficient: e.target.vlaue})} - questionQuantityOnChange={e => setNewCourse({...newCourse, questionsQuantity: e.target.value, questionnaireId: selectedQuestionare.id})} - submitOnClick={() => {dispatch({type: 'ADD_QUESTIONNAIRE_COURSES', payload : newCourse}); setAddCoursePopup(false); setFakeState(fakeState + 356)} } - /> + // addCoursePopup && + // setAddCoursePopup(false)} + // nameOnChange={e => setNewCourse({...newCourse, name: e.target.value})} + // coefficientOnChange={e => setNewCourse({...newCourse, coefficient: e.target.vlaue})} + // questionQuantityOnChange={e => setNewCourse({...newCourse, questionsQuantity: e.target.value, questionnaireId: selectedQuestionare.id})} + // submitOnClick={() => {dispatch({type: 'ADD_QUESTIONNAIRE_COURSES', payload : newCourse}); setAddCoursePopup(false); setFakeState(fakeState + 356)} } + // /> } @@ -183,27 +145,30 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS
- { - addExamState.questionnaires.map( + {addExamState.courses.length > 0 && + addExamState.courses.map( (item => ( -
setSelectedQuestionare({id : item.id,name: item.name, courses: addExamState.questionairesCourses.filter(itm => itm.questionnaireId == item.id)})} +
setSelectedCourse(item)} > +

dispatch({type: 'REMOVE_EXAM_COURSE', payload: item})}> + x +

- دفترچه {item.name} + {item.title}

)) ) } -
addExamState.type == 'bank' ? console.log('bank') : setQuestionairePopUp(true)}> +
setQuestionairePopUp(true)}>

+

- {addExamState.type == 'bank' ? 'افزودن درس' : 'افزودن دفترچه'} + افزودن درس

@@ -214,7 +179,7 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS
- { + {/* { selectedQuestionare.id !== null && (<>

دفترچه {selectedQuestionare.name} @@ -239,14 +204,18 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS -

} +
} */}
{/* {setAnswers(data); setFakeState(fakeState - 2)}}/> */} - - +{selectedCourse.id !== null && + addExamState.questionBank.filter(itm => itm.courseId == selectedCourse.id).map( + (course) => () + ) +} + {/* */}
diff --git a/src/view/addExam/views/addQuestionnaireExam.js b/src/view/addExam/views/addQuestionnaireExam.js index ef4bd84..67fa556 100644 --- a/src/view/addExam/views/addQuestionnaireExam.js +++ b/src/view/addExam/views/addQuestionnaireExam.js @@ -274,4 +274,4 @@ const mapStateToProps = (state) => ({ addExamState: state.addExamReduser }) -export default connect(mapStateToProps)(AddQuestionnaireExam); \ No newline at end of file +export default connect(mapStateToProps)(AddQuestionnaireCourse); \ No newline at end of file