-
Notifications
You must be signed in to change notification settings - Fork 0
[OA][Fullstack]: 270/assessment test runner #284
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
3dd0118
8ed67dd
3099703
d06a4fa
f3a7091
e2ff822
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import { type NextRequest } from 'next/server'; | ||
| import judge0Connector, { | ||
| formatJudgeResult, | ||
| type JudgeSubmissionRequestBody, | ||
| } from '@/lib/connectors/judge0.connector'; | ||
| import { SubmissionSchema } from '@/lib/schemas/submission.schema'; | ||
| import TaskTemplateService from '@/lib/services/task-template.service'; | ||
| // import { getSession } from '@/lib/utils/auth.utils'; | ||
| import { handleError } from '@/lib/utils/errors.utils'; | ||
| import { mapLanguageToJudge } from '@/lib/utils/language.utils'; | ||
| import { type NextRequest } from 'next/server'; | ||
|
|
||
| export async function POST( | ||
| request: NextRequest, | ||
|
|
@@ -19,20 +19,26 @@ export async function POST( | |
| const languageId = mapLanguageToJudge(parsed.language); | ||
| const taskTemplate = await TaskTemplateService.getTaskTemplate( | ||
| taskTemplateId, | ||
| 'TODO: REPLACE THIS LATER LAITH WITH COOKIE' | ||
| 'org_nextlab_001' // lmk if we want this to stay as the TODO | ||
|
Collaborator
Author
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. Did you see this boss?
Collaborator
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. Yes! Let's keep it this way for now. I fear this requires a bit more brain power then I can provide before showcase |
||
| ); | ||
| const tests = [...taskTemplate.privateTestCases, ...taskTemplate.publicTestCases]; | ||
| const tests = [...taskTemplate.publicTestCases, ...taskTemplate.privateTestCases]; | ||
| const formatted: JudgeSubmissionRequestBody[] = tests.map((test) => ({ | ||
| source_code: parsed.code, | ||
| language_id: languageId, | ||
| stdin: test.input, | ||
| expected_output: test.output, | ||
| // NOTE(laith): we're replacing newline characters to actual newline characters to | ||
| // display on the client that newline characters indicate the next parameter | ||
| stdin: test.input.replace(/\\n/g, '\n'), | ||
| // NOTE(laith): print() and console.log() auto append a newline character, so it would | ||
| // double append, this removes it and the judge0Connector will normalize it for us | ||
| expected_output: test.output.endsWith('\n') ? test.output : `${test.output}\n`, | ||
| })); | ||
|
|
||
| const result = await judge0Connector.executeSubmissions(formatted); | ||
| const formattedResults = result.map(formatJudgeResult); | ||
|
|
||
| return Response.json({ | ||
| data: result, | ||
| status: 200, | ||
| data: formattedResults, | ||
| status: 201, | ||
| }); | ||
| } catch (err) { | ||
| return handleError(err); | ||
|
|
||
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.
Are we still saving the code with updateCode somewhere? We should be making sure that this is the case.
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.
wait disregard this I didnt realize it was the edit page