feat(*): Add mocked grading process

This commit is contained in:
Josh Creek
2025-04-16 22:52:41 +01:00
parent eba66d5a99
commit 6fb6b04432
2 changed files with 50 additions and 7 deletions
+25 -7
View File
@@ -33,15 +33,33 @@ async function handleSubmit(event: Event) {
successMsg = '';
errorMsg = '';
// TODO - Actually do an upload, remove simulation of a successful upload
await new Promise((resolve) => setTimeout(resolve, 800));
if (file || textInput.trim().length > 0) {
successMsg = 'Submission received! AI assessment coming soon.';
} else {
errorMsg = 'Please provide a file or enter text.';
const formData = new FormData();
if (file) {
formData.append('file', file);
} else if (textInput.trim().length > 0) {
formData.append('text', textInput.trim());
}
try {
const response = await fetch('/api/grade', {
method: 'POST',
body: formData
});
const result = await response.json();
if (response.ok && result.success) {
successMsg = result.feedback;
file = null;
textInput = '';
} else {
errorMsg = result.error || 'An error occurred.';
}
} catch (err) {
errorMsg = 'Network or server error.';
} finally {
submitting = false;
}
submitting = false;
}
</script>
<section class="max-w-xl mx-auto py-12">