mirror of
https://github.com/jcreek/AutomatedAssessmentFeedbackAgent.git
synced 2026-07-13 02:53:49 +00:00
feat(*): Require adding a description of the task when uploading
This commit is contained in:
@@ -3,6 +3,7 @@ import { onMount } from 'svelte';
|
||||
|
||||
let file: File | null = null;
|
||||
let textInput = '';
|
||||
let taskDescription = '';
|
||||
let submitting = false;
|
||||
let successMsg = '';
|
||||
let errorMsg = '';
|
||||
@@ -33,7 +34,13 @@ async function handleSubmit(event: Event) {
|
||||
successMsg = '';
|
||||
errorMsg = '';
|
||||
|
||||
if (!taskDescription.trim()) {
|
||||
errorMsg = 'Please provide a description of the task or assignment.';
|
||||
submitting = false;
|
||||
return;
|
||||
}
|
||||
const formData = new FormData();
|
||||
formData.append('task', taskDescription.trim());
|
||||
if (file) {
|
||||
formData.append('file', file);
|
||||
} else if (textInput.trim().length > 0) {
|
||||
@@ -52,6 +59,7 @@ async function handleSubmit(event: Event) {
|
||||
window.location.assign('/results');
|
||||
file = null;
|
||||
textInput = '';
|
||||
taskDescription = '';
|
||||
return;
|
||||
} else {
|
||||
errorMsg = result.error || 'An error occurred.';
|
||||
@@ -68,43 +76,44 @@ async function handleSubmit(event: Event) {
|
||||
<section class="max-w-xl mx-auto py-12">
|
||||
<h1 class="text-2xl font-bold mb-4">Upload Student Submissions</h1>
|
||||
<p class="mb-6">Upload student assignments for instant AI-powered assessment and feedback.</p>
|
||||
<form on:submit|preventDefault={handleSubmit} class="space-y-6">
|
||||
<div>
|
||||
<label for="file" class="block font-semibold mb-1">Upload a file (PDF, DOCX, TXT):</label>
|
||||
<form on:submit|preventDefault={handleSubmit} class="bg-white shadow rounded p-6 max-w-xl mx-auto mt-12">
|
||||
<h1 class="text-2xl font-bold mb-4">Upload Student Submission</h1>
|
||||
<div class="mb-4">
|
||||
<label class="block font-semibold mb-1" for="taskDescription">Task/Assignment Description <span class="text-red-500">*</span></label>
|
||||
<textarea id="taskDescription" rows="3" class="w-full border p-2 rounded" bind:value={taskDescription} required placeholder="Describe the assignment, question, or task the student was responding to..."></textarea>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="block font-semibold mb-1" for="file">Upload a file (PDF, DOCX, TXT):</label>
|
||||
<input
|
||||
id="file"
|
||||
type="file"
|
||||
accept=".pdf,.doc,.docx,.txt"
|
||||
class="block w-full border rounded p-2"
|
||||
class="block w-full border p-2 rounded"
|
||||
on:change={handleFileChange}
|
||||
disabled={submitting}
|
||||
/>
|
||||
<span class="text-gray-500 text-sm">Or paste the student's submission below.</span>
|
||||
</div>
|
||||
<div class="text-center text-gray-500">or</div>
|
||||
<div>
|
||||
<label for="textInput" class="block font-semibold mb-1">Paste assignment text:</label>
|
||||
<div class="mb-4">
|
||||
<label class="block font-semibold mb-1" for="textInput">Paste assignment text:</label>
|
||||
<textarea
|
||||
id="textInput"
|
||||
rows="6"
|
||||
class="block w-full border rounded p-2"
|
||||
rows="5"
|
||||
class="w-full border p-2 rounded"
|
||||
bind:value={textInput}
|
||||
on:input={handleTextChange}
|
||||
disabled={submitting}
|
||||
placeholder="Paste or type student answer here..."
|
||||
></textarea>
|
||||
</div>
|
||||
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700 w-full mt-4" disabled={submitting || (!file && textInput.trim().length === 0)}>
|
||||
{submitting ? 'Uploading...' : 'Submit'}
|
||||
</button>
|
||||
{#if errorMsg}
|
||||
<div class="text-red-600 font-medium">{errorMsg}</div>
|
||||
<div class="mt-4 text-red-600">{errorMsg}</div>
|
||||
{/if}
|
||||
{#if successMsg}
|
||||
<div class="text-green-600 font-medium">{successMsg}</div>
|
||||
<div class="mt-4 text-green-600">{successMsg}</div>
|
||||
{/if}
|
||||
<button
|
||||
class="btn btn-primary mt-4 w-full bg-blue-600 hover:bg-blue-700 text-white font-semibold py-2 px-4 rounded disabled:opacity-60"
|
||||
type="submit"
|
||||
disabled={submitting || (!file && textInput.trim().length === 0)}
|
||||
>
|
||||
{submitting ? 'Uploading...' : 'Upload'}
|
||||
</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user