diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index cb13fccd03290819e1237e73a920b2bf3237c2f9..bc5a7c4e45c092b723015ece7acc1cde7a7043ec 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -997,6 +997,63 @@ def _form_saisie_notes( method="GET", ) H.append(tf.getform()) # check and init + + + # Ticket 1018: Import notes from another evaluation + # Add a select element to import notes from another evaluation + # On selection change, the notes will be imported + formsemestre = FormSemestre.get_formsemestre(formsemestre_id) + evaluations = formsemestre.get_evaluations() + rows = {} + # Create a dictionary with the notes of each evaluation for each student + for e in evaluations: + notes = sco_evaluation_db.do_evaluation_get_all_notes(e.id) + for id, note in notes.items(): + if e.id not in rows: + rows[e.id] = {} + rows[e.id][id] = note['value'] + + if len(evaluations) > 1: + H.append( + f'<select data-etudid="{etudid}" class="note_noteImporteur" onchange="set_import_eval(this, {rows})">' + ) + # Add the default option "Sélectionner une évaluation à importer" + H.append('<option value="x" disabled selected>Sélectionner une évaluation à importer</option>') + + for i in evaluations: + # Skip the current evaluation + if i.id == evaluation.id: + continue + + # Add the others evaluations + H.append(f'<option value="{i.id}">{"todo titre module"} - {i.description}</option>') + + H.append('</select>') + + H.append("""<script> + window.onload = function() { + // Get the select element + const selectElement = document.querySelector('.note_noteImporteur'); + + // Reset the selection to the default option + if (selectElement) { + selectElement.value = ""; // This will select the "Sélectionner une évaluation à importer" option + } + } + </script> + """) + H.append( + f"""<button class="btn btn-primary" onclick="valid_import()" id="import_notes">Importer les notes</button>""" + ) + else: + # Span if there is only one evaluation + H.append('<span class="noteImporteur">') + envir = "span" + item = "span" + + H.append("</br>") + H.append("</br>") + H.append( f"""<a href="{url_for("notes.moduleimpl_status", scodoc_dept=g.scodoc_dept, moduleimpl_id=modimpl.id)