From 9ef8944ab6c284f2ae549c082fdfd1175a9e15d1 Mon Sep 17 00:00:00 2001 From: Pkpedram Date: Sat, 26 Feb 2022 10:49:58 +0330 Subject: [PATCH] Add Question, Questionare PopUp Made --- src/view/addExam/views/addQuestions.js | 208 +++++++++++++++++++++---- 1 file changed, 180 insertions(+), 28 deletions(-) diff --git a/src/view/addExam/views/addQuestions.js b/src/view/addExam/views/addQuestions.js index 99b077b..d996a6e 100644 --- a/src/view/addExam/views/addQuestions.js +++ b/src/view/addExam/views/addQuestions.js @@ -1,60 +1,212 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; import Button from "../../../components/Button"; import DatePicker from "../../../components/Calendar/CalendarComponents/DatePicker"; +import Checkbox from "../../../components/Checkbox"; import RangeDatePicker from "../../../components/RangeDatePicker"; -const AddQuestions = ({grades, addExamState, dispatch, stepClick, backStep}) => { +const AddQuestions = ({ grades, addExamState, dispatch, stepClick, backStep }) => { const [name, setName] = useState(null); const [type, setType] = useState(null); const [description, setDescription] = useState(null); + const [questionarePopUp, setQuestionairePopUp] = useState(false); + const [showCoursesInList, setShowCoursesInList] = useState([]); - const payload = {name: name, description: description, type: type}; - - return( + useEffect(() => { + questoinaresLists.map(item => showCoursesInList.push(false)); + console.log(showCoursesInList) + }, []) + + const payload = { name: name, description: description, type: type }; + + const questoinaresLists = [ + { + id: 1, + title: 'دفترچه عمومی', + numberOfQuestions: 60, + courses: [ + { + sortId: 1, + title: 'ادبیات فارسی', + coefficient: 3, + questionStart: 1, + questionEnd: 20, + + }, + { + sortId: 2, + title: 'عربی', + coefficient: 3, + questionStart: 21, + questionEnd: 35, + + }, + { + sortId: 3, + title: 'دینی', + coefficient: 2, + questionStart: 36, + questionEnd: 46, + + }, + { + sortId: 4, + title: 'زبان خارجه', + coefficient: 1, + questionStart: 47, + questionEnd: 60, + + }, + ] + }, + { + id: 1, + title: 'دفترچه عمومی', + numberOfQuestions: 60, + courses: [ + { + sortId: 1, + title: 'ادبیات فارسی', + coefficient: 3, + questionStart: 1, + questionEnd: 20, + + }, + { + sortId: 2, + title: 'عربی', + coefficient: 3, + questionStart: 21, + questionEnd: 35, + + }, + { + sortId: 3, + title: 'دینی', + coefficient: 2, + questionStart: 36, + questionEnd: 46, + + }, + { + sortId: 4, + title: 'زبان خارجه', + coefficient: 1, + questionStart: 47, + questionEnd: 60, + + }, + ] + } + ] + + return ( <> + { + questionarePopUp &&
+
+
+
setQuestionairePopUp(false)}> + + + + + + + + +
+
+ +
+ { + questoinaresLists.map( + (item, index) => ( + <> +
+ +

{item.title}

+

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

+

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

+

{ + let newArray = [...showCoursesInList]; + + newArray[index] = !newArray[index]; + + setShowCoursesInList(newArray) + + }}>نمایش دروس

+ +
+ { + showCoursesInList[index] &&
+ { + item.courses.map((course) => ( +
+

+ {course.title} +

+

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

+

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

+
+ ) ) + } +
+ } + + ) + ) + } +
+
+
+ }
-
- تنظیمات آزمون - -
-

لطفا مشخضات آزمون را تکمیل کنید

-
-
+
+ تنظیمات آزمون -
-

+

+

لطفا مشخضات آزمون را تکمیل کنید

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

+

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

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