Skip to content

Commit

Permalink
Merge pull request #24 from TanishqMehrunkarIIPSDAVV/Zakie-ka-kaam
Browse files Browse the repository at this point in the history
test
  • Loading branch information
nishant0708 authored Sep 9, 2024
2 parents 6077b60 + 3fb1027 commit 2cda46f
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 111 deletions.
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Question from './question/question';
import QuestionPaperDashboard from './QuestionPaperDashboard/QuestionPaperDashboard';
import Editpaper from './Edit_paper/Editpaper';
import ReadyPaperDashboard from './ReadyPaperDashboard/ReadyPaperDashboard';
import ReadyQuestionPaperDashboard from './ReadyQuestionPaperDashboard/ReadyQuestionPaperDashboard';

import Error404 from './error/error404';
import EditQuestion from './Edit_question/edit_question';
Expand Down Expand Up @@ -72,6 +73,7 @@ const App = () => {
<Route path="/edit-question/:paperId/:questionId" element={<EditQuestion/>} />
<Route path="/questionPaperDashboard/:paperId" element={<QuestionPaperDashboard />}/>
<Route path="/ready_papers" element={<ReadyPaperDashboard />}/>
<Route path="/ready_questions/:paperId" element={<ReadyQuestionPaperDashboard />} />
</>
)}

Expand Down
25 changes: 23 additions & 2 deletions src/QuestionPaperDashboard/QuestionPaperDashboard.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

.question-list-container
{
width: 100%;
Expand Down Expand Up @@ -138,9 +137,16 @@
width: 200px;
height: 50px;
border-radius: 5px;
background-color: #45a049;
color: white;
border:1px solid rgb(0, 0, 0);
font-size: 18px;
}
.question_submit-button:hover
{
background-color: #45a04970;
cursor: pointer;
}
@media(max-width : 1000px)
{
.description
Expand Down Expand Up @@ -177,4 +183,19 @@ font-size: 18px;
.error_message_questionDashboard{
text-align: center;
color: red;
}
}

/* ------------------------------------------------------ready question ----------------------------------*/

.ready-question-display-flex
{
display: flex;
justify-content: space-between;
width: 100%;
align-items: center;
}
.ready-question-display-flex:first-child
{
margin-right: 20px;
}

1 change: 0 additions & 1 deletion src/QuestionPaperDashboard/QuestionPaperDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ const QuestionPaperDashboard = () => {
{totalMarks === paperdetails.marks && (
<button
className="question_submit-button"
style={{ backgroundColor: "green", color: "white" }}
onClick={handleSubmit}
>
Submit
Expand Down
2 changes: 1 addition & 1 deletion src/ReadyPaperDashboard/ReadyPaperDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const ReadyPaperDashboard = () => {
}, [teacherId]);

const handleCardClick = (paperId) => {
navigate(`/questionPaperDashboard/${paperId}`);
navigate(`/ready_questions/${paperId}`);
};

return (
Expand Down
128 changes: 128 additions & 0 deletions src/ReadyQuestionPaperDashboard/ReadyQuestionPaperDashboard.jsx
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
107 changes: 0 additions & 107 deletions src/edit_question/edit_question.jsx

This file was deleted.

0 comments on commit 2cda46f

Please sign in to comment.