Skip to content

Commit

Permalink
Merge pull request #197 from makeopensource/158Disable-the-submission…
Browse files Browse the repository at this point in the history
…s-button-after-the-due-date-for-an-assignment-has-passed

removing the submit button from assignments that are past the due date
  • Loading branch information
yessicaq authored Dec 3, 2024
2 parents 4c0d852 + ad02c8d commit 696325a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const AssignmentDetailPage = () => {

} catch (err:any) {
setError(err)
const message = Array.isArray(err) ? err.map((e) => `${e.param} ${e.msg}`).join(', ') : err.message
const message = "Submission past due date"//Array.isArray(err) ? err.map((e) => `${e.param} ${e.msg}`).join(', ') : err.message
setAlert({autoDelete: false, type: 'error', message})
} finally {
setLoading(false)
Expand Down Expand Up @@ -146,6 +146,14 @@ const AssignmentDetailPage = () => {
await fetchData()
}
}
const isSubmissionDisabled = () => {
if (assignment?.dueDate) {
const dueDate = new Date(assignment.dueDate);
const now = new Date();
return now > dueDate;
}
return false;
};


return(
Expand All @@ -172,7 +180,7 @@ const AssignmentDetailPage = () => {
<hr className = {styles.line} />
{role.isInstructor() && <button className={styles.buttons} onClick={() => {
history.push(`/course/${courseId}/assignment/${assignmentId}/createProblem`)
}}>Add Problem</button>}
}}>Add Assignment Question</button>}
<hr className = {styles.line} />
{role.isInstructor() && <button className={styles.buttons} onClick={() => {
history.push(`/course/${courseId}/assignment/${assignmentId}/update`)
Expand Down Expand Up @@ -223,11 +231,16 @@ const AssignmentDetailPage = () => {
</div>
)}

{!(assignment?.disableHandins) && (<input type="file" className={styles.fileInput} onChange={handleFileChange} />)}
{!(assignment?.disableHandins) && (<input type="file"
className={styles.fileInput}
onChange={handleFileChange} />)}

{assignmentProblems && assignmentProblems.length > 0 ? (


{ !(isSubmissionDisabled()) &&assignmentProblems && assignmentProblems.length > 0 ? (
<div className = {styles.submit_container}>
<button className={styles.buttons} onClick={handleSubmit}>Submit</button>
<button className={styles.buttons} onClick={handleSubmit}
>Submit</button>
</div>
) : null}
</div>
Expand Down
4 changes: 2 additions & 2 deletions devU-client/src/components/pages/courses/courseDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ const CourseDetailPage = () => {
<div>

<div className={styles.header}>
<h1>CSE{courseInfo.number}: {courseInfo.name} ({courseInfo.semester})</h1>
<h2> Instructor: </h2>
<h1>{courseInfo.number}: {courseInfo.name} ({courseInfo.semester})</h1>
<h2> Section: </h2>


<div style={{display: 'flex', flexWrap:'wrap', justifyContent: 'space-between'}}>
Expand Down

0 comments on commit 696325a

Please sign in to comment.