|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
import "./index.css"; |
|
|
|
|
import { useSelector } from "react-redux"; |
|
|
|
|
import { connect, useSelector } from "react-redux"; |
|
|
|
|
import { useState } from "react"; |
|
|
|
|
|
|
|
|
|
import img0 from "../../../../assets/azmoon-list/test.png"; |
|
|
|
@ -17,12 +17,32 @@ import { Link } from "react-router-dom"; |
|
|
|
|
import moment from "jalali-moment"; |
|
|
|
|
import { useEffect } from "react"; |
|
|
|
|
import { state } from "../../../../components/exam/Carousel/state"; |
|
|
|
|
import { exam } from "../../../../redux/actions"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const EnterExam = ({ ID }) => { |
|
|
|
|
let gradeList = [ |
|
|
|
|
"اول", |
|
|
|
|
"دوم", |
|
|
|
|
"سوم", |
|
|
|
|
"چهارم", |
|
|
|
|
"پنجم", |
|
|
|
|
"ششم", |
|
|
|
|
"هفتم", |
|
|
|
|
"هشتم", |
|
|
|
|
"نهم", |
|
|
|
|
"دهم", |
|
|
|
|
"یازدهم", |
|
|
|
|
"دوازدهم", |
|
|
|
|
]; |
|
|
|
|
const EnterExam = ({ ID, getExamInfo, examInfo }) => { |
|
|
|
|
// const state = useSelector((state) => state.default);
|
|
|
|
|
console.log("Cheraaaaaaaaaaaaaa????????"); |
|
|
|
|
console.log(ID); |
|
|
|
|
useEffect(() => { |
|
|
|
|
getExamInfo({ id: ID }); |
|
|
|
|
}, []); |
|
|
|
|
console.log(examInfo); |
|
|
|
|
//------------------------------------------
|
|
|
|
|
const [common_data] = useState(state); |
|
|
|
|
console.log(common_data); |
|
|
|
|
let data; |
|
|
|
|
for (let i = 0; i < common_data.length; i++) { |
|
|
|
|
if (common_data[i].id === Number(ID)) { |
|
|
|
@ -31,113 +51,129 @@ const EnterExam = ({ ID }) => { |
|
|
|
|
} |
|
|
|
|
console.log("cc:" + data); |
|
|
|
|
//--today date--and timer setting-----------------------------
|
|
|
|
|
let today = new Date(); |
|
|
|
|
let examDate = new Date(data.date) |
|
|
|
|
console.log(today); |
|
|
|
|
console.log(examDate); |
|
|
|
|
let diff = (examDate-today)/1000; |
|
|
|
|
let d = Math.floor(diff/86400); |
|
|
|
|
console.log(d); |
|
|
|
|
let h = Math.floor((diff-(86400*d))/3600); |
|
|
|
|
console.log(h); |
|
|
|
|
let m = Math.floor((diff-(86400*d)-(h*3600))/60); |
|
|
|
|
console.log(m); |
|
|
|
|
let s = Math.floor(diff-(86400*d)-(h*3600)-(m*60)); |
|
|
|
|
console.log(s); |
|
|
|
|
const [timer,setTimer]=useState({ |
|
|
|
|
d,h,m,s |
|
|
|
|
}) |
|
|
|
|
// let today = new Date();
|
|
|
|
|
// let examDate = new Date(data.date)
|
|
|
|
|
// let diff = (examDate-today)/1000;
|
|
|
|
|
// let d = Math.floor(diff/86400);
|
|
|
|
|
// let h = Math.floor((diff-(86400*d))/3600);
|
|
|
|
|
// let m = Math.floor((diff-(86400*d)-(h*3600))/60);
|
|
|
|
|
// let s = Math.floor(diff-(86400*d)-(h*3600)-(m*60));
|
|
|
|
|
// const [timer,setTimer]=useState({
|
|
|
|
|
// d,h,m,s
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
// console.log(sec);
|
|
|
|
|
if (timer.s >= 0 && diff > 0) { |
|
|
|
|
setTimeout(() => { |
|
|
|
|
// console.log("okdkdokodkd");
|
|
|
|
|
setTimer({ |
|
|
|
|
d, |
|
|
|
|
h, |
|
|
|
|
m, |
|
|
|
|
s:s-1 |
|
|
|
|
}); |
|
|
|
|
if (timer.s === 0) { |
|
|
|
|
setTimer({ |
|
|
|
|
d, |
|
|
|
|
h, |
|
|
|
|
m:m-1, |
|
|
|
|
s:59 |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (timer.m === 0) { |
|
|
|
|
setTimer({ |
|
|
|
|
d, |
|
|
|
|
h:h-1, |
|
|
|
|
m:59, |
|
|
|
|
s:59 |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (timer.h === 0) { |
|
|
|
|
setTimer({ |
|
|
|
|
d:d-1, |
|
|
|
|
h:23, |
|
|
|
|
m:59, |
|
|
|
|
s:59 |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, 1000); |
|
|
|
|
} |
|
|
|
|
// if (timer.s >= 0 && diff > 0) {
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// // console.log("okdkdokodkd");
|
|
|
|
|
// setTimer({
|
|
|
|
|
// d,
|
|
|
|
|
// h,
|
|
|
|
|
// m,
|
|
|
|
|
// s:s-1
|
|
|
|
|
// });
|
|
|
|
|
// if (timer.s === 0) {
|
|
|
|
|
// setTimer({
|
|
|
|
|
// d,
|
|
|
|
|
// h,
|
|
|
|
|
// m:m-1,
|
|
|
|
|
// s:59
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// if (timer.m === 0) {
|
|
|
|
|
// setTimer({
|
|
|
|
|
// d,
|
|
|
|
|
// h:h-1,
|
|
|
|
|
// m:59,
|
|
|
|
|
// s:59
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// if (timer.h === 0) {
|
|
|
|
|
// setTimer({
|
|
|
|
|
// d:d-1,
|
|
|
|
|
// h:23,
|
|
|
|
|
// m:59,
|
|
|
|
|
// s:59
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }, 1000);
|
|
|
|
|
// }
|
|
|
|
|
}); |
|
|
|
|
//-------------------------------------------
|
|
|
|
|
moment.locale("en"); |
|
|
|
|
return ( |
|
|
|
|
<div className="enter-exam"> |
|
|
|
|
<div className="enter-exam-box"> |
|
|
|
|
<div |
|
|
|
|
className="enter-exam-box" |
|
|
|
|
style={window.innerWidth < 1000 ? { width: "95%" } : { width: "35%",height:"auto" }} |
|
|
|
|
> |
|
|
|
|
<div className="eeb-title-box"> |
|
|
|
|
<img className="eeb-title-box-img" src={img0} alt="title-box-img" /> |
|
|
|
|
<div className="eeb-title-box-title">به {data?.name}</div> |
|
|
|
|
<div className="eeb-title-box-title">به {examInfo?.name}</div> |
|
|
|
|
<div className="eeb-title-box-subtitle">خوش آمدید</div> |
|
|
|
|
</div> |
|
|
|
|
<div className="eeb-name-box"> |
|
|
|
|
<img className="eeb-name-box-icon" src={icon1} alt="name-icon" /> |
|
|
|
|
<div className="eeb-name-box-label">نام آزمون:</div> |
|
|
|
|
<div className="eeb-name-box-name">{data?.name.substr(6)}</div> |
|
|
|
|
<div className="eeb-name-box-name">{examInfo?.name}</div> |
|
|
|
|
</div> |
|
|
|
|
<div className="eeb-level-box"> |
|
|
|
|
<img className="eeb-level-box-icon" src={icon2} alt="name-icon" /> |
|
|
|
|
<div className="eeb-level-box-label">پایه تحصیلی:</div> |
|
|
|
|
<div className="eeb-level-box-level">{data?.level}</div> |
|
|
|
|
<div className="eeb-level-box-level"> |
|
|
|
|
{gradeList[examInfo?.gradeId - 1]} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div className="eeb-date-box"> |
|
|
|
|
<img className="eeb-date-box-icon" src={icon3} alt="name-icon" /> |
|
|
|
|
<div className="eeb-date-box-label">زمان آزمون:</div> |
|
|
|
|
{examInfo?.startDate && ( |
|
|
|
|
<div className="eeb-date-box-date"> |
|
|
|
|
{moment(data?.date, 'YYYY/MM/DD').format('jYYYY/jM/jD')} |
|
|
|
|
</div> |
|
|
|
|
<div className="eeb-date-box-time">ساعت
|
|
|
|
|
{examDate.getHours()}:{examDate.getMinutes()} |
|
|
|
|
از{" "} |
|
|
|
|
{examInfo?.startDate && |
|
|
|
|
moment(examInfo?.startDate, "YYYY/MM/DD") |
|
|
|
|
.locale("fa") |
|
|
|
|
.format("YYYY/MM/DD")}{" "} |
|
|
|
|
تا{" "} |
|
|
|
|
{examInfo?.endDate && |
|
|
|
|
moment(examInfo?.endDate, "YYYY/MM/DD") |
|
|
|
|
.locale("fa") |
|
|
|
|
.format("YYYY/MM/DD")} |
|
|
|
|
</div> |
|
|
|
|
)} |
|
|
|
|
{!examInfo?.startDate && ( |
|
|
|
|
<div className="eeb-date-box-date">نامشخص</div> |
|
|
|
|
)} |
|
|
|
|
{/* <div className="eeb-date-box-time"> |
|
|
|
|
ساعت |
|
|
|
|
|
|
|
|
|
</div> */} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div className="eeb-negetive-point-and-question-type-box"> |
|
|
|
|
<div className="eeb-np-box"> |
|
|
|
|
<div |
|
|
|
|
className="eeb-negetive-point-and-question-type-box" |
|
|
|
|
style={{ display: "block" }} |
|
|
|
|
> |
|
|
|
|
<div className="eeb-np-box border-b border-[#F5F5F5]"> |
|
|
|
|
<img className="eeb-np-box-icon" src={icon4} alt="name-icon" /> |
|
|
|
|
<div className="eeb-np-box-label">نمره منفی:</div> |
|
|
|
|
<div className="eeb-np-box-have"> |
|
|
|
|
{data?.negattiveMode && "دارد"} |
|
|
|
|
{!data?.negattiveMode && "ندارد"} |
|
|
|
|
{examInfo?.negativePoint && "دارد"} |
|
|
|
|
{!examInfo?.negativePoint && "ندارد"} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div className="eeb-qt-box"> |
|
|
|
|
<img className="eeb-qt-box-icon" src={icon5} alt="name-icon" /> |
|
|
|
|
<div className="eeb-qt-box-label">نوع سوالات:</div> |
|
|
|
|
<div className="eeb-qt-box-type">{data?.types}</div> |
|
|
|
|
<div className="eeb-qt-box-type">تستی</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div className="eeb-max-user-and-exam-type-box"> |
|
|
|
|
<div className="eeb-mu-box"> |
|
|
|
|
{/* <div className="eeb-mu-box"> |
|
|
|
|
<img className="eeb-mu-box-icon" src={icon6} alt="name-icon" /> |
|
|
|
|
<div className="eeb-mu-box-label">حدنصاب شرکت کنندگان: </div> |
|
|
|
|
<div className="eeb-mu-box-number">{data?.capacity} نفر</div> |
|
|
|
|
</div> |
|
|
|
|
</div> */} |
|
|
|
|
<div className="eeb-et-box"> |
|
|
|
|
<img className="eeb-et-box-icon" src={icon7} alt="name-icon" /> |
|
|
|
|
<div className="eeb-et-box-label">نوع شرکت در آزمون:</div> |
|
|
|
@ -147,20 +183,18 @@ const EnterExam = ({ ID }) => { |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<div className="eeb-guide-box"> |
|
|
|
|
{/* <div className="eeb-guide-box"> |
|
|
|
|
<img className="eeb-guide-box-icon" src={icon8} alt="name-icon" /> |
|
|
|
|
<div className="eeb-guide-box-label">فایل راهنما:</div> |
|
|
|
|
<div className="eeb-guide-box-have"> |
|
|
|
|
{data?.guideFileId && "دارد"} |
|
|
|
|
{!data?.guideFileId && "ندارد"} -</div> |
|
|
|
|
<Link |
|
|
|
|
to={data?.guideFileId || "#"} |
|
|
|
|
className="eeb-guide-box-link" |
|
|
|
|
> |
|
|
|
|
{!data?.guideFileId && "ندارد"} - |
|
|
|
|
</div> |
|
|
|
|
<Link to={data?.guideFileId || "#"} className="eeb-guide-box-link"> |
|
|
|
|
دریافت فایل |
|
|
|
|
</Link> |
|
|
|
|
</div> |
|
|
|
|
<div className="eeb-created-box"> |
|
|
|
|
</div> */} |
|
|
|
|
{/* <div className="eeb-created-box"> |
|
|
|
|
<div className="eeb-created-box-img-container"> |
|
|
|
|
<img |
|
|
|
|
className="eeb-created-box-icon" |
|
|
|
@ -170,14 +204,14 @@ const EnterExam = ({ ID }) => { |
|
|
|
|
</div> |
|
|
|
|
<div className="eeb-created-box-label">ایجاد شده توسط</div> |
|
|
|
|
<div className="eeb-created-box-file">موسسه فرهنگی مصباح نور</div> |
|
|
|
|
</div> |
|
|
|
|
{(new Date(data.date)<today) &&<Link |
|
|
|
|
</div> */} |
|
|
|
|
<Link |
|
|
|
|
to={`/dashboard/azmoon_list/exam/${data?.id}`} |
|
|
|
|
className="eeb-btn" |
|
|
|
|
> |
|
|
|
|
شروع آزمون |
|
|
|
|
</Link>} |
|
|
|
|
{(new Date(data.date)>today) &&
|
|
|
|
|
</Link> |
|
|
|
|
{/* {(new Date(data.date)>today) && |
|
|
|
|
<div className="eeb-timer"> |
|
|
|
|
<div>{timer.d} روز و </div> |
|
|
|
|
<div>{timer.h} ساعت و </div> |
|
|
|
@ -185,10 +219,18 @@ const EnterExam = ({ ID }) => { |
|
|
|
|
<div>{timer.s} ثانیه </div> |
|
|
|
|
<div>تا شروع آزمون</div> |
|
|
|
|
</div> |
|
|
|
|
} |
|
|
|
|
} */} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export default EnterExam; |
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
|
examInfo: state.exam2.info, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|
getExamInfo: exam.info, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(EnterExam); |
|
|
|
|