forked from ScoDoc/ScoDoc
Améliore formsemestre_list_saisies_notes
This commit is contained in:
parent
6cd28853bc
commit
d98eb7dc6b
@ -180,7 +180,28 @@ def evaluation_list_operations(evaluation_id: int):
|
||||
return tab.make_page()
|
||||
|
||||
|
||||
def formsemestre_list_saisies_notes(formsemestre_id, only_modifs=False, fmt="html"):
|
||||
def formsemestre_list_notes_intervenants(formsemestre: FormSemestre) -> list[User]:
|
||||
"Liste des comptes ayant saisi au moins une note dans le semestre"
|
||||
q1 = (
|
||||
User.query.join(NotesNotes)
|
||||
.join(Evaluation)
|
||||
.join(ModuleImpl)
|
||||
.filter_by(formsemestre_id=formsemestre.id)
|
||||
.distinct()
|
||||
)
|
||||
q2 = (
|
||||
User.query.join(NotesNotesLog)
|
||||
.join(Evaluation, Evaluation.id == NotesNotesLog.evaluation_id)
|
||||
.join(ModuleImpl)
|
||||
.filter_by(formsemestre_id=formsemestre.id)
|
||||
.distinct()
|
||||
)
|
||||
return sorted(q1.union(q2).all(), key=lambda x: x.sort_key())
|
||||
|
||||
|
||||
def formsemestre_list_saisies_notes(
|
||||
formsemestre_id, only_modifs=False, user_name: str | None = None, fmt="html"
|
||||
):
|
||||
"""Table listant toutes les opérations de saisies de notes, dans toutes
|
||||
les évaluations du semestre.
|
||||
"""
|
||||
@ -194,52 +215,67 @@ def formsemestre_list_saisies_notes(formsemestre_id, only_modifs=False, fmt="htm
|
||||
.filter_by(formsemestre_id=formsemestre.id)
|
||||
.order_by(model.date.desc())
|
||||
)
|
||||
|
||||
if user_name:
|
||||
user = db.session.query(User).filter_by(user_name=user_name).first()
|
||||
if user:
|
||||
notes_query = notes_query.join(User).filter(model.uid == user.id)
|
||||
# Formate les notes
|
||||
keep_numeric = fmt in scu.FORMATS_NUMERIQUES
|
||||
rows = []
|
||||
for note in notes_query:
|
||||
ens = User.get_user(note.uid)
|
||||
evaluation = note.evaluation
|
||||
rows.append(
|
||||
{
|
||||
"date": note.date.strftime(scu.DATEATIME_FMT),
|
||||
"_date_order": note.date.isoformat(),
|
||||
"code_nip": note.etudiant.code_nip,
|
||||
"nom": note.etudiant.nom_disp(),
|
||||
"prenom": note.etudiant.prenom_str,
|
||||
"date_evaluation": (
|
||||
evaluation.date_debut.strftime(scu.DATEATIME_FMT)
|
||||
if evaluation and note.evaluation.date_debut
|
||||
else ""
|
||||
),
|
||||
"_date_evaluation_order": (
|
||||
note.evaluation.date_debut.isoformat()
|
||||
if evaluation and note.evaluation.date_debut
|
||||
else ""
|
||||
),
|
||||
"value": scu.fmt_note(note.value, keep_numeric=keep_numeric),
|
||||
"module": (
|
||||
(
|
||||
note.evaluation.moduleimpl.module.code
|
||||
or note.evaluation.moduleimpl.module.titre
|
||||
)
|
||||
if evaluation
|
||||
else ""
|
||||
),
|
||||
"evaluation": note.evaluation.description if evaluation else "",
|
||||
"_evaluation_target": (
|
||||
url_for(
|
||||
"notes.evaluation_listenotes",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
evaluation_id=note.evaluation_id,
|
||||
)
|
||||
if evaluation
|
||||
else ""
|
||||
),
|
||||
"user_name": ens.user_name if ens else "",
|
||||
}
|
||||
)
|
||||
row = {
|
||||
"date": note.date.strftime(scu.DATEATIME_FMT),
|
||||
"_date_order": note.date.isoformat(),
|
||||
"code_nip": note.etudiant.code_nip,
|
||||
"nom": note.etudiant.nom_disp(),
|
||||
"prenom": note.etudiant.prenom_str,
|
||||
"date_evaluation": (
|
||||
evaluation.date_debut.strftime(scu.DATEATIME_FMT)
|
||||
if evaluation and note.evaluation.date_debut
|
||||
else ""
|
||||
),
|
||||
"_date_evaluation_order": (
|
||||
note.evaluation.date_debut.isoformat()
|
||||
if evaluation and note.evaluation.date_debut
|
||||
else ""
|
||||
),
|
||||
"value": scu.fmt_note(note.value, keep_numeric=keep_numeric),
|
||||
"module": (
|
||||
(
|
||||
note.evaluation.moduleimpl.module.code
|
||||
or note.evaluation.moduleimpl.module.titre
|
||||
)
|
||||
if evaluation
|
||||
else ""
|
||||
),
|
||||
"evaluation": note.evaluation.description if evaluation else "",
|
||||
"_evaluation_target": (
|
||||
url_for(
|
||||
"notes.evaluation_listenotes",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
evaluation_id=note.evaluation_id,
|
||||
)
|
||||
if evaluation
|
||||
else ""
|
||||
),
|
||||
"user_name": ens.user_name if ens else "",
|
||||
}
|
||||
|
||||
if only_modifs:
|
||||
# si c'est une modif de note, ajoute une colonne avec la nouvelle valeur
|
||||
new = NotesNotes.query.filter_by(
|
||||
evaluation_id=note.evaluation_id, etudid=note.etudid
|
||||
).first()
|
||||
if new:
|
||||
row["new_value"] = scu.fmt_note(new.value, keep_numeric=keep_numeric)
|
||||
row["old_date"] = row["date"]
|
||||
row["_old_date_order"] = row["_date_order"]
|
||||
row["date"] = new.date.strftime(scu.DATEATIME_FMT)
|
||||
row["_date_order"] = new.date.isoformat()
|
||||
|
||||
rows.append(row)
|
||||
|
||||
columns_ids = (
|
||||
"date",
|
||||
@ -247,6 +283,13 @@ def formsemestre_list_saisies_notes(formsemestre_id, only_modifs=False, fmt="htm
|
||||
"nom",
|
||||
"prenom",
|
||||
"value",
|
||||
)
|
||||
if only_modifs:
|
||||
columns_ids += (
|
||||
"new_value",
|
||||
"old_date",
|
||||
)
|
||||
columns_ids += (
|
||||
"user_name",
|
||||
"module",
|
||||
"evaluation",
|
||||
@ -257,7 +300,8 @@ def formsemestre_list_saisies_notes(formsemestre_id, only_modifs=False, fmt="htm
|
||||
"code_nip": "NIP",
|
||||
"nom": "nom",
|
||||
"prenom": "prenom",
|
||||
"date": "Date",
|
||||
"date": "Date modif." if only_modifs else "Date saisie",
|
||||
"old_date": "Date saisie précédente",
|
||||
"value": "Note",
|
||||
"comment": "Remarque",
|
||||
"user_name": "Enseignant",
|
||||
@ -266,6 +310,9 @@ def formsemestre_list_saisies_notes(formsemestre_id, only_modifs=False, fmt="htm
|
||||
"evaluation": "Evaluation",
|
||||
"date_evaluation": "Date éval.",
|
||||
}
|
||||
if only_modifs:
|
||||
titles["value"] = "Ancienne note"
|
||||
titles["new_value"] = "Nouvelle note"
|
||||
table = GenTable(
|
||||
titles=titles,
|
||||
columns_ids=columns_ids,
|
||||
@ -277,13 +324,17 @@ def formsemestre_list_saisies_notes(formsemestre_id, only_modifs=False, fmt="htm
|
||||
caption=f"Saisies de notes dans {formsemestre.titre_annee()}",
|
||||
preferences=sco_preferences.SemPreferences(formsemestre_id),
|
||||
base_url=f"""{request.base_url}?formsemestre_id={
|
||||
formsemestre_id}&only_modifs={int(only_modifs)}""",
|
||||
formsemestre_id}&only_modifs={int(only_modifs)}"""
|
||||
+ (f"&user_name={user_name}" if user_name else ""),
|
||||
origin=f"Généré par {sco_version.SCONAME} le " + scu.timedate_human_repr() + "",
|
||||
table_id="formsemestre_list_saisies_notes",
|
||||
filename=(
|
||||
f"modifs_notes_S{formsemestre.semestre_id}"
|
||||
if only_modifs
|
||||
else f"saisies_notes_S{formsemestre.semestre_id}"
|
||||
(
|
||||
f"modifs_notes-S{formsemestre.semestre_id}"
|
||||
if only_modifs
|
||||
else f"saisies_notes_S{formsemestre.semestre_id}"
|
||||
)
|
||||
+ ("-" + user_name if user_name else "")
|
||||
),
|
||||
)
|
||||
if fmt == "html":
|
||||
@ -293,6 +344,8 @@ def formsemestre_list_saisies_notes(formsemestre_id, only_modifs=False, fmt="htm
|
||||
title="Opérations de saisies de notes",
|
||||
only_modifs=only_modifs,
|
||||
formsemestre_id=formsemestre.id,
|
||||
intervenants=formsemestre_list_notes_intervenants(formsemestre),
|
||||
user_name=user_name,
|
||||
)
|
||||
return table.make_page(fmt=fmt, page_title="Opérations de saisies de notes")
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% block styles %}
|
||||
{{super()}}
|
||||
<style>
|
||||
.export_xls_but {
|
||||
.h-spaced {
|
||||
margin-left: 32px;
|
||||
}
|
||||
</style>
|
||||
@ -22,7 +22,19 @@
|
||||
{% if only_modifs %}checked{% endif %}>
|
||||
Lister uniquement les modifications
|
||||
</label>
|
||||
<span class="export_xls_but">{{table.xls_export_button()|safe}} excel</span>
|
||||
|
||||
<label class="h-spaced" for="user-select">Restreindre à un enseignant :</label>
|
||||
<select id="user-select" name="user_name">
|
||||
<option value="">Choisir...</option>
|
||||
{% for user in intervenants %}
|
||||
<option value="{{ user.user_name }}"
|
||||
{% if user.user_name == user_name %}selected{% endif %}>
|
||||
{{ user.get_nomplogin() }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<span class="h-spaced">{{table.xls_export_button()|safe}} excel</span>
|
||||
</form>
|
||||
|
||||
{{table.html()|safe}}
|
||||
@ -44,5 +56,16 @@
|
||||
|
||||
window.location.href = url.toString();
|
||||
});
|
||||
|
||||
document.getElementById('user-select').addEventListener('change', function() {
|
||||
var form = document.getElementById('filter-form');
|
||||
var userName = this.value;
|
||||
|
||||
var url = new URL(window.location.href);
|
||||
url.searchParams.set('formsemestre_id', {{formsemestre_id}});
|
||||
url.searchParams.set('user_name', userName);
|
||||
|
||||
window.location.href = url.toString();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
@ -3,7 +3,7 @@
|
||||
|
||||
"Infos sur version ScoDoc"
|
||||
|
||||
SCOVERSION = "9.7.40"
|
||||
SCOVERSION = "9.7.41"
|
||||
|
||||
SCONAME = "ScoDoc"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user