-
Notifications
You must be signed in to change notification settings - Fork 14
Non-Container Grading Path #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { Request, Response, NextFunction } from 'express' | ||
|
|
||
| import GraderService from './grader.service' | ||
|
|
||
| import { GenericResponse, NotFound } from '../../utils/apiResponse.utils' | ||
|
|
||
| import { serialize } from '../grader/grader.serializer' | ||
|
|
||
| export async function grade(req: Request, res: Response, next: NextFunction) { | ||
| try { | ||
| const submissionId = parseInt(req.params.id) | ||
| const grade = await GraderService.grade(submissionId) | ||
| if (!grade || grade.length === 0) return res.status(404).json(NotFound) | ||
|
|
||
| const response = serialize(grade) | ||
|
|
||
| res.status(200).json(response) | ||
| } catch (err) { | ||
| res.status(400).json(new GenericResponse(err.message)) | ||
| } | ||
| } | ||
|
|
||
| export default { grade } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Libraries | ||
| import express from 'express' | ||
|
|
||
| // Middleware | ||
| //import validator from './grader.validator' | ||
| import { asInt } from '../../middleware/validator/generic.validator' | ||
|
|
||
| // Controller | ||
| import GraderController from './grader.controller' | ||
|
|
||
| const Router = express.Router() | ||
|
|
||
| /** | ||
| * @swagger | ||
| * tags: | ||
| * - name: Grader | ||
| * description: | ||
| * /grade/{id}: | ||
| * post: | ||
| * summary: Grade a submission, currently only with non-container autograders | ||
| * tags: | ||
| * - Grader | ||
| * responses: | ||
| * '200': | ||
| * description: OK | ||
| * parameters: | ||
| * - name: id | ||
| * in: path | ||
| * required: true | ||
| * schema: | ||
| * type: integer | ||
| */ | ||
| Router.post('/:id', asInt(), GraderController.grade) | ||
|
|
||
| export default Router | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { SubmissionScore, SubmissionProblemScore, GraderInfo } from 'devu-shared-modules' | ||
|
|
||
| export function serialize(scores: any[]): GraderInfo { | ||
| const submissionScore = scores.pop() | ||
| return { | ||
| submissionScore: submissionScore as SubmissionScore, | ||
| submissionProblemScores: scores as SubmissionProblemScore[] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -Needs further discussion- I don't like this at all. If I'm reading things right, your pushing the submission score as the first element of the array and the rest of the array is the problem scores. This needs to be cleaner and clearer. SubmissionScore and SubmissionProblemScore already have serializers. If anyone wants those values, they should hit the existing endpoints and use that logic. The real question is, what should the grading endpoint return? Should it return anything besides an ACK?.. Grading will take a while when we start using containers. The best thing might be to immediately return something like "got your request and we're starting grading" |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should make it clear the the id is a submission id