From 19e62b975b5c063b87bbec33ca9df4ae1038470e Mon Sep 17 00:00:00 2001 From: Pkpedram Date: Tue, 1 Mar 2022 14:46:46 +0330 Subject: [PATCH] Question Component Made --- src/redux/reducers/exam.js | 47 ++++++++++- src/view/addExam/components/question.js | 78 +++++++++++++++++++ .../addExam/views/AddQuestionsFromBank.js | 7 +- 3 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 src/view/addExam/components/question.js diff --git a/src/redux/reducers/exam.js b/src/redux/reducers/exam.js index ced1bb7..6c9d2ef 100644 --- a/src/redux/reducers/exam.js +++ b/src/redux/reducers/exam.js @@ -9,7 +9,7 @@ const initialState = { startTime: '19:0', endTime: '', description: '', - type: 1, + type: 'bank', questionnaires: [ { @@ -43,7 +43,52 @@ const initialState = { answers: [ + ], + + courseBank: [ + { + id: 2, + title: 'ریاضی' + } + ], + questionBank: [ + { + questionId: 1, + 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 + }, + ] + } + ], + courses: [ + + ], + questions: [ + ] + } export default function addExamReduser(state = initialState, { type, payload }) { diff --git a/src/view/addExam/components/question.js b/src/view/addExam/components/question.js new file mode 100644 index 0000000..6e73332 --- /dev/null +++ b/src/view/addExam/components/question.js @@ -0,0 +1,78 @@ +import React from 'react'; + + + + +const Question = () => { + + 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 = [ + 'الف', + 'ب', + 'ج', + 'د', + 'ه', + 'ز', + ] + return( +
+
+
+ {data.title} +
+
+
+

نمره : {data.score}

+
+
+ درصد پاسخگویی: {data.answeredPercentage} +
+
+
+
+ { + data.options.map( + (item) => ( +
+

{gozine[item.id - 1]}

+

{item.title}

+
+ ) + ) + } +
+
+ ) + + +} + +export default Question; \ No newline at end of file diff --git a/src/view/addExam/views/AddQuestionsFromBank.js b/src/view/addExam/views/AddQuestionsFromBank.js index cbd5290..6dd7dd7 100644 --- a/src/view/addExam/views/AddQuestionsFromBank.js +++ b/src/view/addExam/views/AddQuestionsFromBank.js @@ -8,6 +8,7 @@ import Checkbox from "../../../components/Checkbox"; import RangeDatePicker from "../../../components/RangeDatePicker"; import SelectedCourse from "../../../components/selectedCourse"; import AddQuestionnaireCourse from "../components/addQuestionnaireCourse"; +import Question from "../components/question"; const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backStep }) => { const [name, setName] = useState(null); @@ -242,8 +243,10 @@ const AddQuestionsFromBank = ({ grades, addExamState, dispatch, stepClick, backS
- {setAnswers(data); setFakeState(fakeState - 2)}}/> + {/* {setAnswers(data); setFakeState(fakeState - 2)}}/> */} + +