-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from TanishqMehrunkarIIPSDAVV/completed-student
Completed student
- Loading branch information
Showing
4 changed files
with
257 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
src/CompletedPaperStudentDashboard/CompletedPaperStudentDashboard.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import "../papers/papers.css"; | ||
import Nothing from "../Assets/nothing.svg"; | ||
import Navbar from "../Navbar/Navbar"; | ||
import Skeleton from "../Skeleton/Skeleton"; | ||
import axios from "axios"; | ||
import { useParams } from "react-router-dom"; | ||
import { GoDotFill } from "react-icons/go"; | ||
import { FaCheck } from "react-icons/fa"; | ||
import { ImCross } from "react-icons/im"; | ||
import image from "../Assets/profile_photo.png"; | ||
|
||
const CompletedPaperStudentDashboard = () => { | ||
const [students, setStudents] = useState([]); | ||
const [loading, setLoading] = useState(true); | ||
const { paperId } = useParams(); | ||
const evaluations = ["Evaluated", "Not-Evaluated", "Evaluation-in-Progress"]; | ||
const [studentIds, setStudentIds] = useState([]); | ||
|
||
useEffect(() => { | ||
axios | ||
.post("http://localhost:5000/student/getStudentByPaperId", { | ||
paperId, | ||
}) | ||
.then((res) => { | ||
setStudents(res.data.students); | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}) | ||
.finally(() => { | ||
setTimeout(() => { | ||
setLoading(false); | ||
}, 1000); | ||
}); | ||
|
||
axios | ||
.post("http://localhost:5000/paper/getCompletedPaperByPaperId",{ | ||
paperId, | ||
}) | ||
.then((res) => { | ||
setStudentIds(res.data.students); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
}, [paperId]); | ||
|
||
const getAttemptionStatus = (studentId) => { | ||
return studentIds.indexOf(studentId) === -1 ? "Not-Attempted" : "Attempted"; | ||
}; | ||
|
||
return ( | ||
<> | ||
<Navbar /> | ||
<div className="exam-list-container"> | ||
{loading ? ( | ||
<Skeleton exams={students} /> | ||
) : students.length > 0 ? ( | ||
<> | ||
<div className="header"> | ||
<h2>Students:</h2> | ||
</div> | ||
<div className="exam-table"> | ||
{students.map((student, index) => { | ||
const attemption = getAttemptionStatus(student._id); | ||
return ( | ||
<div className="papers_table" key={index}> | ||
<div className="table-data completed-student"> | ||
<div className="evaluation-attemption"> | ||
<div className={`evaluation ${evaluations[index%3]}`}> | ||
<GoDotFill /> | ||
<div>{evaluations[index%3]} {evaluations[index%3] === "Evaluated" && <>Alloted Marks: 20</>}</div> | ||
</div> | ||
<div className={`attemption ${attemption}`}> | ||
{attemption === "Attempted" ? ( | ||
<> | ||
<FaCheck /> | ||
<div>Attempted</div> | ||
</> | ||
) : ( | ||
<> | ||
<ImCross /> | ||
<div>Not Attempted</div> | ||
</> | ||
)} | ||
</div> | ||
</div> | ||
<div className="student-image-name"> | ||
<div className="student-image"> | ||
<img src={image} alt="Image" /> | ||
</div> | ||
<div className="student-name"> | ||
<div className="classhead">{student.fullName}</div> | ||
<div className="subname"> | ||
Email: {student.email} | ||
</div> | ||
<div className="subname">{student.rollNumber}</div> | ||
<div className="subname">{student.phoneNumber}</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</> | ||
) : ( | ||
<div className="no-questions-container"> | ||
<center> | ||
<img alt="Nothing" src={Nothing} className="nothing" /> | ||
<h2>No Students Found</h2> | ||
</center> | ||
</div> | ||
)} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default CompletedPaperStudentDashboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters