From 14a4d586b7c7abc86674724153757f15faf7262c Mon Sep 17 00:00:00 2001 From: Daniel Hader Date: Tue, 2 Jun 2026 20:16:04 -0500 Subject: submission logic progress and submission page redirects --- static/main.js | 2 +- static/submit.html | 2 +- static/submit.js | 28 ++++++++++++++++++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) (limited to 'static') diff --git a/static/main.js b/static/main.js index ae997f3..73a4c60 100644 --- a/static/main.js +++ b/static/main.js @@ -37,7 +37,7 @@ function create_problem_element(problem, submissions) { problem_div.appendChild(sub_title); const submission_link = document.createElement("a"); - submission_link.href = "submit.html?problem=10"; + submission_link.href = `submit.html?problem_id=${problem.id}`; submission_link.innerHTML = "submit solution" problem_div.appendChild(submission_link); diff --git a/static/submit.html b/static/submit.html index 79c4f82..393b2e2 100644 --- a/static/submit.html +++ b/static/submit.html @@ -43,7 +43,7 @@


- +

diff --git a/static/submit.js b/static/submit.js index 81e3aa6..03dfd69 100644 --- a/static/submit.js +++ b/static/submit.js @@ -1,12 +1,28 @@ -function submit() { +async function submit() { + const language = document.getElementById("submission-language").value; + const details = document.getElementById("submission-details").value; + const code = document.getElementById("submission-code").value; + const submission = { - user_id: 1, - problem_id: 2, - language: "c++", - details: "blah blah", - code: "blah blah", + problem_id: 2, // TODO validate language and problem id in server + language: language, + details: details, + code: code, }; + + const response = await fetch("/submission", { + method: "post", + headers: { "Content-Type": "application/json" }, + credentials: "include", + body: JSON.stringify(submission) + }); + + console.log(response); + + const result = await response.json(); + + console.log(result); } function init() { -- cgit v1.2.3