Skip to content

Commit

Permalink
added enddate check and disable handin check
Browse files Browse the repository at this point in the history
  • Loading branch information
RA341 committed Oct 26, 2024
1 parent 3e4811a commit 802d83b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions devU-api/src/entities/assignment/assignment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export async function isReleased(id: number) {
return startDate && startDate < currentDate
}

async function getMaxSubmissionsForAssignment(id: number) {
return await connect().findOne({ where: { id: id, deletedAt: IsNull() }, select: ['maxSubmissions', 'maxFileSize'] })
async function getMaxSubmissionsAndDeadline(id: number) {
return await connect().findOne({ where: { id: id, deletedAt: IsNull() }, select: ['maxSubmissions', 'maxFileSize', 'disableHandins', 'endDate'] })
}

async function processFiles(req: Request) {
Expand Down Expand Up @@ -120,6 +120,6 @@ export default {
listByCourse,
listByCourseReleased,
isReleased,
getMaxSubmissionsForAssignment,
getMaxSubmissionsForAssignment: getMaxSubmissionsAndDeadline,
processFiles,
}
17 changes: 17 additions & 0 deletions devU-api/src/entities/submission/submission.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import SubmissionService from './submission.service'
import AssignmentService from '../assignment/assignment.service'

// TODO discuss how to bypass this when an instructor wants to eg bypass for a specific student
// checks number of submissions and checks if the assignment is beyond the deadline
async function checkSubmissions(req: Request, res: Response, next: NextFunction) {
const userID = req.currentUser?.userId
const assignmentId = req.body.assignmentId
Expand All @@ -18,6 +19,22 @@ async function checkSubmissions(req: Request, res: Response, next: NextFunction)

if (assignmentInfo == null) return res.status(403).send('could not retrieve assignment info')

if (assignmentInfo!.disableHandins) {
// console.debug('Handins are now disabled')
return res.status(403).json({ 'Error': 'Handins are now disabled for this assignment' })
}

const currentTime = new Date()

if (assignmentInfo!.endDate < currentTime) {
// console.debug('Submission after enddate')
return res.status(403).json({
'Error': 'Submission after end date',
'endDate': assignmentInfo!.endDate,
'currentTime': currentTime,
})
}

if (assignmentInfo!.maxSubmissions == null) {
console.debug('Max submissions are not specified, skipping check')
// check file size
Expand Down

0 comments on commit 802d83b

Please sign in to comment.