Skip to content

Commit

Permalink
(add) problem notes
Browse files Browse the repository at this point in the history
  • Loading branch information
shine00chang committed Nov 26, 2024
1 parent 0c3d023 commit 3b7dab8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/client/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<!-- Library -->
<script>
const src = `http://13.93.218.61:8000`;
//const src = `http://localhost:8000`;
const betterFetch = (url, options, { failable } = {}) =>
fetch(src + url, {
...options,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ <h2>Ranklist</h2>
const getContestId = _ => {let e = document.querySelector('input[name="contest-radio"]:checked'); return e ? e.value : undefined;};

const betterFetch = (url, options) =>
fetch("http://localhost:8000" + url, options)
fetch("http://13.93.218.61:8000" + url, options)
.then(async res => {
if (res.status >= 200 && res.status < 300) {
const contentType = res.headers.get("content-type");
Expand Down
6 changes: 5 additions & 1 deletion packages/client/src/pages/contest.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ <h2>input</h2>
<h2>output</h2>
<div id='outputFormat'></div>

<h2>notes</h2>
<div id='note'></div>

<h2>submission</h2>
<label for="lang">Language:</label>
<select name="lang" id="lang" value="C++17" class='input'>
Expand All @@ -183,7 +186,7 @@ <h2>submission</h2>
// hidden in the box
const makeProblemElement = async (contestId, problemId) =>
{
const { name, context, constraints, inputFormat, outputFormat } =
const { name, context, note, constraints, inputFormat, outputFormat } =
await betterFetch(`/v1/contests/${contestId}/problems/${problemId}`);

const format = s =>
Expand All @@ -207,6 +210,7 @@ <h2>submission</h2>
e.querySelector('#context').innerHTML = format(context);
e.querySelector('#inputFormat').innerHTML = format(inputFormat);
e.querySelector('#outputFormat').innerHTML = format(outputFormat);
e.querySelector('#note').innerHTML = format(note);

// submission
e.querySelector('#submit').onclick = async _ =>
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/types/problem.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ConstraintsSchema } from './judger.types.js'
export const NewProblemSchema = Type.Object({
name: Type.String(),
context: Type.String(),
note: Type.String(),
inputFormat: Type.String(),
outputFormat: Type.String(),
constraints: ConstraintsSchema,
Expand All @@ -25,6 +26,7 @@ export type NewProblem = Static<typeof NewProblemSchema>
export const ProblemSchema = Type.Object({
name: Type.String(),
context: Type.String(),
note: Type.String(),
inputFormat: Type.String(),
outputFormat: Type.String(),
constraints: ConstraintsSchema,
Expand Down
6 changes: 4 additions & 2 deletions packages/upload-server/src/services/polygon.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ export async function uploadPolygon ({ domainId, replaceId, archive }: { domainI
}

// Extract context
const context = statement.legend + '\n\n' + statement.notes
const context = statement.legend;
const note = statement.notes

// Create Problem
const problem: Problem = {
id: replaceId ?? nanoid(),
domainId,
name: statement.name,
context,
note,
inputFormat: statement.input,
outputFormat: statement.output,
samples: [],
Expand Down Expand Up @@ -85,7 +87,7 @@ export async function uploadPolygon ({ domainId, replaceId, archive }: { domainI

// If ID exists, replace problem, else insert problem
// The ID is set to replace ID if it exists. see above
await domainProblemCollection.updateOne({ id: problem.id }, problem, { upsert: true })
await domainProblemCollection.updateOne({ id: problem.id }, { $set: problem }, { upsert: true })

// Compile checker
const checkerSource = (await fs.readFile(path.join(work_path, 'check.cpp'))).toString()
Expand Down
1 change: 0 additions & 1 deletion packages/upload-server/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export async function startUploadServer (): Promise<void> {

await app.register(heartbeatRoutes, { prefix: '/heartbeat' })
await app.register(polygonRoutes, { prefix: '/polygon' })
//await app.register(testcaseRoutes, { prefix: '/testcases' })

try {
const port: number = parseInt(process.env.UPLOAD_SERVER_PORT ?? '8001')
Expand Down

0 comments on commit 3b7dab8

Please sign in to comment.