-
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 #24 from TanishqMehrunkarIIPSDAVV/Zakie-ka-kaam
test
- Loading branch information
Showing
6 changed files
with
154 additions
and
111 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
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
128 changes: 128 additions & 0 deletions
128
src/ReadyQuestionPaperDashboard/ReadyQuestionPaperDashboard.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,128 @@ | ||
import React from 'react' | ||
import "../QuestionPaperDashboard/QuestionPaperDashboard.css"; | ||
import Navbar from '../Navbar/Navbar'; | ||
import { useParams } from "react-router-dom"; | ||
import axios from "axios"; | ||
import Nothing from "../Assets/nothing.svg"; | ||
import AlertModal from '../AlertModal/AlertModal'; | ||
import { useState,useEffect } from 'react'; | ||
|
||
const ReadyQuestionPaperDashboard = () => { | ||
|
||
// const navigate = useNavigate(); | ||
const { paperId } = useParams(); | ||
const [questions, setQuestions] = useState([]); | ||
const [loading, setLoading] = useState(true); | ||
const [paperdetails,setpaperdetails]=useState([]); | ||
|
||
// State for the modal | ||
const [modalIsOpen, setModalIsOpen] = useState(false); | ||
|
||
useEffect(() => { | ||
const fetchQuestions = async () => { | ||
try { | ||
const res = await axios.post( | ||
"http://localhost:5000/paper/getReadyQuestionPapersByTeacherId", | ||
{ paperId } | ||
); | ||
setQuestions(res.data); | ||
} catch (error) { | ||
console.error("Failed to fetch questions:", error); | ||
|
||
|
||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
const fetchpaperdetails = async () => { | ||
try { | ||
const res = await axios.post( | ||
"http://localhost:5000/paper/getReadyPaperDetailsByPaperId", | ||
{ paperId } | ||
); | ||
setpaperdetails(res.data[0]); | ||
} catch (error) { | ||
console.error("Failed to fetch paperdetails:", error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
fetchpaperdetails(); | ||
fetchQuestions(); | ||
}, [paperId]); | ||
console.log(paperdetails); | ||
if (loading) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
return ( | ||
<> | ||
<Navbar /> | ||
|
||
<div className="question-list-container"> | ||
{questions.length > 0 ? | ||
(<> | ||
<div className="question-header"> | ||
<div className='ready-question-display-flex'> | ||
<h2 className="question-subject"> | ||
{paperdetails.className} {paperdetails.semester} ({paperdetails.subject}) | ||
</h2> | ||
<h2>Total Marks: {paperdetails.marks}</h2> | ||
</div> | ||
</div> | ||
<div className="question-table"> | ||
{questions.map((question) => ( | ||
<div className="questions-table" key={question._id} | ||
> | ||
<div className="question-table-data"> | ||
<div className="compiler"> | ||
Compiler: {question.compilerReq} | ||
</div> | ||
<div className="marks">Marks: {question.marks}</div> | ||
<div className="heading-description"> | ||
<h3 className="question_paper_h3"> | ||
{question.questionheading} | ||
</h3> | ||
<div className="description"> | ||
{question.questionDescription} | ||
</div> | ||
</div> | ||
{question.image ? ( | ||
<div className="question-image"> | ||
<img src={question.image} alt="question" /> | ||
</div> | ||
) : ( | ||
<></> | ||
)} | ||
</div> | ||
</div> | ||
))} | ||
|
||
<center> | ||
<button | ||
className="question_submit-button" | ||
> | ||
Submit | ||
</button> | ||
</center> | ||
</div> | ||
</>) : (<> | ||
<div className="no-questions-container"> | ||
<center> | ||
<img alt="Nothing" src={Nothing} className="nothing" /> | ||
<h2>No Ready Questions Found</h2> | ||
</center> | ||
</div> | ||
</>)} | ||
</div> | ||
|
||
{/* Alert Modal */} | ||
< AlertModal | ||
isOpen={modalIsOpen} | ||
onClose={() => setModalIsOpen(false)} | ||
/> | ||
</> | ||
) | ||
} | ||
|
||
export default ReadyQuestionPaperDashboard |
This file was deleted.
Oops, something went wrong.