-
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.
- Loading branch information
1 parent
16e2dc8
commit 654b156
Showing
3 changed files
with
222 additions
and
90 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
130 changes: 130 additions & 0 deletions
130
src/CompletedPaperDashboard/CompletedPaperDashboard.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,130 @@ | ||
|
||
import React, { useState, useEffect } from "react"; | ||
import "../papers/papers.css"; | ||
// import { useNavigate } from "react-router-dom"; | ||
import axios from "axios"; | ||
import Nothing from "../Assets/nothing.svg"; | ||
import Navbar from "../Navbar/Navbar"; | ||
import Skeleton from "../Skeleton/Skeleton"; | ||
// import AlertModal from "../AlertModal/AlertModal"; | ||
|
||
const CompletedPaperDashboard = () => { | ||
// const navigate = useNavigate(); | ||
const [completedPapers, setCompletedPapers] = useState([]); | ||
// const [hoveredItem, setHoveredItem] = useState(null); | ||
const [loading, setLoading] = useState(true); | ||
|
||
const teacherId = localStorage.getItem("teacherId"); | ||
// const [reload, setReload] = useState(false); | ||
// const [modalMessage, setModalMessage] = useState(""); | ||
// const [isError, setIsError] = useState(false); | ||
// const [modalIsOpen, setModalIsOpen] = useState(false); | ||
|
||
const getFormattedDateTime = (date, time) => { | ||
if (!date || !time) { | ||
return "Invalid Date or Time"; // Or handle it however you want | ||
} | ||
|
||
const [hours, minutes] = time.split(":").map(Number); | ||
const dateTime = new Date(date); | ||
dateTime.setHours(hours, minutes); | ||
|
||
return dateTime.toLocaleString("en-US", { | ||
year: "numeric", | ||
month: "long", | ||
day: "numeric", | ||
hour: "numeric", | ||
minute: "numeric", | ||
hour12: true, | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
const fetchCompletedPapers = async () => { | ||
try { | ||
const response = await axios.post( | ||
`http://localhost:5000/paper/getCompletedPapersByTeacherId`, | ||
{ teacherId } | ||
); | ||
setCompletedPapers(response.data); | ||
} catch (error) { | ||
console.error("Error fetching completed papers:", error); | ||
} finally { | ||
setTimeout(() => { | ||
setLoading(false); | ||
}, 1000); | ||
} | ||
}; | ||
|
||
fetchCompletedPapers(); | ||
}, [teacherId]); | ||
|
||
// const handleCardClick = (paperId) => { | ||
// navigate(`/completed_questions/${paperId}`); | ||
// }; | ||
|
||
return ( | ||
<> | ||
<Navbar /> | ||
<div className="exam-list-container"> | ||
{loading ? ( | ||
<Skeleton exams={completedPapers} /> | ||
) : completedPapers.length > 0 ? ( | ||
<> | ||
<div className="header"> | ||
<h2>Completed Papers:</h2> | ||
</div> | ||
<center> | ||
<p className="readyDasboardwarning"> | ||
The papers displayed here are completed and have been processed. You can view the details of each paper by clicking on them. | ||
</p> | ||
</center> | ||
<div className="exam-table"> | ||
{completedPapers.map((paper, index) => ( | ||
<div | ||
className="papers_table" | ||
key={index} | ||
// onClick={() => handleCardClick(paper._id)} | ||
// onMouseEnter={() => setHoveredItem(paper._id)} | ||
// onMouseLeave={() => setHoveredItem(null)} | ||
> | ||
{/* Since delete and move features are removed, no buttons are shown */} | ||
<div className="scheduled"> | ||
Completed on: {getFormattedDateTime(paper.endTime, paper.time)} | ||
</div> | ||
<div className="table-data"> | ||
<div className="classhead"> | ||
{paper.className} {paper.semester} | ||
</div> | ||
<div className="subname"> | ||
{paper.subject} ({paper.subjectCode}) | ||
</div> | ||
<div> | ||
Duration: {paper.duration.hours} hours {paper.duration.minutes} mins | ||
</div> | ||
<div>Marks: {paper.marks}</div> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</> | ||
) : ( | ||
<div className="no-questions-container"> | ||
<center> | ||
<img alt="Nothing" src={Nothing} className="nothing" /> | ||
<h2>No Completed Papers Found</h2> | ||
</center> | ||
</div> | ||
)} | ||
</div> | ||
{/* <AlertModal | ||
isOpen={modalIsOpen} | ||
onClose={() => setModalIsOpen(false)} | ||
message={modalMessage} | ||
iserror={isError} | ||
/> */} | ||
</> | ||
); | ||
}; | ||
|
||
export default CompletedPaperDashboard; |
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 |
---|---|---|
@@ -1,90 +1,90 @@ | ||
import React, { useRef, useEffect, useState } from "react"; | ||
import PropTypes from "prop-types"; | ||
import "./Editor.css"; | ||
import { Editor as Ed } from "@monaco-editor/react"; | ||
import { FaCode} from "react-icons/fa"; | ||
import Modal from "react-modal"; // Import Modal component | ||
|
||
Modal.setAppElement("#root"); // Set the root element for accessibility | ||
|
||
const Editor = ({ question }) => { | ||
const editorContainerRef = useRef(null); | ||
const editorRef = useRef(null); | ||
const [input, setInput] = useState(""); | ||
const [isModalOpen, setIsModalOpen] = useState(false); // State for modal visibility | ||
|
||
const handleEditorDidMount = (editor) => { | ||
editorRef.current = editor; | ||
editor.layout(); | ||
}; | ||
|
||
useEffect(() => { | ||
const observer = new ResizeObserver(() => { | ||
if (editorRef.current) { | ||
editorRef.current.layout(); | ||
} | ||
}); | ||
|
||
if (editorContainerRef.current) { | ||
observer.observe(editorContainerRef.current); | ||
} | ||
|
||
return () => { | ||
if (editorContainerRef.current) { | ||
observer.unobserve(editorContainerRef.current); | ||
} | ||
observer.disconnect(); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div className="compiler-editor"> | ||
<div className="editor-header"> | ||
<div className="editor-code"> | ||
<FaCode /> | ||
<div>Code</div> | ||
</div> | ||
</div> | ||
<div className="editor-editor" ref={editorContainerRef}> | ||
<Ed | ||
theme="vs-dark" | ||
defaultLanguage={question?.compilerReq} | ||
defaultValue="// Write Code Here" | ||
className="editor-monaco" | ||
onMount={handleEditorDidMount} | ||
/> | ||
</div> | ||
|
||
{/* Modal for input prompt */} | ||
<Modal | ||
isOpen={isModalOpen} | ||
onRequestClose={() => setIsModalOpen(false)} | ||
contentLabel="Input Modal" | ||
className="modal" | ||
overlayClassName="modal-overlay" | ||
> | ||
<div className="modal-content"> | ||
<h2>Input Required</h2> | ||
<label>Enter Input:</label> | ||
<input | ||
type="text" | ||
value={input} | ||
onChange={(e) => setInput(e.target.value)} | ||
/> | ||
<button>Submit</button> | ||
</div> | ||
</Modal> | ||
</div> | ||
); | ||
}; | ||
|
||
Editor.propTypes = { | ||
question: PropTypes.shape({ | ||
compilerReq: PropTypes.string.isRequired, | ||
description: PropTypes.string.isRequired, | ||
image: PropTypes.string, | ||
}), | ||
onOutput: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default Editor; | ||
import React, { useRef, useEffect, useState } from "react"; | ||
import PropTypes from "prop-types"; | ||
import "./Editor.css"; | ||
import { Editor as Ed } from "@monaco-editor/react"; | ||
import { FaCode} from "react-icons/fa"; | ||
import Modal from "react-modal"; // Import Modal component | ||
|
||
Modal.setAppElement("#root"); // Set the root element for accessibility | ||
|
||
const Editor = ({ question }) => { | ||
const editorContainerRef = useRef(null); | ||
const editorRef = useRef(null); | ||
const [input, setInput] = useState(""); | ||
const [isModalOpen, setIsModalOpen] = useState(false); // State for modal visibility | ||
|
||
const handleEditorDidMount = (editor) => { | ||
editorRef.current = editor; | ||
editor.layout(); | ||
}; | ||
|
||
useEffect(() => { | ||
const observer = new ResizeObserver(() => { | ||
if (editorRef.current) { | ||
editorRef.current.layout(); | ||
} | ||
}); | ||
|
||
if (editorContainerRef.current) { | ||
observer.observe(editorContainerRef.current); | ||
} | ||
|
||
return () => { | ||
if (editorContainerRef.current) { | ||
observer.unobserve(editorContainerRef.current); | ||
} | ||
observer.disconnect(); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div className="compiler-editor"> | ||
<div className="editor-header"> | ||
<div className="editor-code"> | ||
<FaCode /> | ||
<div>Code</div> | ||
</div> | ||
</div> | ||
<div className="editor-editor" ref={editorContainerRef}> | ||
<Ed | ||
theme="vs-dark" | ||
defaultLanguage={question?.compilerReq} | ||
defaultValue="// Write Code Here" | ||
className="editor-monaco" | ||
onMount={handleEditorDidMount} | ||
/> | ||
</div> | ||
|
||
{/* Modal for input prompt */} | ||
<Modal | ||
isOpen={isModalOpen} | ||
onRequestClose={() => setIsModalOpen(false)} | ||
contentLabel="Input Modal" | ||
className="modal" | ||
overlayClassName="modal-overlay" | ||
> | ||
<div className="modal-content"> | ||
<h2>Input Required</h2> | ||
<label>Enter Input:</label> | ||
<input | ||
type="text" | ||
value={input} | ||
onChange={(e) => setInput(e.target.value)} | ||
/> | ||
<button>Submit</button> | ||
</div> | ||
</Modal> | ||
</div> | ||
); | ||
}; | ||
|
||
Editor.propTypes = { | ||
question: PropTypes.shape({ | ||
compilerReq: PropTypes.string.isRequired, | ||
description: PropTypes.string.isRequired, | ||
image: PropTypes.string, | ||
}), | ||
onOutput: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default Editor; |