WIP: correction requêtes directes (ids)

This commit is contained in:
Emmanuel Viennet 2021-08-08 17:38:46 +02:00
parent 1375c195ca
commit 0e57f6b857
17 changed files with 186 additions and 66 deletions

View File

@ -51,7 +51,7 @@ class NotesUE(db.Model):
nullable=False, nullable=False,
) )
ects = db.Column(db.Float) # nombre de credits ECTS ects = db.Column(db.Float) # nombre de credits ECTS
is_external = db.Column(db.Boolean(), nullable=False, default=False) is_external = db.Column(db.Boolean(), default=False)
# id de l'element pedagogique Apogee correspondant: # id de l'element pedagogique Apogee correspondant:
code_apogee = db.Column(db.String(APO_CODE_STR_LEN)) code_apogee = db.Column(db.String(APO_CODE_STR_LEN))
# coef UE, utilise seulement si l'option use_ue_coefs est activée: # coef UE, utilise seulement si l'option use_ue_coefs est activée:
@ -88,7 +88,7 @@ class NotesModule(db.Model):
heures_td = db.Column(db.Float) heures_td = db.Column(db.Float)
heures_tp = db.Column(db.Float) heures_tp = db.Column(db.Float)
coefficient = db.Column(db.Float) # coef PPN coefficient = db.Column(db.Float) # coef PPN
ue_id = db.Column(db.Integer, db.ForeignKey("notes_ue.id")) ue_id = db.Column(db.Integer, db.ForeignKey("notes_ue.id"), index=True)
formation_id = db.Column(db.Integer, db.ForeignKey("notes_formations.id")) formation_id = db.Column(db.Integer, db.ForeignKey("notes_formations.id"))
matiere_id = db.Column(db.Integer, db.ForeignKey("notes_matieres.id")) matiere_id = db.Column(db.Integer, db.ForeignKey("notes_matieres.id"))
# pas un id mais le numéro du semestre: 1, 2, ... # pas un id mais le numéro du semestre: 1, 2, ...

View File

@ -206,6 +206,7 @@ class NotesModuleImpl(db.Model):
formsemestre_id = db.Column( formsemestre_id = db.Column(
db.Integer, db.Integer,
db.ForeignKey("notes_formsemestre.id"), db.ForeignKey("notes_formsemestre.id"),
index=True,
) )
responsable_id = db.Column("responsable_id", db.Integer, db.ForeignKey("user.id")) responsable_id = db.Column("responsable_id", db.Integer, db.ForeignKey("user.id"))
# formule de calcul moyenne: # formule de calcul moyenne:
@ -232,12 +233,12 @@ class NotesModuleImplInscription(db.Model):
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
moduleimpl_inscription_id = db.synonym("id") moduleimpl_inscription_id = db.synonym("id")
db.Column( moduleimpl_id = db.Column(
"moduleimpl_id",
db.Integer, db.Integer,
db.ForeignKey("notes_moduleimpl.moduleimpl_id"), db.ForeignKey("notes_moduleimpl.id"),
index=True,
) )
etudid = db.Column(db.Integer, db.ForeignKey("identite.id")) etudid = db.Column(db.Integer, db.ForeignKey("identite.id"), index=True)
class NotesEvaluation(db.Model): class NotesEvaluation(db.Model):
@ -247,6 +248,9 @@ class NotesEvaluation(db.Model):
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
evaluation_id = db.synonym("id") evaluation_id = db.synonym("id")
moduleimpl_id = db.Column(
db.Integer, db.ForeignKey("notes_moduleimpl.moduleimpl_id"), index=True
)
jour = db.Column(db.Date) jour = db.Column(db.Date)
heure_debut = db.Column(db.Time) heure_debut = db.Column(db.Time)
heure_fin = db.Column(db.Time) heure_fin = db.Column(db.Time)

View File

@ -20,6 +20,7 @@ class Partition(db.Model):
formsemestre_id = db.Column( formsemestre_id = db.Column(
db.Integer, db.Integer,
db.ForeignKey("notes_formsemestre.id"), db.ForeignKey("notes_formsemestre.id"),
index=True,
) )
# "TD", "TP", ... (NULL for 'all') # "TD", "TP", ... (NULL for 'all')
partition_name = db.Column(db.String(SHORT_STR_LEN)) partition_name = db.Column(db.String(SHORT_STR_LEN))

View File

@ -271,9 +271,11 @@ def retreive_current_formsemestre(context, etudid, cur_date):
"""Get formsemestre dans lequel etudid est (ou était) inscrit a la date indiquée """Get formsemestre dans lequel etudid est (ou était) inscrit a la date indiquée
date est une chaine au format ISO (yyyy-mm-dd) date est une chaine au format ISO (yyyy-mm-dd)
""" """
req = """SELECT i.formsemestre_id FROM notes_formsemestre_inscription i, notes_formsemestre sem req = """SELECT i.formsemestre_id
WHERE sem.formsemestre_id = i.formsemestre_id AND i.etudid=%(etudid)s FROM notes_formsemestre_inscription i, notes_formsemestre sem
AND (%(cur_date)s >= sem.date_debut) AND (%(cur_date)s <= sem.date_fin)""" WHERE sem.id = i.formsemestre_id AND i.etudid = %(etudid)s
AND (%(cur_date)s >= sem.date_debut) AND (%(cur_date)s <= sem.date_fin)
"""
r = ndb.SimpleDictFetch(req, {"etudid": etudid, "cur_date": cur_date}) r = ndb.SimpleDictFetch(req, {"etudid": etudid, "cur_date": cur_date})
if not r: if not r:
@ -284,9 +286,10 @@ def retreive_current_formsemestre(context, etudid, cur_date):
def mod_with_evals_at_date(context, date_abs, etudid): def mod_with_evals_at_date(context, date_abs, etudid):
"""Liste des moduleimpls avec des evaluations a la date indiquée""" """Liste des moduleimpls avec des evaluations à la date indiquée"""
req = """SELECT m.* FROM notes_moduleimpl m, notes_evaluation e, notes_moduleimpl_inscription i req = """SELECT m.id AS moduleimpl_id, m.*
WHERE m.moduleimpl_id = e.moduleimpl_id AND e.moduleimpl_id = i.moduleimpl_id FROM notes_moduleimpl m, notes_evaluation e, notes_moduleimpl_inscription i
WHERE m.id = e.moduleimpl_id AND e.moduleimpl_id = i.moduleimpl_id
AND i.etudid = %(etudid)s AND e.jour = %(date_abs)s""" AND i.etudid = %(etudid)s AND e.jour = %(date_abs)s"""
r = ndb.SimpleDictFetch(req, {"etudid": etudid, "date_abs": date_abs}) r = ndb.SimpleDictFetch(req, {"etudid": etudid, "date_abs": date_abs})
return r return r

View File

@ -93,10 +93,10 @@ def get_etudids_with_debouche(context, start_year):
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT DISTINCT i.etudid """SELECT DISTINCT i.etudid
FROM notes_formsemestre_inscription i, notes_formsemestre s, itemsuivi it FROM notes_formsemestre_inscription i, notes_formsemestre s, itemsuivi it
WHERE i.etudid = it.etudid WHERE i.etudid = it.etudid
AND i.formsemestre_id = s.formsemestre_id AND s.date_fin >= %(start_date)s AND i.formsemestre_id = s.id AND s.date_fin >= %(start_date)s
""", """,
{"start_date": start_date}, {"start_date": start_date},
) )
@ -321,7 +321,7 @@ def itemsuivi_tag_list(context, itemsuivi_id):
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT t.title """SELECT t.title
FROM itemsuivi_tags_assoc a, itemsuivi_tags t FROM itemsuivi_tags_assoc a, itemsuivi_tags t
WHERE a.tag_id = t.tag_id WHERE a.tag_id = t.id
AND a.itemsuivi_id = %(itemsuivi_id)s AND a.itemsuivi_id = %(itemsuivi_id)s
""", """,
{"itemsuivi_id": itemsuivi_id}, {"itemsuivi_id": itemsuivi_id},

View File

@ -320,9 +320,13 @@ def matiere_is_locked(context, matiere_id):
(contains modules used in a locked formsemestre) (contains modules used in a locked formsemestre)
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT ma.* from notes_matieres ma, notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi """SELECT ma.id
WHERE ma.matiere_id = mod.matiere_id AND mi.module_id = mod.module_id AND mi.formsemestre_id = sem.formsemestre_id FROM notes_matieres ma, notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi
AND ma.matiere_id = %(matiere_id)s AND sem.etat = 0 WHERE ma.id = mod.matiere_id
AND mi.module_id = mod.id
AND mi.formsemestre_id = sem.id
AND ma.id = %(matiere_id)s
AND sem.etat = false
""", """,
{"matiere_id": matiere_id}, {"matiere_id": matiere_id},
) )

View File

@ -360,7 +360,12 @@ def module_edit(context, module_id=None, REQUEST=None):
)[0] )[0]
parcours = sco_codes_parcours.get_parcours_from_code(Fo["type_parcours"]) parcours = sco_codes_parcours.get_parcours_from_code(Fo["type_parcours"])
M = ndb.SimpleDictFetch( M = ndb.SimpleDictFetch(
"SELECT ue.acronyme, mat.* FROM notes_matieres mat, notes_ue ue WHERE mat.ue_id = ue.ue_id AND ue.formation_id = %(formation_id)s ORDER BY ue.numero, mat.numero", """SELECT ue.acronyme, mat.*, mat.id AS matiere_id
FROM notes_matieres mat, notes_ue ue
WHERE mat.ue_id = ue.id
AND ue.formation_id = %(formation_id)s
ORDER BY ue.numero, mat.numero
""",
{"formation_id": Mod["formation_id"]}, {"formation_id": Mod["formation_id"]},
) )
Mnames = ["%s / %s" % (x["acronyme"], x["titre"]) for x in M] Mnames = ["%s / %s" % (x["acronyme"], x["titre"]) for x in M]
@ -567,9 +572,12 @@ def module_is_locked(context, module_id):
(used in a locked formsemestre) (used in a locked formsemestre)
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT mi.* from notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi """SELECT mi.id
WHERE mi.module_id = mod.module_id AND mi.formsemestre_id = sem.formsemestre_id FROM notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi
AND mi.module_id = %(module_id)s AND sem.etat = 0 WHERE mi.module_id = mod.id
AND mi.formsemestre_id = sem.id
AND mi.module_id = %(module_id)s
AND sem.etat = false
""", """,
{"module_id": module_id}, {"module_id": module_id},
) )

View File

@ -942,10 +942,11 @@ def ue_is_locked(context, ue_id):
(contains modules used in a locked formsemestre) (contains modules used in a locked formsemestre)
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT ue.* FROM notes_ue ue, notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi """SELECT ue.id
WHERE ue.ue_id = mod.ue_id FROM notes_ue ue, notes_modules mod, notes_formsemestre sem, notes_moduleimpl mi
AND mi.module_id = mod.module_id AND mi.formsemestre_id = sem.formsemestre_id WHERE ue.id = mod.ue_id
AND ue.ue_id = %(ue_id)s AND sem.etat = 0 AND mi.module_id = mod.id AND mi.formsemestre_id = sem.id
AND ue.id = %(ue_id)s AND sem.etat = false
""", """,
{"ue_id": ue_id}, {"ue_id": ue_id},
) )

View File

@ -205,10 +205,13 @@ def _build_results_list(context, dpv_by_sem, etuds_infos):
def get_set_formsemestre_id_dates(context, start_date, end_date): def get_set_formsemestre_id_dates(context, start_date, end_date):
"""Ensemble des formsemestre_id entre ces dates""" """Ensemble des formsemestre_id entre ces dates"""
s = ndb.SimpleDictFetch( s = ndb.SimpleDictFetch(
"SELECT formsemestre_id FROM notes_formsemestre WHERE date_debut >= %(start_date)s AND date_fin <= %(end_date)s", """SELECT id
FROM notes_formsemestre
WHERE date_debut >= %(start_date)s AND date_fin <= %(end_date)s
""",
{"start_date": start_date, "end_date": end_date}, {"start_date": start_date, "end_date": end_date},
) )
return {x["formsemestre_id"] for x in s} return {x["id"] for x in s}
def scodoc_table_results( def scodoc_table_results(

View File

@ -219,7 +219,11 @@ def search_etud_by_name(context, term, REQUEST=None):
else: else:
if may_be_nip: if may_be_nip:
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"SELECT nom, prenom, code_nip FROM identite WHERE code_nip LIKE %(beginning)s ORDER BY nom", """SELECT nom, prenom, code_nip
FROM identite
WHERE code_nip
LIKE %(beginning)s ORDER BY nom
""",
{"beginning": term + "%"}, {"beginning": term + "%"},
) )
data = [ data = [
@ -232,7 +236,11 @@ def search_etud_by_name(context, term, REQUEST=None):
] ]
else: else:
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"SELECT etudid, nom, prenom FROM identite WHERE nom LIKE %(beginning)s ORDER BY nom", """SELECT id AS etudid, nom, prenom
FROM identite
WHERE nom LIKE %(beginning)s
ORDER BY nom
""",
{"beginning": term + "%"}, {"beginning": term + "%"},
) )

View File

@ -277,7 +277,10 @@ def read_formsemestre_responsables(context, formsemestre_id):
:returns: liste de chaines :returns: liste de chaines
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"SELECT responsable_id FROM notes_formsemestre_responsables WHERE formsemestre_id = %(formsemestre_id)s", """SELECT responsable_id
FROM notes_formsemestre_responsables
WHERE formsemestre_id = %(formsemestre_id)s
""",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
return [x["responsable_id"] for x in r] return [x["responsable_id"] for x in r]
@ -339,7 +342,10 @@ def read_formsemestre_etapes(context, formsemestre_id):
:returns: liste d'instance de ApoEtapeVDI :returns: liste d'instance de ApoEtapeVDI
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"SELECT etape_apo FROM notes_formsemestre_etapes WHERE formsemestre_id = %(formsemestre_id)s", """SELECT etape_apo
FROM notes_formsemestre_etapes
WHERE formsemestre_id = %(formsemestre_id)s
""",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
return [ApoEtapeVDI(x["etape_apo"]) for x in r if x["etape_apo"]] return [ApoEtapeVDI(x["etape_apo"]) for x in r if x["etape_apo"]]

View File

@ -1343,7 +1343,10 @@ def formsemestre_has_decisions_or_compensations(context, formsemestre_id):
ou bien compensation de ce semestre par d'autre ssemestres. ou bien compensation de ce semestre par d'autre ssemestres.
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"SELECT v.* FROM scolar_formsemestre_validation v WHERE v.formsemestre_id = %(formsemestre_id)s OR v.compense_formsemestre_id = %(formsemestre_id)s", """SELECT v.id AS formsemestre_validation_id, v.*
FROM scolar_formsemestre_validation v
WHERE v.formsemestre_id = %(formsemestre_id)s
OR v.compense_formsemestre_id = %(formsemestre_id)s""",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
return r return r

View File

@ -1160,15 +1160,15 @@ def do_formsemestre_validate_previous_ue(
def _invalidate_etud_formation_caches(context, etudid, formation_id): def _invalidate_etud_formation_caches(context, etudid, formation_id):
"Invalide tous les semestres de cette formation où l'etudiant est inscrit..." "Invalide tous les semestres de cette formation où l'etudiant est inscrit..."
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT sem.* """SELECT sem.id
FROM notes_formsemestre sem, notes_formsemestre_inscription i FROM notes_formsemestre sem, notes_formsemestre_inscription i
WHERE sem.formation_id = %(formation_id)s WHERE sem.formation_id = %(formation_id)s
AND i.formsemestre_id = sem.formsemestre_id AND i.formsemestre_id = sem.id
AND i.etudid = %(etudid)s AND i.etudid = %(etudid)s
""", """,
{"etudid": etudid, "formation_id": formation_id}, {"etudid": etudid, "formation_id": formation_id},
) )
for fsid in [s["formsemestre_id"] for s in r]: for fsid in [s["id"] for s in r]:
sco_cache.invalidate_formsemestre( sco_cache.invalidate_formsemestre(
formsemestre_id=fsid formsemestre_id=fsid
) # > modif decision UE (inval tous semestres avec cet etudiant, ok mais conservatif) ) # > modif decision UE (inval tous semestres avec cet etudiant, ok mais conservatif)
@ -1177,8 +1177,10 @@ def _invalidate_etud_formation_caches(context, etudid, formation_id):
def get_etud_ue_cap_html(context, etudid, formsemestre_id, ue_id, REQUEST=None): def get_etud_ue_cap_html(context, etudid, formsemestre_id, ue_id, REQUEST=None):
"""Ramene bout de HTML pour pouvoir supprimer une validation de cette UE""" """Ramene bout de HTML pour pouvoir supprimer une validation de cette UE"""
valids = ndb.SimpleDictFetch( valids = ndb.SimpleDictFetch(
"""SELECT SFV.* FROM scolar_formsemestre_validation SFV """SELECT SFV.*
WHERE ue_id=%(ue_id)s AND etudid=%(etudid)s""", FROM scolar_formsemestre_validation SFV
WHERE ue_id=%(ue_id)s
AND etudid=%(etudid)s""",
{"etudid": etudid, "ue_id": ue_id}, {"etudid": etudid, "ue_id": ue_id},
) )
if not valids: if not valids:
@ -1239,12 +1241,13 @@ def check_formation_ues(context, formation_id):
for ue in ues: for ue in ues:
# formsemestres utilisant cette ue ? # formsemestres utilisant cette ue ?
sems = ndb.SimpleDictFetch( sems = ndb.SimpleDictFetch(
"""SELECT DISTINCT sem.* """SELECT DISTINCT sem.id AS formsemestre_id, sem.*
FROM notes_formsemestre sem, notes_modules mod, notes_moduleimpl mi FROM notes_formsemestre sem, notes_modules mod, notes_moduleimpl mi
WHERE sem.formation_id = %(formation_id)s WHERE sem.formation_id = %(formation_id)s
AND mod.module_id = mi.module_id AND mod.id = mi.module_id
AND mi.formsemestre_id = sem.formsemestre_id AND mi.formsemestre_id = sem.id
AND mod.ue_id = %(ue_id)s""", AND mod.ue_id = %(ue_id)s
""",
{"ue_id": ue["ue_id"], "formation_id": formation_id}, {"ue_id": ue["ue_id"], "formation_id": formation_id},
) )
semestre_ids = set([x["semestre_id"] for x in sems]) semestre_ids = set([x["semestre_id"] for x in sems])

View File

@ -98,7 +98,11 @@ group_list = groupEditor.list
def get_group(context, group_id): def get_group(context, group_id):
"""Returns group object, with partition""" """Returns group object, with partition"""
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"SELECT gd.*, p.* FROM group_descr gd, partition p WHERE gd.group_id=%(group_id)s AND p.partition_id = gd.partition_id", """SELECT gd.id AS group_id, gd.*, p.id AS partition_id, p.*
FROM group_descr gd, partition p
WHERE gd.id=%(group_id)s
AND p.id = gd.partition_id
""",
{"group_id": group_id}, {"group_id": group_id},
) )
if not r: if not r:
@ -118,7 +122,10 @@ def group_delete(context, group, force=False):
def get_partition(context, partition_id): def get_partition(context, partition_id):
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"SELECT p.* FROM partition p WHERE p.partition_id = %(partition_id)s", """SELECT p.id AS partition_id, p.*
FROM partition p
WHERE p.id = %(partition_id)s
""",
{"partition_id": partition_id}, {"partition_id": partition_id},
) )
if not r: if not r:
@ -129,7 +136,10 @@ def get_partition(context, partition_id):
def get_partitions_list(context, formsemestre_id, with_default=True): def get_partitions_list(context, formsemestre_id, with_default=True):
"""Liste des partitions pour ce semestre (list of dicts)""" """Liste des partitions pour ce semestre (list of dicts)"""
partitions = ndb.SimpleDictFetch( partitions = ndb.SimpleDictFetch(
"SELECT * FROM partition WHERE formsemestre_id=%(formsemestre_id)s order by numero", """SELECT p.id AS partition_id, p.*
FROM partition p
WHERE formsemestre_id=%(formsemestre_id)s
ORDER BY numero""",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
# Move 'all' at end of list (for menus) # Move 'all' at end of list (for menus)
@ -142,7 +152,10 @@ def get_partitions_list(context, formsemestre_id, with_default=True):
def get_default_partition(context, formsemestre_id): def get_default_partition(context, formsemestre_id):
"""Get partition for 'all' students (this one always exists, with NULL name)""" """Get partition for 'all' students (this one always exists, with NULL name)"""
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"SELECT * FROM partition WHERE formsemestre_id=%(formsemestre_id)s AND partition_name is NULL", """SELECT p.id AS partition_id, p.* FROM partition p
WHERE formsemestre_id=%(formsemestre_id)s
AND partition_name is NULL
""",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
if len(r) != 1: if len(r) != 1:
@ -169,7 +182,12 @@ def get_partition_groups(context, partition):
"""List of groups in this partition (list of dicts). """List of groups in this partition (list of dicts).
Some groups may be empty.""" Some groups may be empty."""
return ndb.SimpleDictFetch( return ndb.SimpleDictFetch(
"SELECT gd.*, p.* FROM group_descr gd, partition p WHERE gd.partition_id=%(partition_id)s AND gd.partition_id=p.partition_id ORDER BY group_name", """SELECT gd.id AS group_id, p.id AS partition_id, gd.*, p.*
FROM group_descr gd, partition p
WHERE gd.partition_id=%(partition_id)s
AND gd.partition_id=p.partition_id
ORDER BY group_name
""",
partition, partition,
) )
@ -178,7 +196,12 @@ def get_default_group(formsemestre_id, fix_if_missing=False):
"""Returns group_id for default ('tous') group""" """Returns group_id for default ('tous') group"""
context = None # #context context = None # #context
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"SELECT gd.group_id FROM group_descr gd, partition p WHERE p.formsemestre_id=%(formsemestre_id)s AND p.partition_name is NULL AND p.partition_id = gd.partition_id", """SELECT gd.id AS group_id
FROM group_descr gd, partition p
WHERE p.formsemestre_id=%(formsemestre_id)s
AND p.partition_name is NULL
AND p.partition_id = gd.partition_id
""",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
if len(r) == 0 and fix_if_missing: if len(r) == 0 and fix_if_missing:
@ -207,7 +230,11 @@ def get_default_group(formsemestre_id, fix_if_missing=False):
def get_sem_groups(context, formsemestre_id): def get_sem_groups(context, formsemestre_id):
"""Returns groups for this sem (in all partitions).""" """Returns groups for this sem (in all partitions)."""
return ndb.SimpleDictFetch( return ndb.SimpleDictFetch(
"SELECT gd.*, p.* FROM group_descr gd, partition p WHERE p.formsemestre_id=%(formsemestre_id)s AND p.partition_id = gd.partition_id", """SELECT gd.id AS group_id, p.id AS partition_id, gd.*, p.*
FROM group_descr gd, partition p
WHERE p.formsemestre_id=%(formsemestre_id)s
AND p.partition_id = gd.partition_id
""",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
@ -217,7 +244,17 @@ def get_group_members(context, group_id, etat=None):
Si etat, filtre selon l'état de l'inscription Si etat, filtre selon l'état de l'inscription
Trié par nom_usuel (ou nom) puis prénom Trié par nom_usuel (ou nom) puis prénom
""" """
req = "SELECT i.*, a.*, gm.*, ins.etat FROM identite i, adresse a, group_membership gm, group_descr gd, partition p, notes_formsemestre_inscription ins WHERE i.etudid = gm.etudid and a.etudid = i.etudid and ins.etudid = i.etudid and ins.formsemestre_id = p.formsemestre_id and p.partition_id = gd.partition_id and gd.group_id = gm.group_id and gm.group_id=%(group_id)s" req = """SELECT i.id as etudid, i.*, a.*, gm.*, ins.etat
FROM identite i, adresse a, group_membership gm,
group_descr gd, partition p, notes_formsemestre_inscription ins
WHERE i.id = gm.etudid
and a.etudid = i.id
and ins.etudid = i.id
and ins.formsemestre_id = p.formsemestre_id
and p.id = gd.partition_id
and gd.id = gm.group_id
and gm.group_id=%(group_id)s
"""
if etat is not None: if etat is not None:
req += " and ins.etat = %(etat)s" req += " and ins.etat = %(etat)s"
@ -316,7 +353,13 @@ def get_etud_groups(context, etudid, sem, exclude_default=False):
"""Infos sur groupes de l'etudiant dans ce semestre """Infos sur groupes de l'etudiant dans ce semestre
[ group + partition_name ] [ group + partition_name ]
""" """
req = "SELECT p.*, g.* from group_descr g, partition p, group_membership gm WHERE gm.etudid=%(etudid)s and gm.group_id = g.group_id and g.partition_id = p.partition_id and p.formsemestre_id = %(formsemestre_id)s" req = """SELECT p.id AS partition_id, p.*, g.id AS group_id, g.*
FROM group_descr g, partition p, group_membership gm
WHERE gm.etudid=%(etudid)s
and gm.group_id = g.id
and g.partition_id = p.id
and p.formsemestre_id = %(formsemestre_id)s
"""
if exclude_default: if exclude_default:
req += " and p.partition_name is not NULL" req += " and p.partition_name is not NULL"
groups = ndb.SimpleDictFetch( groups = ndb.SimpleDictFetch(
@ -347,7 +390,16 @@ def formsemestre_get_etud_groupnames(context, formsemestre_id, attr="group_name"
{ etudid : { partition_id : group_name }} (attr=group_name or group_id) { etudid : { partition_id : group_name }} (attr=group_name or group_id)
""" """
infos = ndb.SimpleDictFetch( infos = ndb.SimpleDictFetch(
"select i.etudid, p.partition_id, gd.group_name, gd.group_id from notes_formsemestre_inscription i, partition p, group_descr gd, group_membership gm where i.formsemestre_id=%(formsemestre_id)s and i.formsemestre_id=p.formsemestre_id and p.partition_id=gd.partition_id and gm.etudid=i.etudid and gm.group_id = gd.group_id and p.partition_name is not NULL", """SELECT i.id AS etudid, p.is AS partition_id, gd.group_name, gd.id AS group_id
FROM notes_formsemestre_inscription i, partition p,
group_descr gd, group_membership gm
WHERE i.formsemestre_id=%(formsemestre_id)s
and i.formsemestre_id=p.formsemestre_id
and p.id=gd.partition_id
and gm.etudid=i.etudid
and gm.group_id = gd.group_id
and p.partition_name is not NULL
""",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
R = {} R = {}
@ -369,7 +421,13 @@ def etud_add_group_infos(context, etud, sem, sep=" "):
return etud return etud
infos = ndb.SimpleDictFetch( infos = ndb.SimpleDictFetch(
"SELECT p.partition_name, g.* from group_descr g, partition p, group_membership gm WHERE gm.etudid=%(etudid)s and gm.group_id = g.group_id and g.partition_id = p.partition_id and p.formsemestre_id = %(formsemestre_id)s ORDER BY p.numero", """SELECT p.partition_name, g.*, g.id AS group_id
FROM group_descr g, partition p, group_membership gm WHERE gm.etudid=%(etudid)s
and gm.group_id = g.id
and g.partition_id = p.id
and p.formsemestre_id = %(formsemestre_id)s
ORDER BY p.numero
""",
{"etudid": etud["etudid"], "formsemestre_id": sem["formsemestre_id"]}, {"etudid": etud["etudid"], "formsemestre_id": sem["formsemestre_id"]},
) )
@ -395,7 +453,11 @@ def etud_add_group_infos(context, etud, sem, sep=" "):
def get_etud_groups_in_partition(context, partition_id): def get_etud_groups_in_partition(context, partition_id):
"""Returns { etudid : group }, with all students in this partition""" """Returns { etudid : group }, with all students in this partition"""
infos = ndb.SimpleDictFetch( infos = ndb.SimpleDictFetch(
"SELECT gd.*, etudid from group_descr gd, group_membership gm where gd.partition_id = %(partition_id)s and gm.group_id = gd.group_id", """SELECT gd.id as group_id, gd.*, etudid
FROM group_descr gd, group_membership gm
WHERE gd.partition_id = %(partition_id)s
AND gm.group_id = gd.group_id
""",
{"partition_id": partition_id}, {"partition_id": partition_id},
) )
R = {} R = {}
@ -1063,7 +1125,10 @@ def partition_set_name(context, partition_id, partition_name, REQUEST=None, redi
# check unicity # check unicity
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"SELECT p.* FROM partition p WHERE p.partition_name = %(partition_name)s AND formsemestre_id = %(formsemestre_id)s", """SELECT p.* FROM partition p
WHERE p.partition_name = %(partition_name)s
AND formsemestre_id = %(formsemestre_id)s
""",
{"partition_name": partition_name, "formsemestre_id": formsemestre_id}, {"partition_name": partition_name, "formsemestre_id": formsemestre_id},
) )
if len(r) > 1 or (len(r) == 1 and r[0]["partition_id"] != partition_id): if len(r) > 1 or (len(r) == 1 and r[0]["partition_id"] != partition_id):

View File

@ -518,14 +518,14 @@ def is_inscrit_ue(context, etudid, formsemestre_id, ue_id):
auxquels l'étudiant est inscrit. auxquels l'étudiant est inscrit.
""" """
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""SELECT mod.* """SELECT mod.id AS module_id, mod.*
FROM notes_moduleimpl mi, notes_modules mod, FROM notes_moduleimpl mi, notes_modules mod,
notes_formsemestre sem, notes_moduleimpl_inscription i notes_formsemestre sem, notes_moduleimpl_inscription i
WHERE sem.formsemestre_id = %(formsemestre_id)s WHERE sem.formsemestre_id = %(formsemestre_id)s
AND mi.formsemestre_id = sem.formsemestre_id AND mi.formsemestre_id = sem.id
AND mod.module_id = mi.module_id AND mod.id = mi.module_id
AND mod.ue_id = %(ue_id)s AND mod.ue_id = %(ue_id)s
AND i.moduleimpl_id = mi.moduleimpl_id AND i.moduleimpl_id = mi.id
AND i.etudid = %(etudid)s AND i.etudid = %(etudid)s
ORDER BY mod.numero ORDER BY mod.numero
""", """,

View File

@ -196,9 +196,9 @@ def get_external_moduleimpl_id(context, formsemestre_id, ue_id):
"moduleimpl correspondant à l'UE externe indiquée de ce formsemestre" "moduleimpl correspondant à l'UE externe indiquée de ce formsemestre"
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
""" """
SELECT moduleimpl_id FROM notes_moduleimpl mi, notes_modules mo SELECT mi.id AS moduleimpl_id FROM notes_moduleimpl mi, notes_modules mo
WHERE mi.formsemestre_id = %(formsemestre_id)s WHERE mi.id = %(formsemestre_id)s
AND mi.module_id = mo.module_id AND mi.module_id = mo.id
AND mo.ue_id = %(ue_id)s AND mo.ue_id = %(ue_id)s
""", """,
{"ue_id": ue_id, "formsemestre_id": formsemestre_id}, {"ue_id": ue_id, "formsemestre_id": formsemestre_id},

View File

@ -173,10 +173,21 @@ def evaluation_list_operations(context, REQUEST, evaluation_id):
def formsemestre_list_saisies_notes( def formsemestre_list_saisies_notes(
context, formsemestre_id, format="html", REQUEST=None context, formsemestre_id, format="html", REQUEST=None
): ):
"""Table listant toutes les operations de saisies de notes, dans toutes les evaluations du semestre.""" """Table listant toutes les opérations de saisies de notes, dans toutes
les évaluations du semestre.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
r = ndb.SimpleDictFetch( r = ndb.SimpleDictFetch(
"""select i.nom, n.*, mod.titre, e.description, e.jour from notes_notes n, notes_evaluation e, notes_moduleimpl m, notes_modules mod, identite i where m.moduleimpl_id = e.moduleimpl_id and m.module_id = mod.module_id and e.evaluation_id=n.evaluation_id and i.etudid=n.etudid and m.formsemestre_id=%(formsemestre_id)s order by date desc""", """SELECT i.nom, n.*, mod.titre, e.description, e.jour
FROM notes_notes n, notes_evaluation e, notes_moduleimpl mi,
notes_modules mod, identite i
WHERE mi.id = e.moduleimpl_id
and m.module_id = mod.id
and e.id=n.evaluation_id
and i.etudid=n.etudid
and mi.formsemestre_id=%(formsemestre_id)s
ORDER BY date desc
""",
{"formsemestre_id": formsemestre_id}, {"formsemestre_id": formsemestre_id},
) )
columns_ids = ( columns_ids = (