diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index c585223d1..ae9d7e1ca 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -1332,17 +1332,6 @@ def groups_auto_repartition(partition: Partition): ), ] - H = [ - f"""
Semestre {formsemestre.titre_annee()}
-Les groupes existants seront effacés et remplacés par - ceux créés ici. La répartition aléatoire tente d'uniformiser le niveau - des groupes (en utilisant la dernière moyenne générale disponible pour - chaque étudiant) et de maximiser la mixité de chaque groupe. -
- """, - ] - tf = TrivialFormulator( request.base_url, scu.get_request_args(), @@ -1354,58 +1343,59 @@ def groups_auto_repartition(partition: Partition): ) if tf[0] == 0: return render_template( - "sco_page.j2", - title="Répartition des groupes", - content="\n".join(H) + "\n" + tf[1], + "formsemestre/groups_auto_repartition.j2", + title="Répartition dans des groupes", + form_html=tf[1], + partition=partition, sco=ScoData(formsemestre=formsemestre), ) - elif tf[0] == -1: + if tf[0] == -1: return flask.redirect(dest_url) - else: - # form submission - log(f"groups_auto_repartition({partition})") - group_names = tf[2]["groupNames"] - group_names = sorted({x.strip() for x in group_names.split(",")}) - # Détruit les groupes existant de cette partition - for group in partition.groups: - db.session.delete(group) - db.session.commit() - # Crée les nouveaux groupes - groups = [] - for group_name in group_names: - if group_name.strip(): - groups.append(partition.create_group(group_name)) - # - nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) - identdict = nt.identdict - # build: { civilite : liste etudids trie par niveau croissant } - civilites = {x["civilite"] for x in identdict.values()} - listes = {} + + # form submission + log(f"groups_auto_repartition({partition})") + group_names = tf[2]["groupNames"] + group_names = sorted({x.strip() for x in group_names.split(",")}) + # Détruit les groupes existant de cette partition + for group in partition.groups: + db.session.delete(group) + db.session.commit() + # Crée les nouveaux groupes + groups = [] + for group_name in group_names: + if group_name.strip(): + groups.append(partition.create_group(group_name)) + # + nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) + identdict = nt.identdict + # build: { civilite : liste etudids trie par niveau croissant } + civilites = {x["civilite"] for x in identdict.values()} + listes = {} + for civilite in civilites: + listes[civilite] = [ + (_get_prev_moy(x["etudid"], formsemestre.id), x["etudid"]) + for x in identdict.values() + if x["civilite"] == civilite + ] + listes[civilite].sort() + log("listes[%s] = %s" % (civilite, listes[civilite])) + # affect aux groupes: + n = len(identdict) + igroup = 0 + nbgroups = len(groups) + while n > 0: + log(f"n={n}") for civilite in civilites: - listes[civilite] = [ - (_get_prev_moy(x["etudid"], formsemestre.id), x["etudid"]) - for x in identdict.values() - if x["civilite"] == civilite - ] - listes[civilite].sort() - log("listes[%s] = %s" % (civilite, listes[civilite])) - # affect aux groupes: - n = len(identdict) - igroup = 0 - nbgroups = len(groups) - while n > 0: - log(f"n={n}") - for civilite in civilites: - log(f"civilite={civilite}") - if len(listes[civilite]): - n -= 1 - etudid = listes[civilite].pop()[1] - group = groups[igroup] - igroup = (igroup + 1) % nbgroups - log(f"in {etudid} in group {group.id}") - change_etud_group_in_partition(etudid, group) - log(f"{etudid} in group {group.id}") - return flask.redirect(dest_url) + log(f"civilite={civilite}") + if len(listes[civilite]): + n -= 1 + etudid = listes[civilite].pop()[1] + group = groups[igroup] + igroup = (igroup + 1) % nbgroups + log(f"in {etudid} in group {group.id}") + change_etud_group_in_partition(etudid, group) + log(f"{etudid} in group {group.id}") + return flask.redirect(dest_url) def _get_prev_moy(etudid: int, formsemestre_id: int) -> float | str: diff --git a/app/static/css/partition_editor.css b/app/static/css/partition_editor.css index 00bbb2483..90e895bea 100644 --- a/app/static/css/partition_editor.css +++ b/app/static/css/partition_editor.css @@ -309,7 +309,7 @@ body.editionActivated .filtres>div>div>div>div { display: none; } -#zonePartitions span.editing a { +#zonePartitions span.editing a { text-decoration: none; } @@ -400,7 +400,7 @@ body.editionActivated .filtres .nonEditable .move { /*****************************/ /* Zone Etudiants */ /*****************************/ -#zoneChoix summary{ +#zoneChoix summary { margin: 0 0 16px; cursor: pointer; } @@ -450,6 +450,7 @@ body.editionActivated .filtres .nonEditable .move { margin-bottom: 4px; width: fit-content; } + #zoneChoix .autoAffectation .progress { position: absolute; top: 100%; @@ -524,7 +525,8 @@ body.editionActivated .filtres .nonEditable .move { } #zoneChoix .etudiants .partition>div, -#zoneChoix .etudiants .partition span { +#zoneChoix .etudiants .partition span, +div.partition-name { display: block; padding: 4px 8px; border: 1px solid #aaa; @@ -541,12 +543,22 @@ body.editionActivated .filtres .nonEditable .move { color: #fff; } -#zoneChoix .etudiants .partition>:nth-child(1) { +#zoneChoix .etudiants .partition>:nth-child(1), +div.partition-name { background: #09c; border-color: #09c; color: #fff; } +div.partition-name { + display: inline-block; + width: fit-content; +} + +div.partition-name a { + color: #fff !important; +} + section:not(#zonePartitions) .hide { display: none !important; } diff --git a/app/templates/formsemestre/groups_auto_repartition.j2 b/app/templates/formsemestre/groups_auto_repartition.j2 new file mode 100644 index 000000000..34a799b92 --- /dev/null +++ b/app/templates/formsemestre/groups_auto_repartition.j2 @@ -0,0 +1,30 @@ +{# Formulaire répartition auto dans les groupes #} + +{% extends "sco_page.j2" %} + +{% block app_content %} + +