diff --git a/src/Navbar/Navbar.css b/src/Navbar/Navbar.css index 668c179..47ca867 100644 --- a/src/Navbar/Navbar.css +++ b/src/Navbar/Navbar.css @@ -194,4 +194,11 @@ cursor: pointer; background-color: #4caf4f62; border-color: #4caf4f62; + } + + .question-description + { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } \ No newline at end of file diff --git a/src/Navbar/Navbar.jsx b/src/Navbar/Navbar.jsx index 565c82d..35318d9 100644 --- a/src/Navbar/Navbar.jsx +++ b/src/Navbar/Navbar.jsx @@ -14,6 +14,7 @@ const Navbar = () => { const [timeLeft, setTimeLeft] = useState(0); const [studentDetails, setStudentDetails] = useState({ fullName: "", rollNumber: "" }); const paperId = localStorage.getItem("paperId"); + const [questionList, setQuestionList] = useState([]); const studentId = localStorage.getItem("studentId"); const { questionId } = useParams(); // Extract questionId from the URL @@ -35,6 +36,7 @@ const Navbar = () => { try { const response = await axios.post('http://localhost:5000/paper/getReadyPaperDetailsByPaperId', { paperId }); const paper = response.data[0]; + // console.log(paper); const endTime = new Date(paper.endTime); const currentTime = new Date(); const remainingTime = Math.floor((endTime - currentTime) / 1000); @@ -44,6 +46,19 @@ const Navbar = () => { } }; + const fetchQuestionDetails = async () => { + try { + let response = await axios.post('http://localhost:5000/student/getQuestionByPaperId', { paperId }); + + let sortedQuestions = response.data.questions.sort((a, b) => a.marks - b.marks); + + setQuestionList(sortedQuestions); + } catch (error) { + console.error("Error fetching question details:", error); + } + }; + + // Fetch student details using studentId const fetchStudentDetails = async () => { try { @@ -73,13 +88,13 @@ const Navbar = () => { useEffect(() => { fetchPaperDetails(); fetchStudentDetails(); - + fetchQuestionDetails(); const countdown = setInterval(() => { setTimeLeft((prevTime) => (prevTime > 0 ? prevTime - 1 : 0)); }, 1000); return () => clearInterval(countdown); - }, []); + },[]); return ( <> @@ -121,9 +136,24 @@ const Navbar = () => {
+ {question.questionDescription} +
+