From 9f797a211bf18481ffd626f20654d70dce509c77 Mon Sep 17 00:00:00 2001
From: Sam
Date: Mon, 2 Mar 2026 19:32:52 +0100
Subject: [PATCH] add JSON import button and legacy import functionality
---
backend/templates/leerkracht.html | 42 ++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/backend/templates/leerkracht.html b/backend/templates/leerkracht.html
index 04563fb..8444d1b 100644
--- a/backend/templates/leerkracht.html
+++ b/backend/templates/leerkracht.html
@@ -250,6 +250,10 @@
β Wijzigen
+
+
Uitloggen
@@ -342,7 +346,7 @@
-
+
@@ -672,6 +676,42 @@ function showNotification(msg, type='success') {
el.className = `notification ${type} show`;
setTimeout(() => el.classList.remove('show'), 3000);
}
+
+// ββ Legacy JSON import (uit vorige standalone versie) ββββββββββββββββββββββββ
+async function importLegacyJson(file) {
+ if (!file) return;
+ let data;
+ try {
+ data = JSON.parse(await file.text());
+ } catch(e) {
+ showNotification('Ongeldig JSON bestand', 'error'); return;
+ }
+
+ if (!data.vakken) { showNotification('Geen vakken gevonden in dit bestand', 'error'); return; }
+
+ showNotification('Bezig met importeren...', 'info');
+
+ try {
+ const res = await fetch('/api/assessments/bulk-import', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ vakken: data.vakken })
+ });
+ const result = await res.json();
+ if (!res.ok) { showNotification(result.error || 'Import mislukt', 'error'); return; }
+
+ showNotification(
+ `Import klaar: ${result.totaal} beoordelingen geΓ―mporteerd` +
+ (result.fouten > 0 ? `, ${result.fouten} fouten` : ''),
+ result.fouten > 0 ? 'warning' : 'success'
+ );
+ if (currentVakId) await loadAssessments(currentVakId);
+ updateStats();
+ } catch(e) {
+ showNotification('Netwerkfout tijdens import', 'error');
+ }
+}
+