From bf4aef4e90deb9c7e487b9e64c08a1a9b3299f67 Mon Sep 17 00:00:00 2001 From: Alireza khaji Date: Tue, 12 Jul 2022 16:52:33 +0430 Subject: [PATCH] userManagement, add note exam process | 255 --- package.json | 1 + src/components/AnswerSheet/index.js | 189 +++++++++--------- src/redux/actions/book.js | 6 +- src/redux/reducers/book.js | 105 +--------- src/view/addExam/views/ViewExam.js | 22 +- src/view/addExam/views/ViewExamNote.js | 133 ++++++++++++ .../addExam/views/addQuestionnaireExam.js | 25 ++- src/view/user-management/index.js | 59 ++++-- yarn.lock | 66 +++++- 9 files changed, 378 insertions(+), 228 deletions(-) create mode 100644 src/view/addExam/views/ViewExamNote.js diff --git a/package.json b/package.json index a7c4910..93a44b6 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "react-indiana-drag-scroll": "^2.1.0", "react-leaflet": "^3.2.5", "react-multi-date-picker": "^3.3.0", + "react-pdf": "^5.7.2", "react-redux": "^7.2.6", "react-router-dom": "^6.2.1", "react-scripts": "5.0.0", diff --git a/src/components/AnswerSheet/index.js b/src/components/AnswerSheet/index.js index e4347ea..211b2b7 100644 --- a/src/components/AnswerSheet/index.js +++ b/src/components/AnswerSheet/index.js @@ -1,99 +1,106 @@ import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; -const AnswerSheet = ({ questionStart, questionEnd, optionsQuantity, selectedCourseId, passAnswers,selectedQId, addExamState }) => { - const [data, setData] = useState([]); - const [options, setOptions] = useState([]); - const [success, setSuccess] = useState(selectedCourseId); - useEffect(() => { - let array = []; - let optionsArray = []; - for (var i = questionStart; i <= questionEnd; i++) { - array.push({ - questionId:i, - answer: null, - courseId: selectedCourseId, - questionnaierId: selectedQId - }); - } - for (var i = 1; optionsQuantity ? i <= optionsQuantity : i <=4 ; i++) { - optionsArray.push({ - id: i, - active: false, - }) - } - - setOptions(optionsArray); - setData(array) - // passAnswers(data) - - // console.log(data, options) - }, [selectedCourseId]) - console.log(selectedCourseId) +const AnswerSheet = ({ + questionStart, + questionEnd, + optionsQuantity, + selectedCourseId, + passAnswers, + selectedQId, + addExamState, + selectedCourse, +}) => { + const [data, setData] = useState([]); + const [options, setOptions] = useState([]); + const [success, setSuccess] = useState(selectedCourseId); + useEffect(() => { + let array = []; + let optionsArray = []; + for (var i = Number(questionStart); i <= Number(questionEnd); i++) { + array.push({ + questionId: i, + answer: null, + courseId: selectedCourseId, + questionnaierId: selectedQId, + }); + } + for (var i = 1; optionsQuantity ? i <= optionsQuantity : i <= 4; i++) { + optionsArray.push({ + id: i, + active: false, + }); + } + + setOptions(optionsArray); + setData(array); + // passAnswers(data) + + // console.log(data, options) + }, [selectedCourseId]); + console.log(selectedCourseId); + console.log("yyyyyyyyyyyyyyyyyyyyy"); + console.log(data); + console.log(selectedCourse); + + return success == selectedCourseId && success !== undefined ? ( +
+ +
+ ) : ( +
+ {data.map((item, index) => ( +
+

+ {item.questionId} +

+
+ {options.map((option) => ( +

{ + var newArray = [...data]; + + newArray[index].answer = option.id; + + setData(newArray); + // console.log(data) + }} + >

+ ))} +
+ +
نمره : ۱
+
+ ))} - return (success == selectedCourseId && success !== undefined? - + {data.length > 0 && (
- -
- - : - -
- { - data.map((item, index) => ( -
-

- {item.questionId} -

-
- - { - options.map( - (option) => ( - -

{ - var newArray = [...data]; - - newArray[index].answer = option.id; - - setData(newArray) - // console.log(data) - - - }} > - -

- - - ) - ) - } - -
- - -
- نمره : ۱ -
- -
- )) - } - - {data.length > 0 && -
- -
} +
- ) -} + )} +
+ ); +}; const mapStateToProps = (state) => ({ - grades: state.publicApi.grades, - addExamState: state.addExamReduser -}) + grades: state.publicApi.grades, + addExamState: state.addExamReduser, +}); export default connect(mapStateToProps)(AnswerSheet); diff --git a/src/redux/actions/book.js b/src/redux/actions/book.js index 6a11165..9e933d4 100644 --- a/src/redux/actions/book.js +++ b/src/redux/actions/book.js @@ -1,9 +1,13 @@ import proxy from "../proxy"; const book = { - list: + list: (data = {}) => async (dispatch) => await proxy.get("product/list", data, { dispatch }), + schoolUser: + (data = {}) => + async (dispatch) => + await proxy.get("product/schoolUsers", data, { dispatch }), info: (data = {}) => async (dispatch) => diff --git a/src/redux/reducers/book.js b/src/redux/reducers/book.js index eecc593..35f174c 100644 --- a/src/redux/reducers/book.js +++ b/src/redux/reducers/book.js @@ -3,107 +3,8 @@ import { toast } from "react-toastify"; const initialState = { loading: false, error: null, - list: [ - { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, { - id:1, - name: 'عربی دوازدهم', - product: [{ price: 1000000,}], - vodTeacher: 'علی عبدالمالکی' - - }, - - -], + list: [], + schoolUserList :[], info: null, searchResult: [], filterResult: [], @@ -161,6 +62,8 @@ export default function book(state = initialState, action) { }; case "product/info": return { ...state, loading: false, info: data, error: null }; + case "product/schoolUser": + return { ...state, loading: false, schoolUserList: data, error: null }; case "book/lesson/active": return { ...state, diff --git a/src/view/addExam/views/ViewExam.js b/src/view/addExam/views/ViewExam.js index 5263b58..b92f7a2 100644 --- a/src/view/addExam/views/ViewExam.js +++ b/src/view/addExam/views/ViewExam.js @@ -12,6 +12,7 @@ import Preview from "../../../components/AnswerSheet/preview"; import { exam } from "../../../redux/actions"; import moment from "jalali-moment"; import preview from "../../../components/AnswerSheet/preview"; +import ViewExamNote from "./ViewExamNote"; const ViewExam = ({ addExamState, @@ -26,7 +27,7 @@ const ViewExam = ({ useEffect(() => { window.scrollTo(0, 0); console.log("oooooooooooooooooooooooooooooo"); - console.log(addExamState); + // console.log(addExamState); console.log(examId); }, []); @@ -88,7 +89,7 @@ const ViewExam = ({ return (
-
+

آزمون {examPreview?.exam?.name}

@@ -98,9 +99,9 @@ const ViewExam = ({
-
- {examPreview?.exam?.type && ( -
+
+ {examPreview?.exam?.type === 1 && ( +
{examPreview?.questions?.map((item, index) => (
)} + {examPreview?.exam?.type === 2 && ( + + )} + {/* */}
-
+