Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const [open,setOpen] = useState(false);
- const classes = useStyles();
- const theme = useTheme();
- const isWeb = useMediaQuery(theme.breakpoints.up("sm"));
- const testValue = 0;
- const { id, page, from } = useParams();
- const [currentPage, setCurrentPage] = useState(useParams().page);
- const initData = useSelector((state) => state.initData);
- let resultinitData,allExams=[];
- const AllresultinitData = useSelector((state) => state.initData.results);
- if(AllresultinitData!==undefined){
- resultinitData = AllresultinitData[id];
- }
- const resultresponse = useSelector((state) => state.submitAnsResponse);
- let inittialAllExam =useSelector((state) => state.initData.exams);
- if(inittialAllExam!==undefined)
- allExams=inittialAllExam;
- let archievedExam = useSelector((state) => state.archievedData.exams);
- if (archievedExam !== undefined) {
- allExams = [...allExams, ...archievedExam];
- }
- const history = useHistory();
- const pageChange = (Page) => {
- setCurrentPage(Page);
- history.push(resultDetails(id, Page, from));
- };
- let result,
- statistics = {},
- passed_examinees = 0,
- total_examinees = 0,
- cut_mark = 0.0,
- marks = 0.0,
- incorrect_answers = 0,
- correct_answers = 0,
- skippedCount = 0,
- total_marks = 1,
- total_questions=0,
- title="";
- if (from == RESPONSE) {
- result = resultresponse;
- statistics = result.statistics;
- } else {
- result = resultinitData;
- if (result == undefined) {
- const resultarray = allExams.filter((ex) => ex.id == id);
- if (resultarray.length > 0) {
- result = resultarray[0];
- statistics = result.statistics;
- }
- } else statistics = result.exam_data.statistics;
- }
- if (isEmpty(result) || result == undefined) {
- return <LoaderComponent />;
- }
- let standings = [];
- if (from != RESPONSE) {
- if ( result.exam_data == undefined ||result.exam_data.statistics == undefined
- ) {
- standings = result.statistics.standings;
- } else standings = result.exam_data.statistics.standings;
- passed_examinees = statistics.passed_examinees;
- total_examinees = statistics.total_examinees;
- if(statistics.cut_mark!=undefined)
- cut_mark = statistics.cut_mark.toFixed(1);
- }
- else {
- if (result.exam_data != undefined) {
- standings = result.exam_data.statistics.standings;
- }
- }
- let currentQuestion = [];
- if (from == RESPONSE) {
- let AllcurrentQuestion = allExams.filter((ex) => ex.id == id)[0].questions;
- if(AllcurrentQuestion!==undefined)
- {
- currentQuestion = AllcurrentQuestion;
- }
- } else {
- if (
- result.exam_data == undefined ||
- result.exam_data.questions == undefined
- ) {
- currentQuestion = result.questions;
- } else currentQuestion = result.exam_data.questions;
- }
- if (result.answer_sheet != undefined) {
- let mp = {};
- result.answer_sheet.forEach((ans) => {
- mp[ans.question] = ans.answers[0];
- });
- // console.log(currentQuestion);
- let newAnswerSheet = [];
- if(currentQuestion!==undefined){
- currentQuestion.forEach((que) => {
- if (mp[que] != undefined)
- newAnswerSheet.push({
- answers: [mp[que]],
- question: que,
- });
- else
- newAnswerSheet.push({
- answers: [],
- question: que,
- });
- });
- }
- result = { ...result, ["answer_sheet"]: newAnswerSheet };
- }
- if (result != undefined && result.answer_sheet != undefined) {
- marks = result.statistics.marks.toFixed(1);
- incorrect_answers = result.statistics.incorrect_answers;
- correct_answers = result.statistics.correct_answers;
- skippedCount =
- result.answer_sheet.length - (incorrect_answers + correct_answers);
- }
- const pageCheck = (newPage) => newPage === page;
- const standingAvailable = () =>
- (standings != undefined && standings != null && standings.length > 0) ==
- true;
- const checkPosition = () => {
- if (
- result == undefined ||
- result.statistics == undefined ||
- result.statistics.position == undefined ||
- result.statistics.position == "N/A"
- )
- return false;
- return true;
- };
- const PassFailRemark = () => {
- if (
- result == undefined ||
- result.statistics == undefined ||
- result.statistics.grade == undefined ||
- result.statistics.grade == "fail"
- )
- return "আপনি অনুত্তীর্ণ হয়েছেন";
- else return "আপনি উত্তীর্ণ হয়েছেন";
- };
- const passFailBorderColor = () => {
- if (
- result == undefined ||
- result.statistics == undefined ||
- result.statistics.grade == undefined ||
- result.statistics.grade == "fail"
- )
- return { border: "2px solid red" };
- return {};
- };
- const PassOrFaillImage = () => {
- if (
- result == undefined ||
- result.statistics == undefined ||
- result.statistics.grade == undefined ||
- result.statistics.grade == "fail"
- )
- return <img className={classes.passFailImageSize} src={crossResult} alt=''></img>;
- return <img style={classes.passFailImageSize} src={trophy} alt=''></img>;
- };
- if(result!==undefined && result.exam_data!==undefined && result.exam_data.total_marks!=undefined )
- {
- total_marks = result.exam_data.total_marks;
- }
- else if(result!=undefined && result.total_marks!=undefined)
- {
- total_marks = result.total_marks;
- }
- // console.log('final ',result,result!==undefined, result.exam_data,result.exam_data.statistics);
- if(from==RESPONSE && result!==undefined && result.exam_data!==undefined && result.exam_data.statistics!=undefined )
- {
- passed_examinees = result.exam_data.statistics.passed_examinees;
- total_examinees = result.exam_data.statistics.total_examinees;
- if(result.exam_data.statistics.cut_mark!=undefined)
- cut_mark = result.exam_data.statistics.cut_mark.toFixed(1);
- }
- if(result!==undefined && result.exam_data!==undefined)
- {
- title = result.exam_data.title;
- }
- if(result!==undefined && currentQuestion!==undefined)
- {
- total_questions = currentQuestion.length;
- console.log(total_questions)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement