From ad4b5a135e767828d53fe2d4940ad5f4710003d7 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 11 Aug 2021 14:00:39 +0200 Subject: [PATCH] listenotes ok --- app/scodoc/sco_etud.py | 2 +- app/scodoc/sco_formsemestre_edit.py | 6 +++--- app/scodoc/sco_groups.py | 17 ++++++++++++++--- app/scodoc/sco_liste_notes.py | 23 +++++++++++++---------- app/scodoc/sco_placement.py | 4 ++-- app/scodoc/sco_saisie_notes.py | 2 +- 6 files changed, 34 insertions(+), 20 deletions(-) diff --git a/app/scodoc/sco_etud.py b/app/scodoc/sco_etud.py index 51ef7d46..03e9654e 100644 --- a/app/scodoc/sco_etud.py +++ b/app/scodoc/sco_etud.py @@ -634,7 +634,7 @@ def make_etud_args(etudid=None, code_nip=None, REQUEST=None, raise_exc=True): args = {"code_nip": code_nip} elif REQUEST: if "etudid" in REQUEST.form: - args = {"etudid": REQUEST.form["etudid"]} + args = {"etudid": int(REQUEST.form["etudid"])} elif "code_nip" in REQUEST.form: args = {"code_nip": REQUEST.form["code_nip"]} elif "code_ine" in REQUEST.form: diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index 08b1f9a7..49c97c40 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -135,7 +135,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): "Form choix modules / responsables et creation formsemestre" # Fonction accessible à tous, controle acces à la main: if edit: - formsemestre_id = REQUEST.form["formsemestre_id"] + formsemestre_id = int(REQUEST.form["formsemestre_id"]) sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) if not current_user.has_permission(Permission.ScoImplement): if not edit: @@ -154,14 +154,14 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): uid2display[u.id] = u.get_nomplogin() allowed_user_names = list(uid2display.values()) + [""] # - formation_id = REQUEST.form["formation_id"] + formation_id = int(REQUEST.form["formation_id"]) F = sco_formations.formation_list(context, args={"formation_id": formation_id}) if not F: raise ScoValueError("Formation inexistante !") F = F[0] if not edit: initvalues = {"titre": _default_sem_title(F)} - semestre_id = REQUEST.form["semestre_id"] + semestre_id = int(REQUEST.form["semestre_id"]) sem_module_ids = set() else: # setup form init values diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 99eaed33..cfb8b58a 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -1418,7 +1418,10 @@ def do_evaluation_listeetuds_groups( if not groups: return [] # no groups, so no students rg = ["gm.group_id = '%(group_id)s'" % g for g in groups] - rq = "and Isem.etudid = gm.etudid and gd.partition_id = p.partition_id and p.formsemestre_id = Isem.formsemestre_id" + rq = """and Isem.etudid = gm.etudid + and gd.partition_id = p.id + and p.formsemestre_id = Isem.formsemestre_id + """ r = rq + " AND (" + " or ".join(rg) + " )" fromtables += ["group_membership gm", "group_descr gd", "partition p"] else: @@ -1458,7 +1461,15 @@ def do_evaluation_listegroupes(context, evaluation_id, include_default=False): cnx = ndb.GetDBConnexion() cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor.execute( - "SELECT DISTINCT gd.group_id FROM group_descr gd, group_membership gm, partition p, notes_moduleimpl m, notes_evaluation e WHERE gm.group_id = gd.group_id and gd.partition_id = p.partition_id and p.formsemestre_id = m.formsemestre_id and m.moduleimpl_id = e.moduleimpl_id and e.evaluation_id = %(evaluation_id)s" + """SELECT DISTINCT gd.id AS group_id + FROM group_descr gd, group_membership gm, partition p, + notes_moduleimpl m, notes_evaluation e + WHERE gm.group_id = gd.id + and gd.partition_id = p.id + and p.formsemestre_id = m.formsemestre_id + and m.id = e.moduleimpl_id + and e.id = %(evaluation_id)s + """ + c, {"evaluation_id": evaluation_id}, ) @@ -1473,7 +1484,7 @@ def listgroups(context, group_ids): groups = [] for group_id in group_ids: cursor.execute( - """SELECT gd.*, p.* + """SELECT gd.id AS group_id, gd.*, p.id AS partition_id, p.* FROM group_descr gd, partition p WHERE p.id = gd.partition_id AND gd.id = %(group_id)s diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index 0fddd370..e801363e 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -59,15 +59,16 @@ def do_evaluation_listenotes(context, REQUEST): """ Affichage des notes d'une évaluation - args: evaluation_id + args: evaluation_id ou moduleimpl_id + (si moduleimpl_id, affiche toutes les évaluatons du module) """ mode = None if "evaluation_id" in REQUEST.form: - evaluation_id = REQUEST.form["evaluation_id"] + evaluation_id = int(REQUEST.form["evaluation_id"]) mode = "eval" evals = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) if "moduleimpl_id" in REQUEST.form: - moduleimpl_id = REQUEST.form["moduleimpl_id"] + moduleimpl_id = int(REQUEST.form["moduleimpl_id"]) mode = "module" evals = sco_evaluations.do_evaluation_list({"moduleimpl_id": moduleimpl_id}) if not mode: @@ -428,7 +429,7 @@ def _make_table_notes( columns_ids.append("comment") # titres divers: - gl = "".join(["&group_ids%3Alist=" + g for g in group_ids]) + gl = "".join(["&group_ids%3Alist=" + str(g) for g in group_ids]) if note_sur_20: gl = "¬e_sur_20%3Alist=yes" + gl if anonymous_listing: @@ -583,7 +584,7 @@ def _add_eval_columns( val = None if val is None: - row["_" + evaluation_id + "_td_attrs"] = 'class="etudabs" ' + row["_" + str(evaluation_id) + "_td_attrs"] = 'class="etudabs" ' if not row.get("_css_row_class", ""): row["_css_row_class"] = "etudabs" # regroupe les commentaires @@ -599,7 +600,7 @@ def _add_eval_columns( row.update( { evaluation_id: val_fmt, - "_" + evaluation_id + "_help": explanation, + "_" + str(evaluation_id) + "_help": explanation, # si plusieurs evals seront ecrasés et non affichés: "comment": explanation, "expl_key": expl_key, @@ -619,7 +620,9 @@ def _add_eval_columns( if nb_notes > 0: moys[evaluation_id] = "%.3g" % (sum_notes / nb_notes) - moys["_" + evaluation_id + "_help"] = "moyenne sur %d notes (%s le %s)" % ( + moys[ + "_" + str(evaluation_id) + "_help" + ] = "moyenne sur %d notes (%s le %s)" % ( nb_notes, e["description"], e["jour"], @@ -630,11 +633,11 @@ def _add_eval_columns( titles[evaluation_id] = "%(description)s (%(jour)s)" % e if e["eval_state"]["evalcomplete"]: - titles["_" + evaluation_id + "_td_attrs"] = 'class="eval_complete"' + titles["_" + str(evaluation_id) + "_td_attrs"] = 'class="eval_complete"' elif e["eval_state"]["evalattente"]: - titles["_" + evaluation_id + "_td_attrs"] = 'class="eval_attente"' + titles["_" + str(evaluation_id) + "_td_attrs"] = 'class="eval_attente"' else: - titles["_" + evaluation_id + "_td_attrs"] = 'class="eval_incomplete"' + titles["_" + str(evaluation_id) + "_td_attrs"] = 'class="eval_incomplete"' return notes, nb_abs, nb_att # pour histogramme diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index 30705498..409825cc 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -60,7 +60,7 @@ def do_placement_selectetuds(context, REQUEST): """ Choisi les étudiants et les infos sur la salle pour leur placement. """ - evaluation_id = REQUEST.form["evaluation_id"] + evaluation_id = int(REQUEST.form["evaluation_id"]) E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) if not E: raise ScoValueError("invalid evaluation_id") @@ -241,7 +241,7 @@ def do_placement(context, REQUEST): authuser = REQUEST.AUTHENTICATED_USER authusername = str(authuser) try: - evaluation_id = REQUEST.form["evaluation_id"] + evaluation_id = int(REQUEST.form["evaluation_id"]) except: raise ScoValueError( "Formulaire incomplet ! Vous avez sans doute attendu trop longtemps, veuillez vous reconnecter. Si le problème persiste, contacter l'administrateur. Merci." diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index 5af63d65..ecc8e4dd 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -168,7 +168,7 @@ def do_evaluation_upload_xls(context, REQUEST): Soumission d'un fichier XLS (evaluation_id, notefile) """ authuser = REQUEST.AUTHENTICATED_USER - evaluation_id = REQUEST.form["evaluation_id"] + evaluation_id = int(REQUEST.form["evaluation_id"]) comment = REQUEST.form["comment"] E = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})[0] M = sco_moduleimpl.do_moduleimpl_withmodule_list(