|
@@ -0,0 +1,88 @@
|
|
|
|
|
+import React from 'react';
|
|
|
|
|
+import {NavLink} from "react-router-dom";
|
|
|
|
|
+import {Descriptions, Divider, Collapse } from "antd";
|
|
|
|
|
+import {fetcher} from "../../utils/common";
|
|
|
|
|
+import { error } from "../../utils/message";
|
|
|
|
|
+import {USER_ANSWERSET} from "../../utils/constants";
|
|
|
|
|
+import { FaCheck } from "react-icons/fa";
|
|
|
|
|
+import { HiBadgeCheck } from "react-icons/hi";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+const { Panel } = Collapse;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+const QuestionItemDescription = (props) => (
|
|
|
|
|
+ <Collapse>
|
|
|
|
|
+ <Panel header={
|
|
|
|
|
+ <div className="d-flex justify-content-between">
|
|
|
|
|
+ <div>مشاهده پاسخها</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ }
|
|
|
|
|
+ >
|
|
|
|
|
+ { props.answersInfo.map( (item, key) => (
|
|
|
|
|
+ <div key={key}>
|
|
|
|
|
+ <div>{item.question_info.question}</div>
|
|
|
|
|
+ <div className="d-flex justify-content-between">
|
|
|
|
|
+ <p>
|
|
|
|
|
+ { item.question_info.answer_index === 1 && <HiBadgeCheck size="1.5em" color="green" /> }
|
|
|
|
|
+ گزینه 1) {item.question_info.ans1}
|
|
|
|
|
+ { item.chosen_index === 1 && <FaCheck /> }
|
|
|
|
|
+ </p>
|
|
|
|
|
+ <p>
|
|
|
|
|
+ { item.question_info.answer_index === 2 && <HiBadgeCheck size="1.5em" color="green" /> }
|
|
|
|
|
+ گزینه 2) {item.question_info.ans2}
|
|
|
|
|
+ { item.chosen_index === 2 && <FaCheck /> }
|
|
|
|
|
+ </p>
|
|
|
|
|
+ <p>
|
|
|
|
|
+ { item.question_info.answer_index === 3 && <HiBadgeCheck size="1.5em" color="green" /> }
|
|
|
|
|
+ گزینه 3) {item.question_info.ans3}
|
|
|
|
|
+ { item.chosen_index === 3 && <FaCheck /> }
|
|
|
|
|
+ </p>
|
|
|
|
|
+ <p>
|
|
|
|
|
+ { item.question_info.answer_index === 4 && <HiBadgeCheck size="1.5em" color="green" /> }
|
|
|
|
|
+ گزینه 4) {item.question_info.ans4}
|
|
|
|
|
+ { item.chosen_index === 4 && <FaCheck /> }
|
|
|
|
|
+ </p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ))}
|
|
|
|
|
+ </Panel>
|
|
|
|
|
+ </Collapse>
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+const AnswersetDescription = (props) => (
|
|
|
|
|
+ <div className="my-3">
|
|
|
|
|
+ <h6>نتایج آزمون {props.item.test_set}</h6>
|
|
|
|
|
+ <div>نمره کسب شده : {props.item.mark}</div>
|
|
|
|
|
+ <div className="p-2">
|
|
|
|
|
+ <QuestionItemDescription answersInfo={props.item.answers_info} />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <Divider />
|
|
|
|
|
+ </div>
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+export default function Results(props) {
|
|
|
|
|
+
|
|
|
|
|
+ const [answersets, setAnswersets] = React.useState([]);
|
|
|
|
|
+
|
|
|
|
|
+ React.useEffect( () => {
|
|
|
|
|
+ fetchAnswersets();
|
|
|
|
|
+ }, [])
|
|
|
|
|
+
|
|
|
|
|
+ const fetchAnswersets = () => {
|
|
|
|
|
+ fetcher(USER_ANSWERSET)
|
|
|
|
|
+ .then( response => setAnswersets(response))
|
|
|
|
|
+ .catch( e => error(String(e)))
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div className="p-5">
|
|
|
|
|
+ <div className="d-flex justify-content-between">
|
|
|
|
|
+ <h5>نتایج</h5>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {answersets.map( (item , key) => <AnswersetDescription key={key} item={item} /> )}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+}
|