From 38e7771575c83fb8672d3c556a8fad5dd88f3f6c Mon Sep 17 00:00:00 2001 From: Pkpedram Date: Sat, 26 Feb 2022 16:03:05 +0330 Subject: [PATCH] AnswerSheet Made And Is Functional --- src/components/AnswerSheet/index.js | 68 ++++++++++++++++++++++++++ src/components/selectedCourse/index.js | 14 +++--- src/view/addExam/views/addQuestions.js | 8 ++- 3 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 src/components/AnswerSheet/index.js diff --git a/src/components/AnswerSheet/index.js b/src/components/AnswerSheet/index.js new file mode 100644 index 0000000..8e0c2d3 --- /dev/null +++ b/src/components/AnswerSheet/index.js @@ -0,0 +1,68 @@ +import React, { useEffect, useState } from "react"; + +const AnswerSheet = ({questionsQuantity, optionsQuantity }) => { + const [data, setData] = useState([]); + const [options, setOptions] = useState([]); + useEffect(() => { + let array = []; + let optionsArray = []; + for(var i =1; i <= questionsQuantity; i++){ + array.push({ + questionId : i, + answer: null, + }); + } + for(var i =1; i<= optionsQuantity; i++){ + optionsArray.push({ + id: i, + active: false, + }) + } + setOptions(optionsArray); + setData(array) + console.log(data, options) + }, []) + + return( +
+ { + data.map((item, index) => ( +
+

+ {item.questionId} +

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

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

+ + +
+ نمره : ۱ +
+ +
+ )) + } +
+ ) +} + +export default AnswerSheet diff --git a/src/components/selectedCourse/index.js b/src/components/selectedCourse/index.js index 17e2e40..5e89d47 100644 --- a/src/components/selectedCourse/index.js +++ b/src/components/selectedCourse/index.js @@ -1,7 +1,7 @@ import React from "react"; -const SelectedCourse = ({openAnswerSheet, title, questionQuantity, coefficient, optionsQuantity }) => { - return( +const SelectedCourse = ({ openAnswerSheet, title, questionQuantity, coefficient, optionsQuantity }) => { + return (
@@ -9,24 +9,24 @@ const SelectedCourse = ({openAnswerSheet, title, questionQuantity, coefficient, {title}
-

+

تعداد سوالات

- +

ضریب

- +

تعداد گزینه

- +

نمره منفی

- +