mirror of
https://github.com/jcreek/AutomatedAssessmentFeedbackAgent.git
synced 2026-07-14 11:33:48 +00:00
feat(*): Enable displaying history using localstorage
This commit is contained in:
@@ -1,13 +1,31 @@
|
||||
<script lang="ts">
|
||||
import AssessmentFeedback from '$lib/components/AssessmentFeedback.svelte';
|
||||
import AssessmentHistory from '$lib/components/AssessmentHistory.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let feedback: any = null;
|
||||
let history: any[] = [];
|
||||
|
||||
function saveToHistory(entry: any) {
|
||||
let prev = [];
|
||||
try {
|
||||
prev = JSON.parse(localStorage.getItem('assessmentHistory') || '[]');
|
||||
} catch {}
|
||||
prev.unshift(entry); // latest first
|
||||
localStorage.setItem('assessmentHistory', JSON.stringify(prev.slice(0, 50)));
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
// For hackathon simplicity, get feedback from history state
|
||||
if (window.history.state && window.history.state.feedback) {
|
||||
feedback = window.history.state.feedback;
|
||||
try {
|
||||
history = JSON.parse(localStorage.getItem('assessmentHistory') || '[]');
|
||||
if (history && history.length > 0) {
|
||||
feedback = history[0]; // Show latest as most prominent feedback
|
||||
} else {
|
||||
feedback = null;
|
||||
}
|
||||
} catch {
|
||||
history = [];
|
||||
feedback = null;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -17,7 +35,9 @@ onMount(() => {
|
||||
<p class="mb-6">View detailed feedback and recommendations for each student submission.</p>
|
||||
{#if feedback}
|
||||
<AssessmentFeedback {...feedback} />
|
||||
{:else}
|
||||
{/if}
|
||||
{#if !feedback && (!history || history.length === 0)}
|
||||
<div class="border rounded p-6 text-gray-500">No results yet. Upload submissions to see feedback here.</div>
|
||||
{/if}
|
||||
<AssessmentHistory {history} hideIfEmpty={true} />
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user