From 1d07266c8ac65d32e33ab1f2b48efaeb19609b34 Mon Sep 17 00:00:00 2001
From: Abdallah Toumji <abdallah.toumji.etu@univ-lille.fr>
Date: Sun, 2 Mar 2025 17:29:44 +0100
Subject: [PATCH] Ticket 1018: Linked the js to the page to allow the user to
 import note

---
 app/static/js/saisie_notes.js | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/app/static/js/saisie_notes.js b/app/static/js/saisie_notes.js
index b040a9f01..f7e591648 100644
--- a/app/static/js/saisie_notes.js
+++ b/app/static/js/saisie_notes.js
@@ -56,6 +56,28 @@ function valid_note(e) {
 
 let isSaving = false; // true si requĂȘte en cours
 
+// Ticket 1018: Change the stored evaluation data when the user selects a different evaluation to import
+let selectedImportEvaluationData = {};
+function set_import_eval(e, data) {
+	const eval = data[e.value];
+	selectedImportEvaluationData = eval;
+}
+
+// Ticket 1018: Import the selected evaluation data into the form thus importing the notes
+function valid_import() {
+	console.log('valid_import', selectedImportEvaluationData);
+
+	let noteInputs = document.querySelectorAll('#formnotes .note');
+	noteInputs.forEach(function (input) {
+		const etudid = parseInt(input.getAttribute('data-etudid'));
+		const note = selectedImportEvaluationData[etudid];
+		if (note) {
+			// trigger the event listener
+			input.value = note;
+		}
+	});
+}
+
 async function save_note(elem, v, etudid) {
   let evaluation_id = document.querySelector("#formnotes_evaluation_id").getAttribute("value");
   let formsemestre_id = document.querySelector("#formnotes_formsemestre_id").getAttribute("value");
-- 
GitLab