1
0
forked from ScoDoc/ScoDoc

refactoring (context)

This commit is contained in:
Emmanuel Viennet 2021-08-19 10:28:35 +02:00
parent cfd54fbc88
commit 24416e256d
79 changed files with 552 additions and 916 deletions

View File

@ -112,11 +112,11 @@ def scodoc(func):
def scodoc_function(*args, **kwargs):
if "scodoc_dept" in kwargs:
dept_acronym = kwargs["scodoc_dept"]
current_app.logger.info("setting dept to " + dept_acronym)
# current_app.logger.info("setting dept to " + dept_acronym)
app.set_sco_dept(dept_acronym)
del kwargs["scodoc_dept"]
elif not hasattr(g, "scodoc_dept"):
current_app.logger.info("setting dept to None")
# current_app.logger.info("setting dept to None")
g.scodoc_dept = None
g.scodoc_dept_id = -1 # invalide
return func(*args, **kwargs)

View File

@ -604,7 +604,6 @@ class GenTable(object):
def make_page(
self,
context,
title="",
format="html",
page_title="",
@ -644,7 +643,7 @@ class GenTable(object):
elif format == "pdf":
objects = self.pdf()
doc = sco_pdf.pdf_basic_page(
objects, title=title, preferences=self.preferences, context=context
objects, title=title, preferences=self.preferences
)
if publish:
return scu.sendPDFFile(REQUEST, doc, filename + ".pdf")
@ -731,5 +730,5 @@ if __name__ == "__main__":
document.build(objects)
data = doc.getvalue()
open("/tmp/gen_table.pdf", "wb").write(data)
p = T.make_page(None, format="pdf", REQUEST=None)
p = T.make_page(format="pdf", REQUEST=None)
open("toto.pdf", "wb").write(p)

View File

@ -182,7 +182,7 @@ class NotesTable(object):
self.context = context
self.formsemestre_id = formsemestre_id
cnx = ndb.GetDBConnexion()
self.sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
self.sem = sco_formsemestre.get_formsemestre(formsemestre_id)
self.moduleimpl_stats = {} # { moduleimpl_id : {stats} }
self._uecoef = {} # { ue_id : coef } cache coef manuels ue cap
self._evaluations_etats = None # liste des evaluations avec état
@ -191,7 +191,7 @@ class NotesTable(object):
)
# Infos sur les etudiants
self.inscrlist = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
args={"formsemestre_id": formsemestre_id}
)
# infos identite etudiant
# xxx sous-optimal: 1/select par etudiant -> 0.17" pour identdict sur GTR1 !
@ -245,7 +245,7 @@ class NotesTable(object):
# nb_inscrits, nb_notes, nb_abs, nb_neutre, moy, median, last_modif=
self.formation = sco_formations.formation_list(
context, args={"formation_id": self.sem["formation_id"]}
args={"formation_id": self.sem["formation_id"]}
)[0]
self.parcours = sco_codes_parcours.get_parcours_from_code(
self.formation["type_parcours"]

View File

@ -67,9 +67,7 @@ def comp_nom_semestre_dans_parcours(context, sem):
"""
from app.scodoc import sco_formations
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
return "%s %s %s %s" % (
parcours.SESSION_NAME, # eg "semestre"
@ -1240,8 +1238,8 @@ def get_cosemestres_diplomants(context, semBase, avec_meme_formation=False):
> dont la formation est la même (optionnel)
> ne prenant en compte que les etudiants sans redoublement
"""
tousLesSems = sco_formsemestre.do_formsemestre_list(
context
tousLesSems = (
sco_formsemestre.do_formsemestre_list()
) # tous les semestres memorisés dans scodoc
diplome = get_annee_diplome_semestre(semBase)

View File

@ -91,7 +91,7 @@ def pe_view_sem_recap(
return _pe_view_sem_recap_form(context, formsemestre_id, REQUEST=REQUEST)
prefs = sco_preferences.SemPreferences(formsemestre_id=formsemestre_id)
semBase = sco_formsemestre.get_formsemestre(context, formsemestre_id)
semBase = sco_formsemestre.get_formsemestre(formsemestre_id)
jury = pe_jurype.JuryPE(context, semBase)

View File

@ -28,14 +28,12 @@
"""Fonctions sur les absences
"""
# Anciennement dans ZAbscences.py, séparé pour migration
import calendar
import datetime
import html
import string
import time
import types
import datetime
import calendar
import cgi
from app.scodoc import notesdb as ndb
from app.scodoc.notes_log import log
@ -896,7 +894,7 @@ def MonthTableBody(
if href:
href = 'href="%s"' % href
if descr:
descr = 'title="%s"' % cgi.escape(descr, quote=True)
descr = 'title="%s"' % html.escape(descr, quote=True)
if href or descr:
cc.append("<a %s %s>" % (href, descr))
@ -990,7 +988,7 @@ def MonthTableBody(
if href:
href = 'href="%s"' % href
if descr:
descr = 'title="%s"' % cgi.escape(descr, quote=True)
descr = 'title="%s"' % html.escape(descr, quote=True)
if href or descr:
cc.append("<a %s %s>" % (href, descr))
if legend or d == 1:

View File

@ -284,7 +284,7 @@ def retreive_current_formsemestre(context, etudid, cur_date):
if not r:
return None
# s'il y a plusieurs semestres, prend le premier (rarissime et non significatif):
sem = sco_formsemestre.get_formsemestre(context, r[0]["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(r[0]["formsemestre_id"])
return sem

View File

@ -700,15 +700,15 @@ def formChoixSemestreGroupe(context, all=False):
"""
# XXX assez primitif, à ameliorer TOTALEMENT OBSOLETE !
if all:
sems = sco_formsemestre.do_formsemestre_list(context)
sems = sco_formsemestre.do_formsemestre_list()
else:
sems = sco_formsemestre.do_formsemestre_list(context, args={"etat": "1"})
sems = sco_formsemestre.do_formsemestre_list(args={"etat": "1"})
if not sems:
raise ScoValueError("aucun semestre !")
H = ['<select name="group_ids">']
for sem in sems:
for p in sco_groups.get_partitions_list(context, sem["formsemestre_id"]):
for group in sco_groups.get_partition_groups(context, p):
for p in sco_groups.get_partitions_list(sem["formsemestre_id"]):
for group in sco_groups.get_partition_groups(p):
if group["group_name"]:
group_tit = "%s %s" % (p["partition_name"], group["group_name"])
else:
@ -855,9 +855,9 @@ def ListeAbsEtud(
# Formats non HTML et demande d'une seule table:
if format != "html" and format != "text":
if absjust_only == 1:
return tab_absjust.make_page(context, format=format, REQUEST=REQUEST)
return tab_absjust.make_page(format=format, REQUEST=REQUEST)
else:
return tab_absnonjust.make_page(context, format=format, REQUEST=REQUEST)
return tab_absnonjust.make_page(format=format, REQUEST=REQUEST)
if format == "html":
# Mise en forme HTML:

View File

@ -420,7 +420,7 @@ class ApoEtud(dict):
if (not export_res_etape) and cur_sem:
# exporte toujours le résultat de l'étape si l'étudiant est diplômé
Se = sco_parcours_dut.SituationEtudParcours(
context, self.etud, cur_sem["formsemestre_id"]
self.etud, cur_sem["formsemestre_id"]
)
export_res_etape = Se.all_other_validated()
@ -572,9 +572,7 @@ class ApoEtud(dict):
(sem["semestre_id"] == apo_data.cur_semestre_id)
and (apo_data.etape in sem["etapes"])
and (
sco_formsemestre.sem_in_annee_scolaire(
context, sem, apo_data.annee_scolaire
)
sco_formsemestre.sem_in_annee_scolaire(sem, apo_data.annee_scolaire)
)
)
]
@ -1123,7 +1121,7 @@ def comp_apo_sems(context, etape_apogee, annee_scolaire):
:return: list of sems for etape_apogee in annee_scolaire
"""
return sco_formsemestre.list_formsemestre_by_etape(
context, etape_apo=str(etape_apogee), annee_scolaire=annee_scolaire
etape_apo=str(etape_apogee), annee_scolaire=annee_scolaire
)

View File

@ -381,7 +381,7 @@ def formsemestre_archive(context, REQUEST, formsemestre_id, group_ids=[]):
"opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER)
)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not group_ids:
# tous les inscrits du semestre
group_ids = [sco_groups.get_default_group(formsemestre_id)]
@ -512,7 +512,7 @@ def formsemestre_list_archives(context, REQUEST, formsemestre_id):
}
L.append(a)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(
context, REQUEST, "Archive des PV et résultats ", sem
@ -563,9 +563,7 @@ def formsemestre_delete_archive(
raise AccessDenied(
"opération non autorisée pour %s" % str(REQUEST.AUTHENTICATED_USER)
)
_ = sco_formsemestre.get_formsemestre(
context, formsemestre_id
) # check formsemestre_id
_ = sco_formsemestre.get_formsemestre(formsemestre_id) # check formsemestre_id
archive_id = PVArchive.get_id_from_name(context, formsemestre_id, archive_name)
dest_url = "formsemestre_list_archives?formsemestre_id=%s" % (formsemestre_id)

View File

@ -312,7 +312,7 @@ def etudarchive_import_files_form(context, group_id, REQUEST=None):
return "\n".join(H) + tf[1] + "</li></ol>" + F
elif tf[0] == -1:
# retrouve le semestre à partir du groupe:
group = sco_groups.get_group(context, group_id)
group = sco_groups.get_group(group_id)
return flask.redirect(
url_for(
"notes.formsemestre_status",

View File

@ -106,7 +106,7 @@ def make_context_dict(context, sem, etud):
C[name] = sco_preferences.get_preference(name, sem["formsemestre_id"])
# ajoute groupes et group_0, group_1, ...
sco_groups.etud_add_group_infos(context, etud, sem)
sco_groups.etud_add_group_infos(etud, sem)
C["groupes"] = etud["groupes"]
n = 0
for partition_id in etud["partitions"]:
@ -150,7 +150,7 @@ def formsemestre_bulletinetud_dict(
# Formation et parcours
I["formation"] = sco_formations.formation_list(
context, args={"formation_id": I["sem"]["formation_id"]}
args={"formation_id": I["sem"]["formation_id"]}
)[0]
I["parcours"] = sco_codes_parcours.get_parcours_from_code(
I["formation"]["type_parcours"]
@ -169,15 +169,11 @@ def formsemestre_bulletinetud_dict(
else:
I["descr_situation_html"] = I["descr_situation"]
# Groupes:
partitions = sco_groups.get_partitions_list(
context, formsemestre_id, with_default=False
)
partitions = sco_groups.get_partitions_list(formsemestre_id, with_default=False)
partitions_etud_groups = {} # { partition_id : { etudid : group } }
for partition in partitions:
pid = partition["partition_id"]
partitions_etud_groups[pid] = sco_groups.get_etud_groups_in_partition(
context, pid
)
partitions_etud_groups[pid] = sco_groups.get_etud_groups_in_partition(pid)
# --- Absences
I["nbabs"], I["nbabsjust"] = sco_abs.get_abs_count(etudid, nt.sem)
@ -337,9 +333,7 @@ def formsemestre_bulletinetud_dict(
"modules_capitalized"
] = [] # modules de l'UE capitalisée (liste vide si pas capitalisée)
if ue_status["is_capitalized"]:
sem_origin = sco_formsemestre.get_formsemestre(
context, ue_status["formsemestre_id"]
)
sem_origin = sco_formsemestre.get_formsemestre(ue_status["formsemestre_id"])
u["ue_descr_txt"] = "Capitalisée le %s" % ndb.DateISOtoDMY(
ue_status["event_date"]
)
@ -427,7 +421,7 @@ def _ue_mod_bulletin(context, etudid, formsemestre_id, ue_id, modimpls, nt, vers
"bul_show_abs_modules", formsemestre_id
)
if bul_show_abs_modules:
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
debut_sem = ndb.DateDMYtoISO(sem["date_debut"])
fin_sem = ndb.DateDMYtoISO(sem["date_fin"])
@ -801,7 +795,7 @@ def formsemestre_bulletinetud(
if format not in {"html", "pdfmail"}:
return bulletin
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
_formsemestre_bulletinetud_header_html(
context, etud, etudid, sem, formsemestre_id, format, version, REQUEST
@ -849,7 +843,7 @@ def formsemestre_bulletinetud(
def can_send_bulletin_by_mail(context, formsemestre_id):
"""True if current user is allowed to send a bulletin by mail"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
return (
sco_preferences.get_preference("bul_mail_allowed_for_all", formsemestre_id)
or current_user.has_permission(Permission.ScoImplement)

View File

@ -220,7 +220,6 @@ class BulletinGenerator(object):
document.addPageTemplates(
sco_pdf.ScolarsPageTemplate(
document,
context=self.context,
author="%s %s (E. Viennet) [%s]"
% (VERSION.SCONAME, VERSION.SCOVERSION, self.description),
title="Bulletin %s de %s"

View File

@ -93,7 +93,7 @@ def formsemestre_bulletinetud_published_dict(
d = {}
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if (not sem["bul_hide_xml"]) or force_publishing:
published = 1
else:
@ -141,15 +141,11 @@ def formsemestre_bulletinetud_published_dict(
return d # stop !
# Groupes:
partitions = sco_groups.get_partitions_list(
context, formsemestre_id, with_default=False
)
partitions = sco_groups.get_partitions_list(formsemestre_id, with_default=False)
partitions_etud_groups = {} # { partition_id : { etudid : group } }
for partition in partitions:
pid = partition["partition_id"]
partitions_etud_groups[pid] = sco_groups.get_etud_groups_in_partition(
context, pid
)
partitions_etud_groups[pid] = sco_groups.get_etud_groups_in_partition(pid)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > toutes notes
ues = nt.get_ues()

View File

@ -91,7 +91,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator):
"bul_show_abs_modules", formsemestre_id
)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if sem["bul_bgcolor"]:
bgcolor = sem["bul_bgcolor"]
else:

View File

@ -94,7 +94,6 @@ def pdfassemblebulletins(
document.addPageTemplates(
sco_pdf.ScolarsPageTemplate(
document,
context=context,
author="%s %s (E. Viennet)" % (VERSION.SCONAME, VERSION.SCOVERSION),
title="Bulletin %s" % bul_title,
subject="Bulletin de note",
@ -176,7 +175,7 @@ def get_formsemestre_bulletins_pdf(
if cached:
return cached[1], cached[0]
fragments = []
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# Make each bulletin
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_etudids, get_sexnom
bookmarks = {}

View File

@ -393,7 +393,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
P.append(t)
# Rangs dans les partitions:
partitions, _ = sco_groups.get_formsemestre_groups(context, formsemestre_id)
partitions, _ = sco_groups.get_formsemestre_groups(formsemestre_id)
for partition in partitions:
if partition["bul_show_rank"]:
partition_id = partition["partition_id"]

View File

@ -81,7 +81,7 @@ def make_xml_formsemestre_bulletinetud(
if REQUEST:
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if (not sem["bul_hide_xml"]) or force_publishing:
published = "1"
else:
@ -134,15 +134,11 @@ def make_xml_formsemestre_bulletinetud(
return doc # stop !
# Groupes:
partitions = sco_groups.get_partitions_list(
context, formsemestre_id, with_default=False
)
partitions = sco_groups.get_partitions_list(formsemestre_id, with_default=False)
partitions_etud_groups = {} # { partition_id : { etudid : group } }
for partition in partitions:
pid = partition["partition_id"]
partitions_etud_groups[pid] = sco_groups.get_etud_groups_in_partition(
context, pid
)
partitions_etud_groups[pid] = sco_groups.get_etud_groups_in_partition(pid)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > toutes notes
ues = nt.get_ues()

View File

@ -201,7 +201,7 @@ def do_moduleimpl_moyennes(context, nt, mod):
diag_info = {} # message d'erreur formule
moduleimpl_id = mod["moduleimpl_id"]
is_malus = mod["module"]["module_type"] == scu.MODULE_MALUS
sem = sco_formsemestre.get_formsemestre(context, mod["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(mod["formsemestre_id"])
etudids = sco_moduleimpl.do_moduleimpl_listeetuds(
context, moduleimpl_id
) # tous, y compris demissions
@ -210,7 +210,7 @@ def do_moduleimpl_moyennes(context, nt, mod):
[
x["etudid"]
for x in sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
context, mod["formsemestre_id"]
mod["formsemestre_id"]
)
]
)
@ -374,8 +374,8 @@ def do_formsemestre_moyennes(context, nt, formsemestre_id):
la liste des moduleimpls, la liste des evaluations valides,
liste des moduleimpls avec notes en attente.
"""
# sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
# inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
# sem = sco_formsemestre.get_formsemestre( formsemestre_id)
# inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
# args={"formsemestre_id": formsemestre_id}
# )
# etudids = [x["etudid"] for x in inscr]

View File

@ -57,7 +57,7 @@ def formsemestre_table_estim_cost(
peut conduire à une sur-estimation du coût s'il y a des modules optionnels
(dans ce cas, retoucher le tableau excel exporté).
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
sco_formsemestre_status.fill_formsemestre(sem)
Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
context, formsemestre_id=formsemestre_id
@ -198,4 +198,4 @@ def formsemestre_estim_cost(
coef_tp,
)
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)

View File

@ -56,7 +56,7 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
H.append(sco_up_to_date.html_up_to_date_box(context))
# Liste de toutes les sessions:
sems = sco_formsemestre.do_formsemestre_list(context)
sems = sco_formsemestre.do_formsemestre_list()
cursems = [] # semestres "courants"
othersems = [] # autres (verrouillés)
# icon image:
@ -74,7 +74,7 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
sem["lockimg"] = lockicon
othersems.append(sem)
# Responsable de formation:
sco_formsemestre.sem_set_responsable_name(context, sem)
sco_formsemestre.sem_set_responsable_name(sem)
if showcodes == "1":
sem["tmpcode"] = "<td><tt>%s</tt></td>" % sem["formsemestre_id"]
@ -82,9 +82,7 @@ def index_html(context, REQUEST=None, showcodes=0, showsemtable=0):
sem["tmpcode"] = ""
# Nombre d'inscrits:
args = {"formsemestre_id": sem["formsemestre_id"]}
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args=args
)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(args=args)
nb = len(ins) # nb etudiants
sem["nb_inscrits"] = nb
if nb > 0:

View File

@ -49,7 +49,7 @@ from app.scodoc import sco_news
def formation_delete(context, formation_id=None, dialog_confirmed=False, REQUEST=None):
"""Delete a formation"""
F = sco_formations.formation_list(context, args={"formation_id": formation_id})
F = sco_formations.formation_list(args={"formation_id": formation_id})
if not F:
raise ScoValueError("formation inexistante !")
F = F[0]
@ -59,9 +59,7 @@ def formation_delete(context, formation_id=None, dialog_confirmed=False, REQUEST
"""<h2>Suppression de la formation %(titre)s (%(acronyme)s)</h2>""" % F,
]
sems = sco_formsemestre.do_formsemestre_list(
context, {"formation_id": formation_id}
)
sems = sco_formsemestre.do_formsemestre_list({"formation_id": formation_id})
if sems:
H.append(
"""<p class="warning">Impossible de supprimer cette formation, car les sessions suivantes l'utilisent:</p>
@ -101,7 +99,7 @@ def do_formation_delete(context, oid):
"""delete a formation (and all its UE, matieres, modules)
XXX delete all ues, will break if there are validations ! USE WITH CARE !
"""
F = sco_formations.formation_list(context, args={"formation_id": oid})[0]
F = sco_formations.formation_list(args={"formation_id": oid})[0]
if sco_formations.formation_has_locked_sems(context, oid):
raise ScoLockedFormError()
cnx = ndb.GetDBConnexion()
@ -145,7 +143,7 @@ def formation_edit(context, formation_id=None, create=False, REQUEST=None):
is_locked = False
else:
# edit an existing formation
F = sco_formations.formation_list(context, args={"formation_id": formation_id})
F = sco_formations.formation_list(args={"formation_id": formation_id})
if not F:
raise ScoValueError("formation inexistante !")
initvalues = F[0]
@ -237,7 +235,7 @@ def formation_edit(context, formation_id=None, create=False, REQUEST=None):
"version": version,
}
ndb.quote_dict(args)
others = sco_formations.formation_list(context, args=args)
others = sco_formations.formation_list(args=args)
if others and ((len(others) > 1) or others[0]["formation_id"] != formation_id):
return (
"\n".join(H)
@ -266,7 +264,7 @@ def do_formation_create(context, args):
a = args.copy()
if "formation_id" in a:
del a["formation_id"]
F = sco_formations.formation_list(context, args=a)
F = sco_formations.formation_list(args=a)
if len(F) > 0:
log("do_formation_create: error: %d formations matching args=%s" % (len(F), a))
raise ScoValueError("Formation non unique (%s) !" % str(a))

View File

@ -84,9 +84,7 @@ def do_matiere_create(context, args):
r = _matiereEditor.create(cnx, args)
# news
F = sco_formations.formation_list(
context, args={"formation_id": ue["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": ue["formation_id"]})[0]
sco_news.add(
typ=sco_news.NEWS_FORM,
object=ue["formation_id"],
@ -184,9 +182,7 @@ def do_matiere_delete(context, oid):
_matiereEditor.delete(cnx, oid)
# news
F = sco_formations.formation_list(
context, args={"formation_id": ue["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": ue["formation_id"]})[0]
sco_news.add(
typ=sco_news.NEWS_FORM,
object=ue["formation_id"],
@ -237,9 +233,7 @@ def matiere_edit(context, matiere_id=None, REQUEST=None):
if not F:
raise ScoValueError("UE inexistante !")
U = U[0]
Fo = sco_formations.formation_list(
context, args={"formation_id": U["formation_id"]}
)[0]
Fo = sco_formations.formation_list(args={"formation_id": U["formation_id"]})[0]
ues = sco_edit_ue.do_ue_list(context, args={"formation_id": U["formation_id"]})
ue_names = ["%(acronyme)s (%(titre)s)" % u for u in ues]

View File

@ -108,9 +108,7 @@ def do_module_create(context, args) -> int:
r = _moduleEditor.create(cnx, args)
# news
F = sco_formations.formation_list(
context, args={"formation_id": args["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": args["formation_id"]})[0]
sco_news.add(
typ=sco_news.NEWS_FORM,
object=args["formation_id"],
@ -129,9 +127,7 @@ def module_create(context, matiere_id=None, REQUEST=None):
raise ScoValueError("invalid matiere !")
M = sco_edit_matiere.do_matiere_list(context, args={"matiere_id": matiere_id})[0]
UE = sco_edit_ue.do_ue_list(context, args={"ue_id": M["ue_id"]})[0]
Fo = sco_formations.formation_list(
context, args={"formation_id": UE["formation_id"]}
)[0]
Fo = sco_formations.formation_list(args={"formation_id": UE["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(Fo["type_parcours"])
semestres_indices = list(range(1, parcours.NB_SEM + 1))
H = [
@ -274,9 +270,7 @@ def do_module_delete(context, oid):
_moduleEditor.delete(cnx, oid)
# news
F = sco_formations.formation_list(
context, args={"formation_id": mod["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": mod["formation_id"]})[0]
sco_news.add(
typ=sco_news.NEWS_FORM,
object=mod["formation_id"],
@ -355,9 +349,7 @@ def module_edit(context, module_id=None, REQUEST=None):
raise ScoValueError("invalid module !")
Mod = Mod[0]
unlocked = not module_is_locked(context, module_id)
Fo = sco_formations.formation_list(
context, args={"formation_id": Mod["formation_id"]}
)[0]
Fo = sco_formations.formation_list(args={"formation_id": Mod["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(Fo["type_parcours"])
M = ndb.SimpleDictFetch(
"""SELECT ue.acronyme, mat.*, mat.id AS matiere_id
@ -545,7 +537,7 @@ def module_list(context, formation_id, REQUEST=None):
if not formation_id:
raise ScoValueError("invalid formation !")
F = sco_formations.formation_list(context, args={"formation_id": formation_id})[0]
F = sco_formations.formation_list(args={"formation_id": formation_id})[0]
H = [
html_sco_header.sco_header(page_title="Liste des modules de %(titre)s" % F),
"""<h2>Listes des modules dans la formation %(titre)s (%(acronyme)s)</h2>"""

View File

@ -105,9 +105,7 @@ def do_ue_create(context, args):
r = _ueEditor.create(cnx, args)
# news
F = sco_formations.formation_list(
context, args={"formation_id": args["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": args["formation_id"]})[0]
sco_news.add(
typ=sco_news.NEWS_FORM,
object=args["formation_id"],
@ -167,9 +165,7 @@ def do_ue_delete(context, ue_id, delete_validations=False, REQUEST=None, force=F
# > UE delete + supr. validations associées etudiants (cas compliqué, mais rarement utilisé: acceptable de tout invalider ?):
sco_cache.invalidate_formsemestre()
# news
F = sco_formations.formation_list(
context, args={"formation_id": ue["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": ue["formation_id"]})[0]
sco_news.add(
typ=sco_news.NEWS_FORM,
object=ue["formation_id"],
@ -212,7 +208,7 @@ def ue_edit(context, ue_id=None, create=False, formation_id=None, REQUEST=None):
title = "Création d'une UE"
initvalues = {}
submitlabel = "Créer cette UE"
Fol = sco_formations.formation_list(context, args={"formation_id": formation_id})
Fol = sco_formations.formation_list(args={"formation_id": formation_id})
if not Fol:
raise ScoValueError(
"Formation %s inexistante ! (si vous avez suivi un lien valide, merci de signaler le problème)"
@ -438,7 +434,7 @@ def ue_list(context, formation_id=None, msg="", REQUEST=None):
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre_validation
F = sco_formations.formation_list(context, args={"formation_id": formation_id})
F = sco_formations.formation_list(args={"formation_id": formation_id})
if not F:
raise ScoValueError("invalid formation_id")
F = F[0]
@ -802,7 +798,7 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module
<p><ul>"""
)
for sem in sco_formsemestre.do_formsemestre_list(
context, args={"formation_id": formation_id}
args={"formation_id": formation_id}
):
H.append(
'<li><a class="stdlink" href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titremois)s</a>'
@ -847,9 +843,7 @@ def ue_sharing_code(context, ue_code=None, ue_id=None, hide_ue_id=None):
ue = do_ue_list(context, args={"ue_id": ue_id})[0]
if not ue_code:
ue_code = ue["ue_code"]
F = sco_formations.formation_list(
context, args={"formation_id": ue["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": ue["formation_id"]})[0]
formation_code = F["formation_code"]
ue_list_all = do_ue_list(context, args={"ue_code": ue_code})
@ -859,7 +853,7 @@ def ue_sharing_code(context, ue_code=None, ue_id=None, hide_ue_id=None):
ue_list = []
for ue in ue_list_all:
F = sco_formations.formation_list(
context, args={"formation_id": ue["formation_id"]}
args={"formation_id": ue["formation_id"]}
)[0]
if formation_code == F["formation_code"]:
ue_list.append(ue)
@ -881,9 +875,7 @@ def ue_sharing_code(context, ue_code=None, ue_id=None, hide_ue_id=None):
H.append('<span class="ue_share">UE avec le code %s:</span>' % ue_code)
H.append("<ul>")
for ue in ue_list:
F = sco_formations.formation_list(
context, args={"formation_id": ue["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": ue["formation_id"]})[0]
H.append(
'<li>%s (%s) dans <a class="stdlink" href="ue_list?formation_id=%s">%s (%s)</a>, version %s</li>'
% (
@ -970,7 +962,7 @@ def formation_table_recap(context, formation_id, format="html", REQUEST=None):
"""Table recapitulant formation."""
from app.scodoc import sco_formations
F = sco_formations.formation_list(context, args={"formation_id": formation_id})
F = sco_formations.formation_list(args={"formation_id": formation_id})
if not F:
raise ScoValueError("invalid formation_id")
F = F[0]
@ -1049,7 +1041,7 @@ def formation_table_recap(context, formation_id, format="html", REQUEST=None):
pdf_title=title,
preferences=sco_preferences.SemPreferences(),
)
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
def ue_list_semestre_ids(context, ue):

View File

@ -129,8 +129,8 @@ def group_edt_json(context, group_id, start="", end="", REQUEST=None):
TODO: utiliser start et end (2 dates au format ISO YYYY-MM-DD)
TODO: cacher
"""
group = sco_groups.get_group(context, group_id)
sem = sco_formsemestre.get_formsemestre(context, group["formsemestre_id"])
group = sco_groups.get_group(group_id)
sem = sco_formsemestre.get_formsemestre(group["formsemestre_id"])
edt2sco, sco2edt, msg = get_edt_transcodage_groups(
context, group["formsemestre_id"]
)

View File

@ -346,8 +346,7 @@ def apo_semset_maq_status(
if missing:
formation_ids = {sem["formation_id"] for sem in semset.sems}
formations = [
sco_formations.formation_list(context, formation_id=i)[0]
for i in formation_ids
sco_formations.formation_list(formation_id=i)[0] for i in formation_ids
]
# log('formations=%s' % formations)
H.append(
@ -593,7 +592,7 @@ def _view_etuds_page(
preferences=sco_preferences.SemPreferences(),
)
if format != "html":
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
H.append(tab.html())
@ -772,7 +771,7 @@ def view_apo_csv(context, etape_apo="", semset_id="", format="html", REQUEST=Non
)
if format != "html":
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
H += [
tab.html(),

View File

@ -925,13 +925,13 @@ def fill_etuds_info(etuds):
# Semestres dans lesquel il est inscrit
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid}
{"etudid": etudid}
)
etud["ins"] = ins
sems = []
cursem = None # semestre "courant" ou il est inscrit
for i in ins:
sem = sco_formsemestre.get_formsemestre(context, i["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(i["formsemestre_id"])
if sco_formsemestre.sem_est_courant(context, sem):
cursem = sem
curi = i
@ -948,7 +948,7 @@ def fill_etuds_info(etuds):
etud["inscription_formsemestre_id"] = cursem["formsemestre_id"]
etud["etatincursem"] = curi["etat"]
etud["situation"] = descr_situation_etud(context, etudid, etud["ne"])
# XXX est-ce utile ? sco_groups.etud_add_group_infos(context, etud, cursem)
# XXX est-ce utile ? sco_groups.etud_add_group_infos( etud, cursem)
else:
if etud["sems"]:
if etud["sems"][0]["dateord"] > time.strftime(
@ -1023,7 +1023,7 @@ def descr_situation_etud(context, etudid, ne=""):
if not r:
situation = "non inscrit"
else:
sem = sco_formsemestre.get_formsemestre(context, r["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(r["formsemestre_id"])
if r["etat"] == "I":
situation = "inscrit%s en %s" % (ne, sem["titremois"])
# Cherche la date d'inscription dans scolar_events:

View File

@ -215,7 +215,7 @@ def _check_evaluation_args(args):
args["jour"] = jour
if jour:
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
d, m, y = [int(x) for x in sem["date_debut"].split("/")]
date_debut = datetime.date(y, m, d)
d, m, y = [int(x) for x in sem["date_fin"].split("/")]
@ -425,17 +425,17 @@ def do_evaluation_etat(evaluation_id, partition_id=None, select_first_partition=
# Si partition_id is None, prend 'all' ou bien la premiere:
if partition_id is None:
if select_first_partition:
partitions = sco_groups.get_partitions_list(context, formsemestre_id)
partitions = sco_groups.get_partitions_list(formsemestre_id)
partition = partitions[0]
else:
partition = sco_groups.get_default_partition(context, formsemestre_id)
partition = sco_groups.get_default_partition(formsemestre_id)
partition_id = partition["partition_id"]
# Il faut considerer les inscriptions au semestre
# (pour avoir l'etat et le groupe) et aussi les inscriptions
# au module (pour gerer les modules optionnels correctement)
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
context, formsemestre_id
formsemestre_id
)
insmod = sco_moduleimpl.do_moduleimpl_inscription_list(
context, moduleimpl_id=E["moduleimpl_id"]
@ -456,7 +456,7 @@ def do_evaluation_etat(evaluation_id, partition_id=None, select_first_partition=
TotalNbMissing = 0
TotalNbAtt = 0
groups = {} # group_id : group
etud_groups = sco_groups.get_etud_groups_in_partition(context, partition_id)
etud_groups = sco_groups.get_etud_groups_in_partition(partition_id)
for i in ins:
group = etud_groups.get(i["etudid"], None)
@ -721,7 +721,7 @@ def do_evaluation_etat_in_mod(nt, moduleimpl_id):
def formsemestre_evaluations_cal(formsemestre_id, REQUEST=None):
"""Page avec calendrier de toutes les evaluations de ce semestre"""
context = None # #context
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > liste evaluations
evals = nt.get_sem_evaluation_etat_list()
@ -823,7 +823,7 @@ def evaluation_date_first_completion(evaluation_id):
# E = do_evaluation_list(args={"evaluation_id": evaluation_id})[0]
# M = sco_moduleimpl.do_moduleimpl_list(context,moduleimpl_id=E["moduleimpl_id"])[0]
# formsemestre_id = M["formsemestre_id"]
# insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(context, formsemestre_id)
# insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits( formsemestre_id)
# insmod = sco_moduleimpl.do_moduleimpl_inscription_list(context,moduleimpl_id=E["moduleimpl_id"])
# insmodset = set([x["etudid"] for x in insmod])
# retire de insem ceux qui ne sont pas inscrits au module
@ -860,7 +860,7 @@ def formsemestre_evaluations_delai_correction(
N'indique pas les évaluations de ratrapage ni celles des modules de bonus/malus.
"""
context = None # #context
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > liste evaluations
evals = nt.get_sem_evaluation_etat_list()
@ -931,7 +931,7 @@ def formsemestre_evaluations_delai_correction(
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
filename=scu.make_filename("evaluations_delais_" + sem["titreannee"]),
)
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
def module_evaluation_insert_before(ModEvals, next_eval):

View File

@ -63,7 +63,7 @@ def _build_results_table(context, start_date=None, end_date=None, types_parcours
semlist_parcours = []
for sem in semlist:
sem["formation"] = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
args={"formation_id": sem["formation_id"]}
)[0]
sem["parcours"] = sco_codes_parcours.get_parcours_from_code(
sem["formation"]["type_parcours"]

View File

@ -156,7 +156,7 @@ def search_etud_in_dept(context, expnom="", REQUEST=None):
e["_nomprenom_target"] = target
e["inscription_target"] = target
e["_nomprenom_td_attrs"] = 'id="%s" class="etudinfo"' % (e["etudid"])
sco_groups.etud_add_group_infos(context, e, e["cursem"])
sco_groups.etud_add_group_infos(e, e["cursem"])
tab = GenTable(
columns_ids=("nomprenom", "code_nip", "inscription", "groupes"),

View File

@ -69,7 +69,7 @@ _formationEditor = ndb.EditableTable(
)
def formation_list(context, formation_id=None, args={}):
def formation_list(formation_id=None, args={}):
"""List formation(s) with given id, or matching args
(when args is given, formation_id is ignored).
"""
@ -87,7 +87,7 @@ def formation_list(context, formation_id=None, args={}):
def formation_has_locked_sems(context, formation_id):
"True if there is a locked formsemestre in this formation"
sems = sco_formsemestre.do_formsemestre_list(
context, args={"formation_id": formation_id, "etat": False}
args={"formation_id": formation_id, "etat": False}
)
return sems
@ -264,7 +264,7 @@ def formation_list_table(context, formation_id=None, args={}, REQUEST=None):
f["_titre_id"] = "titre-%s" % f["acronyme"].lower().replace(" ", "-")
# Ajoute les semestres associés à chaque formation:
f["sems"] = sco_formsemestre.do_formsemestre_list(
context, args={"formation_id": f["formation_id"]}
args={"formation_id": f["formation_id"]}
)
f["sems_list_txt"] = ", ".join([s["session_id"] for s in f["sems"]])
f["_sems_list_txt_html"] = ", ".join(

View File

@ -88,19 +88,17 @@ _formsemestreEditor = ndb.EditableTable(
)
def get_formsemestre(context, formsemestre_id):
def get_formsemestre(formsemestre_id):
"list ONE formsemestre"
try:
sem = do_formsemestre_list(context, args={"formsemestre_id": formsemestre_id})[
0
]
sem = do_formsemestre_list(args={"formsemestre_id": formsemestre_id})[0]
return sem
except:
log("get_formsemestre: invalid formsemestre_id (%s)" % formsemestre_id)
raise
def do_formsemestre_list(context, *a, **kw):
def do_formsemestre_list(*a, **kw):
"list formsemestres"
# log('do_formsemestre_list: a=%s kw=%s' % (str(a),str(kw)))
cnx = ndb.GetDBConnexion()
@ -109,10 +107,8 @@ def do_formsemestre_list(context, *a, **kw):
# Ajoute les étapes Apogee et les responsables:
for sem in sems:
sem["etapes"] = read_formsemestre_etapes(context, sem["formsemestre_id"])
sem["responsables"] = read_formsemestre_responsables(
context, sem["formsemestre_id"]
)
sem["etapes"] = read_formsemestre_etapes(sem["formsemestre_id"])
sem["responsables"] = read_formsemestre_responsables(sem["formsemestre_id"])
# Filtre sur code etape si indiqué:
if "args" in kw:
@ -121,7 +117,7 @@ def do_formsemestre_list(context, *a, **kw):
sems = [sem for sem in sems if etape in sem["etapes"]]
for sem in sems:
formsemestre_enrich(context, sem)
_formsemestre_enrich(sem)
# tri par date, le plus récent d'abord
sems.sort(key=itemgetter("dateord", "semestre_id"), reverse=True)
@ -129,15 +125,13 @@ def do_formsemestre_list(context, *a, **kw):
return sems
def formsemestre_enrich(context, sem):
def _formsemestre_enrich(sem):
"""Ajoute champs souvent utiles: titre + annee et dateord (pour tris)"""
# imports ici pour eviter refs circulaires
from app.scodoc import sco_formsemestre_edit
from app.scodoc import sco_etud
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
# 'S1', 'S2', ... ou '' pour les monosemestres
if sem["semestre_id"] != NO_SEMESTRE_ID:
@ -203,13 +197,11 @@ def formsemestre_enrich(context, sem):
sem["mois_fin"],
)
sem["session_id"] = sco_formsemestre_edit.get_formsemestre_session_id(
context, sem, F, parcours
sem, F, parcours
)
sem["etapes"] = read_formsemestre_etapes(context, sem["formsemestre_id"])
sem["etapes"] = read_formsemestre_etapes(sem["formsemestre_id"])
sem["etapes_apo_str"] = formsemestre_etape_apo_str(sem)
sem["responsables"] = read_formsemestre_responsables(
context, sem["formsemestre_id"]
)
sem["responsables"] = read_formsemestre_responsables(sem["formsemestre_id"])
def formsemestre_etape_apo_str(sem):
@ -232,19 +224,18 @@ def do_formsemestre_create(args, silent=False):
formsemestre_id = _formsemestreEditor.create(cnx, args)
if args["etapes"]:
args["formsemestre_id"] = formsemestre_id
write_formsemestre_etapes(context, args)
write_formsemestre_etapes(args)
if args["responsables"]:
args["formsemestre_id"] = formsemestre_id
write_formsemestre_responsables(context, args)
write_formsemestre_responsables(args)
# create default partition
partition_id = sco_groups.partition_create(
context,
formsemestre_id,
default=True,
redirect=0,
)
_group_id = sco_groups.createGroup(context, partition_id, default=True)
_group_id = sco_groups.createGroup(partition_id, default=True)
# news
if "titre" not in args:
@ -260,22 +251,22 @@ def do_formsemestre_create(args, silent=False):
return formsemestre_id
def do_formsemestre_edit(context, sem, cnx=None, **kw):
def do_formsemestre_edit(sem, cnx=None, **kw):
"""Apply modifications to formsemestre.
Update etapes and resps. Invalidate cache."""
if not cnx:
cnx = ndb.GetDBConnexion()
_formsemestreEditor.edit(cnx, sem, **kw)
write_formsemestre_etapes(context, sem)
write_formsemestre_responsables(context, sem)
write_formsemestre_etapes(sem)
write_formsemestre_responsables(sem)
sco_cache.invalidate_formsemestre(
formsemestre_id=sem["formsemestre_id"]
) # > modif formsemestre
def read_formsemestre_responsables(context, formsemestre_id):
def read_formsemestre_responsables(formsemestre_id):
"""recupere liste des responsables de ce semestre
:returns: liste de chaines
"""
@ -289,8 +280,8 @@ def read_formsemestre_responsables(context, formsemestre_id):
return [x["responsable_id"] for x in r]
def write_formsemestre_responsables(context, sem):
return _write_formsemestre_aux(context, sem, "responsables", "responsable_id")
def write_formsemestre_responsables(sem):
return _write_formsemestre_aux(sem, "responsables", "responsable_id")
# ---------------------- Coefs des UE
@ -307,7 +298,7 @@ formsemestre_uecoef_list = _formsemestre_uecoef_editor.list
formsemestre_uecoef_delete = _formsemestre_uecoef_editor.delete
def do_formsemestre_uecoef_edit_or_create(context, cnx, formsemestre_id, ue_id, coef):
def do_formsemestre_uecoef_edit_or_create(cnx, formsemestre_id, ue_id, coef):
"modify or create the coef"
coefs = formsemestre_uecoef_list(
cnx, args={"formsemestre_id": formsemestre_id, "ue_id": ue_id}
@ -331,7 +322,7 @@ def do_formsemestre_uecoef_edit_or_create(context, cnx, formsemestre_id, ue_id,
)
def do_formsemestre_uecoef_delete(context, cnx, formsemestre_id, ue_id):
def do_formsemestre_uecoef_delete(cnx, formsemestre_id, ue_id):
"delete coef for this (ue,sem)"
coefs = formsemestre_uecoef_list(
cnx, args={"formsemestre_id": formsemestre_id, "ue_id": ue_id}
@ -340,7 +331,7 @@ def do_formsemestre_uecoef_delete(context, cnx, formsemestre_id, ue_id):
formsemestre_uecoef_delete(cnx, coefs[0]["formsemestre_uecoef_id"])
def read_formsemestre_etapes(context, formsemestre_id):
def read_formsemestre_etapes(formsemestre_id):
"""recupere liste des codes etapes associés à ce semestre
:returns: liste d'instance de ApoEtapeVDI
"""
@ -354,11 +345,11 @@ def read_formsemestre_etapes(context, formsemestre_id):
return [ApoEtapeVDI(x["etape_apo"]) for x in r if x["etape_apo"]]
def write_formsemestre_etapes(context, sem):
return _write_formsemestre_aux(context, sem, "etapes", "etape_apo")
def write_formsemestre_etapes(sem):
return _write_formsemestre_aux(sem, "etapes", "etape_apo")
def _write_formsemestre_aux(context, sem, fieldname, valuename):
def _write_formsemestre_aux(sem, fieldname, valuename):
"""fieldname: 'etapes' ou 'responsables'
valuename: 'etape_apo' ou 'responsable_id'
"""
@ -394,7 +385,7 @@ def _write_formsemestre_aux(context, sem, fieldname, valuename):
cnx.commit()
def sem_set_responsable_name(context, sem):
def sem_set_responsable_name(sem):
"ajoute champs responsable_name"
sem["responsable_name"] = ", ".join(
[
@ -404,7 +395,7 @@ def sem_set_responsable_name(context, sem):
)
def sem_in_semestre_scolaire(context, sem, year=False, saison=0, REQUEST=None):
def sem_in_semestre_scolaire(sem, year=False, saison=0):
"""n'utilise que la date de debut, pivot au 1er aout
si annee non specifiée, année scolaire courante
Patch Jmp: ajout du parametre optionnel saison
@ -435,7 +426,7 @@ def sem_in_semestre_scolaire(context, sem, year=False, saison=0, REQUEST=None):
return sem["mois_debut_ord"] <= 7 or sem["mois_debut_ord"] == 12
def sem_in_annee_scolaire(context, sem, year=False, REQUEST=None):
def sem_in_annee_scolaire(sem, year=False):
"""Test si sem appartient à l'année scolaire year (int).
N'utilise que la date de debut, pivot au 1er août.
Si annee non specifiée, année scolaire courante
@ -485,28 +476,22 @@ def scodoc_get_all_unlocked_sems():
try:
for dept in depts:
app.set_sco_dept(dept.acronym)
semdepts += [
(sem, dept)
for sem in do_formsemestre_list(dept.Scolarite.Notes)
if sem["etat"]
]
semdepts += [(sem, dept) for sem in do_formsemestre_list() if sem["etat"]]
finally:
app.set_sco_dept(cur_dept)
return semdepts
def table_formsemestres(
context,
sems,
columns_ids=(),
sup_columns_ids=(),
html_title="<h2>Semestres</h2>",
html_next_section="",
REQUEST=None,
):
"""Une table presentant des semestres"""
for sem in sems:
sem_set_responsable_name(context, sem)
sem_set_responsable_name(sem)
sem["_titre_num_target"] = (
"formsemestre_status?formsemestre_id=%s" % sem["formsemestre_id"]
)
@ -550,36 +535,30 @@ def table_formsemestres(
return tab
def list_formsemestre_by_etape(
context, etape_apo=False, annee_scolaire=False, REQUEST=None
):
def list_formsemestre_by_etape(etape_apo=False, annee_scolaire=False):
"""Liste des semestres de cette etape, pour l'annee scolaire indiquée (sinon, pour toutes)"""
ds = {} # formsemestre_id : sem
if etape_apo:
sems = do_formsemestre_list(context, args={"etape_apo": etape_apo})
sems = do_formsemestre_list(args={"etape_apo": etape_apo})
for sem in sems:
if annee_scolaire: # restriction annee scolaire
if sem_in_annee_scolaire(
context, sem, year=int(annee_scolaire), REQUEST=REQUEST
):
if sem_in_annee_scolaire(sem, year=int(annee_scolaire)):
ds[sem["formsemestre_id"]] = sem
sems = list(ds.values())
else:
sems = do_formsemestre_list(context)
sems = do_formsemestre_list()
if annee_scolaire:
sems = [
sem
for sem in sems
if sem_in_annee_scolaire(
context, sem, year=int(annee_scolaire), REQUEST=REQUEST
)
if sem_in_annee_scolaire(sem, year=int(annee_scolaire))
]
sems.sort(key=lambda s: (s["modalite"], s["dateord"]))
return sems
def view_formsemestre_by_etape(context, etape_apo=None, format="html", REQUEST=None):
def view_formsemestre_by_etape(etape_apo=None, format="html", REQUEST=None):
"""Affiche table des semestres correspondants à l'étape"""
if etape_apo:
html_title = (
@ -588,18 +567,16 @@ def view_formsemestre_by_etape(context, etape_apo=None, format="html", REQUEST=N
else:
html_title = """<h2>Semestres courants</h2>"""
tab = table_formsemestres(
context,
list_formsemestre_by_etape(
context, etape_apo=etape_apo, annee_scolaire=scu.AnneeScolaire()
etape_apo=etape_apo, annee_scolaire=scu.AnneeScolaire()
),
html_title=html_title,
html_next_section="""<form action="view_formsemestre_by_etape">
Etape: <input name="etape_apo" type="text" size="8"></input>
</form>""",
REQUEST=REQUEST,
)
tab.base_url = "%s?etape_apo=%s" % (REQUEST.URL0, etape_apo or "")
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
def sem_has_etape(sem, code_etape):

View File

@ -62,7 +62,7 @@ def formsemestre_custommenu_html(context, formsemestre_id):
"HTML code for custom menu"
menu = []
# Calendrier électronique ?
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
ics_url = sco_edt_cal.formsemestre_get_ics_url(context, sem)
if ics_url:
menu.append({"title": "Emploi du temps (ics)", "url": ics_url})
@ -79,7 +79,7 @@ def formsemestre_custommenu_html(context, formsemestre_id):
def formsemestre_custommenu_edit(context, formsemestre_id, REQUEST=None):
"""Dialog to edit the custom menu"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
dest_url = (
scu.NotesURL() + "/formsemestre_status?formsemestre_id=%s" % formsemestre_id
)

View File

@ -88,7 +88,7 @@ def formsemestre_createwithmodules(context, REQUEST=None):
def formsemestre_editwithmodules(context, REQUEST, formsemestre_id):
"""Page modification semestre"""
# portage from dtml
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(
context,
@ -124,7 +124,7 @@ def formsemestre_editwithmodules(context, REQUEST, formsemestre_id):
def can_edit_sem(context, REQUEST, formsemestre_id="", sem=None):
"""Return sem if user can edit it, False otherwise"""
sem = sem or sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sem or sco_formsemestre.get_formsemestre(formsemestre_id)
if not current_user.has_permission(Permission.ScoImplement): # pas chef
if not sem["resp_can_edit"] or current_user.id not in sem["responsables"]:
return False
@ -136,7 +136,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
# Fonction accessible à tous, controle acces à la main:
if edit:
formsemestre_id = int(REQUEST.form["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not current_user.has_permission(Permission.ScoImplement):
if not edit:
# il faut ScoImplement pour creer un semestre
@ -155,7 +155,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
allowed_user_names = list(uid2display.values()) + [""]
#
formation_id = int(REQUEST.form["formation_id"])
F = sco_formations.formation_list(context, args={"formation_id": formation_id})
F = sco_formations.formation_list(args={"formation_id": formation_id})
if not F:
raise ScoValueError("Formation inexistante !")
F = F[0]
@ -551,9 +551,9 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
opt_selected(default_group_id),
)
fcg += '<option value="" %s>Aucun</option>' % opt_selected("")
for p in sco_groups.get_partitions_list(context, formsemestre_id):
for p in sco_groups.get_partitions_list(formsemestre_id):
if p["partition_name"] != None:
for group in sco_groups.get_partition_groups(context, p):
for group in sco_groups.get_partition_groups(p):
fcg += '<option value="%s" %s>%s %s</option>' % (
group["group_id"],
opt_selected(group["group_id"]),
@ -750,7 +750,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
# nouveaux modules
# (retire le "MI" du début du nom de champs)
checkedmods = [int(x[2:]) for x in tf[2]["tf-checked"]]
sco_formsemestre.do_formsemestre_edit(context, tf[2])
sco_formsemestre.do_formsemestre_edit(tf[2])
ams = sco_moduleimpl.do_moduleimpl_list(
context, formsemestre_id=formsemestre_id
)
@ -781,8 +781,7 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False):
group_id = tf[2]["%s!group_id" % module_id]
if group_id:
etudids = [
x["etudid"]
for x in sco_groups.get_group_members(context, group_id)
x["etudid"] for x in sco_groups.get_group_members(group_id)
]
log(
"inscription module:module_id=%s,moduleimpl_id=%s: %s"
@ -882,7 +881,7 @@ def formsemestre_clone(context, formsemestre_id, REQUEST=None):
"""
Formulaire clonage d'un semestre
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# Liste des enseignants avec forme pour affichage / saisie avec suggestion
userlist = sco_users.get_user_list()
uid2display = {} # user_name : forme pour affichage = "NOM Prenom (login)"
@ -1020,7 +1019,7 @@ def do_formsemestre_clone(
New dates, responsable_id
"""
log("cloning %s" % orig_formsemestre_id)
orig_sem = sco_formsemestre.get_formsemestre(context, orig_formsemestre_id)
orig_sem = sco_formsemestre.get_formsemestre(orig_formsemestre_id)
cnx = ndb.GetDBConnexion()
# 1- create sem
args = orig_sem.copy()
@ -1098,30 +1097,27 @@ def do_formsemestre_clone(
listgroups = []
listnamegroups = []
# Création des partitions:
for part in sco_groups.get_partitions_list(context, orig_formsemestre_id):
for part in sco_groups.get_partitions_list(orig_formsemestre_id):
if part["partition_name"] != None:
partname = part["partition_name"]
new_partition_id = sco_groups.partition_create(
context,
formsemestre_id,
partition_name=partname,
redirect=0,
)
for g in sco_groups.get_partition_groups(context, part):
for g in sco_groups.get_partition_groups(part):
if g["group_name"] != None:
listnamegroups.append(g["group_name"])
listgroups.append([new_partition_id, listnamegroups])
listnamegroups = []
# Création des groupes dans les nouvelles partitions:
for newpart in sco_groups.get_partitions_list(context, formsemestre_id):
for newpart in sco_groups.get_partitions_list(formsemestre_id):
for g in listgroups:
if newpart["partition_id"] == g[0]:
part_id = g[0]
for group_name in g[1]:
_ = sco_groups.createGroup(
context, part_id, group_name=group_name
)
_ = sco_groups.createGroup(part_id, group_name=group_name)
return formsemestre_id
@ -1139,12 +1135,9 @@ def formsemestre_associate_new_version(
"""Formulaire changement formation d'un semestre"""
if not dialog_confirmed:
# dresse le liste des semestres de la meme formation et version
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
othersems = sco_formsemestre.do_formsemestre_list(
context,
args={
"formation_id": F["formation_id"],
"version": F["version"],
@ -1202,10 +1195,10 @@ def do_formsemestres_associate_new_version(context, formsemestre_ids, REQUEST=No
if not formsemestre_ids:
return
# Check: tous de la même formation
sem = sco_formsemestre.get_formsemestre(context, formsemestre_ids[0])
sem = sco_formsemestre.get_formsemestre(formsemestre_ids[0])
formation_id = sem["formation_id"]
for formsemestre_id in formsemestre_ids[1:]:
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if formation_id != sem["formation_id"]:
raise ScoValueError("les semestres ne sont pas tous de la même formation !")
@ -1220,9 +1213,9 @@ def do_formsemestres_associate_new_version(context, formsemestre_ids, REQUEST=No
)
for formsemestre_id in formsemestre_ids:
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
sem["formation_id"] = formation_id
sco_formsemestre.do_formsemestre_edit(context, sem, cnx=cnx, html_quote=False)
sco_formsemestre.do_formsemestre_edit(sem, cnx=cnx, html_quote=False)
_reassociate_moduleimpls(
context, cnx, formsemestre_id, ues_old2new, modules_old2new
)
@ -1261,10 +1254,8 @@ def _reassociate_moduleimpls(
def formsemestre_delete(context, formsemestre_id, REQUEST=None):
"""Delete a formsemestre (affiche avertissements)"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
H = [
html_sco_header.html_sem_header(
context, REQUEST, "Suppression du semestre", sem
@ -1357,7 +1348,7 @@ def do_formsemestre_delete(context, formsemestre_id):
No checks, no warnings: erase all !
"""
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
sco_cache.EvaluationCache.invalidate_sem(formsemestre_id)
@ -1478,7 +1469,7 @@ def formsemestre_change_lock(
ok, err = sco_permissions_check.check_access_diretud(formsemestre_id)
if not ok:
return err
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etat = not sem["etat"]
if REQUEST and not dialog_confirmed:
@ -1500,7 +1491,7 @@ def formsemestre_change_lock(
)
args = {"formsemestre_id": formsemestre_id, "etat": etat}
sco_formsemestre.do_formsemestre_edit(context, args)
sco_formsemestre.do_formsemestre_edit(args)
if REQUEST:
return flask.redirect(
"formsemestre_status?formsemestre_id=%s" % formsemestre_id
@ -1514,7 +1505,7 @@ def formsemestre_change_publication_bul(
ok, err = sco_permissions_check.check_access_diretud(formsemestre_id)
if not ok:
return err
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etat = not sem["bul_hide_xml"]
if REQUEST and not dialog_confirmed:
@ -1535,7 +1526,7 @@ def formsemestre_change_publication_bul(
)
args = {"formsemestre_id": formsemestre_id, "bul_hide_xml": etat}
sco_formsemestre.do_formsemestre_edit(context, args)
sco_formsemestre.do_formsemestre_edit(args)
if REQUEST:
return flask.redirect(
"formsemestre_status?formsemestre_id=%s" % formsemestre_id
@ -1550,7 +1541,7 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=
ok, err = sco_permissions_check.check_access_diretud(formsemestre_id)
if not ok:
return err
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
footer = html_sco_header.sco_footer()
help = """<p class="help">
@ -1664,11 +1655,11 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=
# apply modifications
for ue in ue_modified:
sco_formsemestre.do_formsemestre_uecoef_edit_or_create(
context, cnx, formsemestre_id, ue["ue_id"], ue["coef"]
cnx, formsemestre_id, ue["ue_id"], ue["coef"]
)
for ue in ue_deleted:
sco_formsemestre.do_formsemestre_uecoef_delete(
context, cnx, formsemestre_id, ue["ue_id"]
cnx, formsemestre_id, ue["ue_id"]
)
if ue_modified or ue_deleted:
@ -1702,7 +1693,7 @@ def formsemestre_edit_uecoefs(context, formsemestre_id, err_ue_id=None, REQUEST=
# ----- identification externe des sessions (pour SOJA et autres logiciels)
def get_formsemestre_session_id(context, sem, F, parcours):
def get_formsemestre_session_id(sem, F, parcours):
"""Identifiant de session pour ce semestre
Exemple: RT-DUT-FI-S1-ANNEE
@ -1716,8 +1707,8 @@ def get_formsemestre_session_id(context, sem, F, parcours):
ANNEE=annee universitaire de debut (exemple: un S2 de 2013-2014 sera S2-2013)
"""
# sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
# F = sco_formations.formation_list(context, args={ 'formation_id' : sem['formation_id'] } )[0]
# sem = sco_formsemestre.get_formsemestre( formsemestre_id)
# F = sco_formations.formation_list( args={ 'formation_id' : sem['formation_id'] } )[0]
# parcours = sco_codes_parcours.get_parcours_from_code(F['type_parcours'])
ImputationDept = sco_preferences.get_preference(

View File

@ -57,7 +57,7 @@ def formsemestre_ext_create(context, etudid, sem_params, REQUEST=None):
"""
# Check args
_formation = sco_formations.formation_list(
context, args={"formation_id": sem_params["formation_id"]}
args={"formation_id": sem_params["formation_id"]}
)[0]
if etudid:
_etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
@ -105,17 +105,15 @@ def formsemestre_ext_create_form(context, etudid, formsemestre_id, REQUEST=None)
),
]
F = html_sco_header.sco_footer()
orig_sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
orig_sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# Ne propose que des semestres de semestre_id strictement inférieur au semestre courant
# et seulement si pas inscrit au même semestre_id d'un semestre ordinaire ScoDoc.
# Les autres situations (eg redoublements en changeant d'établissement)
# doivent être gérées par les validations de semestres "antérieurs"
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"etudid": etudid, "etat": "I"}
args={"etudid": etudid, "etat": "I"}
)
semlist = [
sco_formsemestre.get_formsemestre(context, i["formsemestre_id"]) for i in insem
]
semlist = [sco_formsemestre.get_formsemestre(i["formsemestre_id"]) for i in insem]
existing_semestre_ids = set([s["semestre_id"] for s in semlist])
min_semestre_id = 1
max_semestre_id = orig_sem["semestre_id"]
@ -223,7 +221,7 @@ def formsemestre_ext_edit_ue_validations(
La moyenne générale du semestre est calculée et affichée,
mais pas enregistrée.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
ue_list = _list_ue_with_coef_and_validations(context, sem, etudid)
descr = _ue_form_description(context, ue_list, REQUEST.form)

View File

@ -58,19 +58,19 @@ _formsemestre_inscriptionEditor = ndb.EditableTable(
)
def do_formsemestre_inscription_list(context, *args, **kw):
def do_formsemestre_inscription_list(*args, **kw):
"list formsemestre_inscriptions"
cnx = ndb.GetDBConnexion()
return _formsemestre_inscriptionEditor.list(cnx, *args, **kw)
def do_formsemestre_inscription_listinscrits(context, formsemestre_id):
def do_formsemestre_inscription_listinscrits(formsemestre_id):
"""Liste les inscrits (état I) à ce semestre et cache le résultat"""
r = sco_cache.SemInscriptionsCache.get(formsemestre_id)
if r is None:
# retreive list
r = do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id, "etat": "I"}
args={"formsemestre_id": formsemestre_id, "etat": "I"}
)
sco_cache.SemInscriptionsCache.set(formsemestre_id, r)
return r
@ -81,7 +81,7 @@ def do_formsemestre_inscription_create(context, args, REQUEST, method=None):
cnx = ndb.GetDBConnexion()
log("do_formsemestre_inscription_create: args=%s" % str(args))
sems = sco_formsemestre.do_formsemestre_list(
context, {"formsemestre_id": args["formsemestre_id"]}
{"formsemestre_id": args["formsemestre_id"]}
)
if len(sems) != 1:
raise ScoValueError("code de semestre invalide: %s" % args["formsemestre_id"])
@ -141,7 +141,7 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non
"""
from app.scodoc import sco_formsemestre_edit
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# -- check lock
if not sem["etat"]:
raise ScoValueError("desinscription impossible: semestre verrouille")
@ -154,7 +154,7 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non
)
insem = do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id, "etudid": etudid}
args={"formsemestre_id": formsemestre_id, "etudid": etudid}
)
if not insem:
raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid)
@ -179,7 +179,7 @@ def do_formsemestre_desinscription(context, etudid, formsemestre_id, REQUEST=Non
# --- Semestre extérieur
if sem["modalite"] == "EXT":
inscrits = do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
args={"formsemestre_id": formsemestre_id}
)
nbinscrits = len(inscrits)
if nbinscrits == 0:
@ -224,13 +224,13 @@ def do_formsemestre_inscription_with_modules(
# inscriptions aux groupes
# 1- inscrit au groupe 'tous'
group_id = sco_groups.get_default_group(formsemestre_id)
sco_groups.set_group(context, etudid, group_id)
sco_groups.set_group(etudid, group_id)
gdone = {group_id: 1} # empeche doublons
# 2- inscrit aux groupes
for group_id in group_ids:
if group_id and not group_id in gdone:
sco_groups.set_group(context, etudid, group_id)
sco_groups.set_group(etudid, group_id)
gdone[group_id] = 1
# inscription a tous les modules de ce semestre
@ -289,10 +289,8 @@ def formsemestre_inscription_with_modules_form(
<h3>Choisir un semestre:</h3>"""
)
F = html_sco_header.sco_footer()
sems = sco_formsemestre.do_formsemestre_list(context, args={"etat": "1"})
insem = do_formsemestre_inscription_list(
context, args={"etudid": etudid, "etat": "I"}
)
sems = sco_formsemestre.do_formsemestre_list(args={"etat": "1"})
insem = do_formsemestre_inscription_list(args={"etudid": etudid, "etat": "I"})
if sems:
H.append("<ul>")
for sem in sems:
@ -335,7 +333,7 @@ def formsemestre_inscription_with_modules(
)
if multiple_ok:
multiple_ok = int(multiple_ok)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
H = [
html_sco_header.html_sem_header(
@ -347,7 +345,7 @@ def formsemestre_inscription_with_modules(
]
F = html_sco_header.sco_footer()
# Check 1: déjà inscrit ici ?
ins = do_formsemestre_inscription_list(context, {"etudid": etudid})
ins = do_formsemestre_inscription_list({"etudid": etudid})
already = False
for i in ins:
if i["formsemestre_id"] == formsemestre_id:
@ -426,9 +424,7 @@ def formsemestre_inscription_with_modules(
% (REQUEST.URL0, etudid, formsemestre_id)
)
H.append(
sco_groups.form_group_choice(context, formsemestre_id, allow_none=True)
)
H.append(sco_groups.form_group_choice(formsemestre_id, allow_none=True))
#
H.append(
@ -443,7 +439,7 @@ def formsemestre_inscription_with_modules(
def formsemestre_inscription_option(context, etudid, formsemestre_id, REQUEST=None):
"""Dialogue pour (dés)inscription à des modules optionnels."""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not sem["etat"]:
raise ScoValueError("Modification impossible: semestre verrouille")
@ -502,9 +498,7 @@ def formsemestre_inscription_option(context, etudid, formsemestre_id, REQUEST=No
ue_descr += " <em>%s</em>" % UE_TYPE_NAME[ue["type"]]
ue_status = nt.get_etud_ue_status(etudid, ue_id)
if ue_status["is_capitalized"]:
sem_origin = sco_formsemestre.get_formsemestre(
context, ue_status["formsemestre_id"]
)
sem_origin = sco_formsemestre.get_formsemestre(ue_status["formsemestre_id"])
ue_descr += ' <a class="discretelink" href="formsemestre_bulletinetud?formsemestre_id=%s&etudid=%s" title="%s">(capitalisée le %s)' % (
sem_origin["formsemestre_id"],
etudid,
@ -739,7 +733,7 @@ def est_inscrit_ailleurs(context, etudid, formsemestre_id):
Retourne la liste des semestres concernés (ou liste vide).
"""
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
debut_s = sem["dateord"]
fin_s = ndb.DateDMYtoISO(sem["date_fin"])
r = []
@ -769,7 +763,7 @@ def formsemestre_inscrits_ailleurs(context, formsemestre_id, REQUEST=None):
"""Page listant les étudiants inscrits dans un autre semestre
dont les dates recouvrent le semestre indiqué.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(
context,

View File

@ -130,9 +130,7 @@ def formsemestre_status_menubar(context, sem):
else:
change_lock_msg = "Déverrouiller"
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
menuSemestre = [
{
@ -336,9 +334,7 @@ def formsemestre_status_menubar(context, sem):
},
]
# 1 item / partition:
partitions = sco_groups.get_partitions_list(
context, formsemestre_id, with_default=False
)
partitions = sco_groups.get_partitions_list(formsemestre_id, with_default=False)
submenu = []
enabled = (
sco_groups.sco_permissions_check.can_change_groups(formsemestre_id)
@ -485,7 +481,7 @@ def retreive_formsemestre_from_request():
)[0]
formsemestre_id = modimpl["formsemestre_id"]
elif "group_id" in args:
group = sco_groups.get_group(context, args["group_id"])
group = sco_groups.get_group(args["group_id"])
formsemestre_id = group["formsemestre_id"]
elif group_ids:
if group_ids:
@ -494,10 +490,10 @@ def retreive_formsemestre_from_request():
else:
# prend le semestre du 1er groupe de la liste:
group_id = group_ids[0]
group = sco_groups.get_group(context, group_id)
group = sco_groups.get_group(group_id)
formsemestre_id = group["formsemestre_id"]
elif "partition_id" in args:
partition = sco_groups.get_partition(context, args["partition_id"])
partition = sco_groups.get_partition(args["partition_id"])
formsemestre_id = partition["formsemestre_id"]
else:
return None # no current formsemestre
@ -515,7 +511,7 @@ def formsemestre_page_title(context):
if not formsemestre_id:
return ""
try:
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id).copy()
sem = sco_formsemestre.get_formsemestre(formsemestre_id).copy()
except:
log("can't find formsemestre_id %s" % formsemestre_id)
return ""
@ -560,9 +556,7 @@ def fill_formsemestre(sem):
)
else:
sem["eyelink"] = ""
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
sem["formation"] = F
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
if sem["semestre_id"] != -1:
@ -579,7 +573,7 @@ def fill_formsemestre(sem):
)
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
args={"formsemestre_id": formsemestre_id}
)
sem["nbinscrits"] = len(inscrits)
uresps = [
@ -596,12 +590,10 @@ def formsemestre_description_table(
"""Description du semestre sous forme de table exportable
Liste des modules et de leurs coefficients
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > liste evaluations
use_ue_coefs = sco_preferences.get_preference("use_ue_coefs", formsemestre_id)
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
context, formsemestre_id=formsemestre_id
@ -752,7 +744,7 @@ def formsemestre_description(
tab.html_before_table += "checked"
tab.html_before_table += ">indiquer les évaluations</input></form>"
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
# genere liste html pour accès aux groupes de ce semestre
@ -809,18 +801,16 @@ def _make_listes_sem(context, sem, REQUEST=None, with_absences=True):
#
H.append('<div id="grouplists">')
# Genere liste pour chaque partition (categorie de groupes)
for partition in sco_groups.get_partitions_list(context, sem["formsemestre_id"]):
for partition in sco_groups.get_partitions_list(sem["formsemestre_id"]):
if not partition["partition_name"]:
H.append("<h4>Tous les étudiants</h4>" % partition)
else:
H.append("<h4>Groupes de %(partition_name)s</h4>" % partition)
groups = sco_groups.get_partition_groups(context, partition)
groups = sco_groups.get_partition_groups(partition)
if groups:
H.append("<table>")
for group in groups:
n_members = len(
sco_groups.get_group_members(context, group["group_id"])
)
n_members = len(sco_groups.get_group_members(group["group_id"]))
group["url_etat"] = url_for(
"absences.EtatAbsencesGr",
group_ids=group["group_id"],
@ -929,14 +919,12 @@ def formsemestre_status_head(
):
"""En-tête HTML des pages "semestre" """
semlist = sco_formsemestre.do_formsemestre_list(
context, args={"formsemestre_id": formsemestre_id}
args={"formsemestre_id": formsemestre_id}
)
if not semlist:
raise ScoValueError("Session inexistante (elle a peut être été supprimée ?)")
sem = semlist[0]
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
page_title = page_title or "Modules de "
@ -997,11 +985,11 @@ def formsemestre_status(context, formsemestre_id=None, REQUEST=None):
"""Tableau de bord semestre HTML"""
# porté du DTML
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
Mlist = sco_moduleimpl.do_moduleimpl_withmodule_list(
context, formsemestre_id=formsemestre_id
)
# inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(context,
# inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
# args={"formsemestre_id": formsemestre_id}
# )
prev_ue_id = None

View File

@ -101,7 +101,7 @@ def formsemestre_validation_etud_form(
check = True
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
if not Se.sem["etat"]:
raise ScoValueError("validation: semestre verrouille")
@ -342,7 +342,7 @@ def formsemestre_validation_etud(
):
"""Enregistre validation"""
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
# retrouve la decision correspondant au code:
choices = Se.get_possible_choices(assiduite=True)
choices += Se.get_possible_choices(assiduite=False)
@ -377,7 +377,7 @@ def formsemestre_validation_etud_manu(
if assidu:
assidu = True
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
if code_etat in Se.parcours.UNUSED_CODES:
raise ScoValueError("code decision invalide dans ce parcours")
# Si code ADC, extrait le semestre utilisé:
@ -581,7 +581,7 @@ def formsemestre_recap_parcours_table(
# indique le semestre compensé par celui ci:
if decision_sem and decision_sem["compense_formsemestre_id"]:
csem = sco_formsemestre.get_formsemestre(
context, decision_sem["compense_formsemestre_id"]
decision_sem["compense_formsemestre_id"]
)
H.append("<td><em>compense S%s</em></td>" % csem["semestre_id"])
else:
@ -827,7 +827,7 @@ def form_decision_manuelle(
# -----------
def formsemestre_validation_auto(context, formsemestre_id, REQUEST):
"Formulaire saisie automatisee des decisions d'un semestre"
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(
context, REQUEST, "Saisie automatique des décisions du semestre", sem
@ -857,7 +857,7 @@ def formsemestre_validation_auto(context, formsemestre_id, REQUEST):
def do_formsemestre_validation_auto(context, formsemestre_id, REQUEST):
"Saisie automatisee des decisions d'un semestre"
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
next_semestre_id = sem["semestre_id"] + 1
nt = sco_cache.NotesTableCache.get(
formsemestre_id
@ -867,9 +867,9 @@ def do_formsemestre_validation_auto(context, formsemestre_id, REQUEST):
conflicts = [] # liste des etudiants avec decision differente déjà saisie
for etudid in etudids:
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid, "formsemestre_id": formsemestre_id}
{"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0]
# Conditions pour validation automatique:
@ -971,7 +971,7 @@ def formsemestre_validation_suppress_etud(context, formsemestre_id, etudid):
cnx.rollback()
raise
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
_invalidate_etud_formation_caches(
context, etudid, sem["formation_id"]
) # > suppr. decision jury (peut affecter de plusieurs semestres utilisant UE capitalisée)
@ -984,10 +984,8 @@ def formsemestre_validate_previous_ue(context, formsemestre_id, etudid, REQUEST=
from app.scodoc import sco_formations
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
Fo = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
Fo = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
H = [
html_sco_header.sco_header(
@ -1124,17 +1122,15 @@ def do_formsemestre_validate_previous_ue(
Si le coefficient est spécifié, modifie le coefficient de
cette UE (utile seulement pour les semestres extérieurs).
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
cnx = ndb.GetDBConnexion(autocommit=False)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_etud_ue_status
if ue_coefficient != None:
sco_formsemestre.do_formsemestre_uecoef_edit_or_create(
context, cnx, formsemestre_id, ue_id, ue_coefficient
cnx, formsemestre_id, ue_id, ue_coefficient
)
else:
sco_formsemestre.do_formsemestre_uecoef_delete(
context, cnx, formsemestre_id, ue_id
)
sco_formsemestre.do_formsemestre_uecoef_delete(cnx, formsemestre_id, ue_id)
sco_parcours_dut.do_formsemestre_validate_ue(
cnx,
nt,
@ -1197,7 +1193,7 @@ def get_etud_ue_cap_html(context, etudid, formsemestre_id, ue_id, REQUEST=None):
else:
valid["m"] = ""
if valid["formsemestre_id"]:
sem = sco_formsemestre.get_formsemestre(context, valid["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(valid["formsemestre_id"])
valid["s"] = ", du semestre %s" % sem["titreannee"]
else:
valid["s"] = " enregistrée d'un parcours antérieur (hors ScoDoc)"
@ -1222,7 +1218,7 @@ def etud_ue_suppress_validation(context, etudid, formsemestre_id, ue_id, REQUEST
{"etudid": etudid, "ue_id": ue_id},
)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
_invalidate_etud_formation_caches(context, etudid, sem["formation_id"])
return flask.redirect(
@ -1275,7 +1271,7 @@ def check_formation_ues(context, formation_id):
for ue in ues:
if ue["ue_id"] in ue_multiples:
sems = [
sco_formsemestre.get_formsemestre(context, x["formsemestre_id"])
sco_formsemestre.get_formsemestre(x["formsemestre_id"])
for x in ue_multiples[ue["ue_id"]]
]
slist = ", ".join(

View File

@ -99,7 +99,7 @@ groupEditor = ndb.EditableTable(
group_list = groupEditor.list
def get_group(context, group_id):
def get_group(group_id):
"""Returns group object, with partition"""
r = ndb.SimpleDictFetch(
"""SELECT gd.id AS group_id, gd.*, p.id AS partition_id, p.*
@ -114,7 +114,7 @@ def get_group(context, group_id):
return r[0]
def group_delete(context, group, force=False):
def group_delete(group, force=False):
"""Delete a group."""
# if not group['group_name'] and not force:
# raise ValueError('cannot suppress this group')
@ -124,7 +124,7 @@ def group_delete(context, group, force=False):
ndb.SimpleQuery("DELETE FROM group_descr WHERE id=%(group_id)s", group)
def get_partition(context, partition_id):
def get_partition(partition_id):
r = ndb.SimpleDictFetch(
"""SELECT p.id AS partition_id, p.*
FROM partition p
@ -137,7 +137,7 @@ def get_partition(context, partition_id):
return r[0]
def get_partitions_list(context, formsemestre_id, with_default=True):
def get_partitions_list(formsemestre_id, with_default=True):
"""Liste des partitions pour ce semestre (list of dicts)"""
partitions = ndb.SimpleDictFetch(
"""SELECT p.id AS partition_id, p.*
@ -153,7 +153,7 @@ def get_partitions_list(context, formsemestre_id, with_default=True):
return R
def get_default_partition(context, formsemestre_id):
def get_default_partition(formsemestre_id):
"""Get partition for 'all' students (this one always exists, with NULL name)"""
r = ndb.SimpleDictFetch(
"""SELECT p.id AS partition_id, p.* FROM partition p
@ -170,19 +170,17 @@ def get_default_partition(context, formsemestre_id):
return r[0]
def get_formsemestre_groups(context, formsemestre_id, with_default=False):
def get_formsemestre_groups(formsemestre_id, with_default=False):
"""Returns ( partitions, { partition_id : { etudid : group } } )."""
partitions = get_partitions_list(
context, formsemestre_id, with_default=with_default
)
partitions = get_partitions_list(formsemestre_id, with_default=with_default)
partitions_etud_groups = {} # { partition_id : { etudid : group } }
for partition in partitions:
pid = partition["partition_id"]
partitions_etud_groups[pid] = get_etud_groups_in_partition(context, pid)
partitions_etud_groups[pid] = get_etud_groups_in_partition(pid)
return partitions, partitions_etud_groups
def get_partition_groups(context, partition):
def get_partition_groups(partition):
"""List of groups in this partition (list of dicts).
Some groups may be empty."""
return ndb.SimpleDictFetch(
@ -198,7 +196,6 @@ def get_partition_groups(context, partition):
def get_default_group(formsemestre_id, fix_if_missing=False):
"""Returns group_id for default ('tous') group"""
context = None # #context
r = ndb.SimpleDictFetch(
"""SELECT gd.id AS group_id
FROM group_descr gd, partition p
@ -216,15 +213,13 @@ def get_default_group(formsemestre_id, fix_if_missing=False):
% formsemestre_id
)
try:
partition_id = get_default_partition(context, formsemestre_id)[
"partition_id"
]
partition_id = get_default_partition(formsemestre_id)["partition_id"]
except ScoException:
log("creating default partition for %s" % formsemestre_id)
partition_id = partition_create(
context, formsemestre_id, default=True, redirect=False
formsemestre_id, default=True, redirect=False
)
group_id = createGroup(context, partition_id, default=True)
group_id = createGroup(partition_id, default=True)
return group_id
# debug check
if len(r) != 1:
@ -233,7 +228,7 @@ def get_default_group(formsemestre_id, fix_if_missing=False):
return group_id
def get_sem_groups(context, formsemestre_id):
def get_sem_groups(formsemestre_id):
"""Returns groups for this sem (in all partitions)."""
return ndb.SimpleDictFetch(
"""SELECT gd.id AS group_id, p.id AS partition_id, gd.*, p.*
@ -245,7 +240,7 @@ def get_sem_groups(context, formsemestre_id):
)
def get_group_members(context, group_id, etat=None):
def get_group_members(group_id, etat=None):
"""Liste des etudiants d'un groupe.
Si etat, filtre selon l'état de l'inscription
Trié par nom_usuel (ou nom) puis prénom
@ -279,14 +274,14 @@ def get_group_members(context, group_id, etat=None):
# obsolete: sco_groups_view.DisplayedGroupsInfos
# def get_groups_members(context, group_ids, etat=None):
# def get_groups_members(group_ids, etat=None):
# """Liste les étudiants d'une liste de groupes
# chaque étudiant n'apparait qu'une seule fois dans le résultat.
# La liste est triée par nom / prenom
# """
# D = {} # { etudid : etud }
# for group_id in group_ids:
# members = get_group_members(context, group_id, etat=etat)
# members = get_group_members(group_id, etat=etat)
# for m in members:
# D[m['etudid']] = m
# r = D.values()
@ -295,15 +290,15 @@ def get_group_members(context, group_id, etat=None):
# return r
def get_group_infos(context, group_id, etat=None): # was _getlisteetud
def get_group_infos(group_id, etat=None): # was _getlisteetud
"""legacy code: used by group_list and trombino"""
from app.scodoc import sco_formsemestre
cnx = ndb.GetDBConnexion()
group = get_group(context, group_id)
sem = sco_formsemestre.get_formsemestre(context, group["formsemestre_id"])
group = get_group(group_id)
sem = sco_formsemestre.get_formsemestre(group["formsemestre_id"])
members = get_group_members(context, group_id, etat=etat)
members = get_group_members(group_id, etat=etat)
# add human readable description of state:
nbdem = 0
for t in members:
@ -333,7 +328,7 @@ def get_group_infos(context, group_id, etat=None): # was _getlisteetud
t["etath"] = t["etat"]
# Add membership for all partitions, 'partition_id' : group
for etud in members: # long: comment eviter ces boucles ?
etud_add_group_infos(context, etud, sem)
etud_add_group_infos(etud, sem)
if group["group_name"] != None:
group_tit = "%s %s" % (group["partition_name"], group["group_name"])
@ -343,19 +338,19 @@ def get_group_infos(context, group_id, etat=None): # was _getlisteetud
return members, group, group_tit, sem, nbdem
def get_group_other_partitions(context, group):
def get_group_other_partitions(group):
"""Liste des partitions du même semestre que ce groupe,
sans celle qui contient ce groupe.
"""
other_partitions = [
p
for p in get_partitions_list(context, group["formsemestre_id"])
for p in get_partitions_list(group["formsemestre_id"])
if p["partition_id"] != group["partition_id"] and p["partition_name"]
]
return other_partitions
def get_etud_groups(context, etudid, sem, exclude_default=False):
def get_etud_groups(etudid, sem, exclude_default=False):
"""Infos sur groupes de l'etudiant dans ce semestre
[ group + partition_name ]
"""
@ -375,23 +370,23 @@ def get_etud_groups(context, etudid, sem, exclude_default=False):
return _sortgroups(groups)
def get_etud_main_group(context, etudid, sem):
def get_etud_main_group(etudid, sem):
"""Return main group (the first one) for etud, or default one if no groups"""
groups = get_etud_groups(context, etudid, sem, exclude_default=True)
groups = get_etud_groups(etudid, sem, exclude_default=True)
if groups:
return groups[0]
else:
return get_group(context, get_default_group(sem["formsemestre_id"]))
return get_group(get_default_group(sem["formsemestre_id"]))
def formsemestre_get_main_partition(context, formsemestre_id):
def formsemestre_get_main_partition(formsemestre_id):
"""Return main partition (the first one) for sem, or default one if no groups
(rappel: default == tous, main == principale (groupes TD habituellement)
"""
return get_partitions_list(context, formsemestre_id, with_default=True)[0]
return get_partitions_list(formsemestre_id, with_default=True)[0]
def formsemestre_get_etud_groupnames(context, formsemestre_id, attr="group_name"):
def formsemestre_get_etud_groupnames(formsemestre_id, attr="group_name"):
"""Recupere les groupes de tous les etudiants d'un semestre
{ etudid : { partition_id : group_name }} (attr=group_name or group_id)
"""
@ -418,7 +413,7 @@ def formsemestre_get_etud_groupnames(context, formsemestre_id, attr="group_name"
return R
def etud_add_group_infos(context, etud, sem, sep=" "):
def etud_add_group_infos(etud, sem, sep=" "):
"""Add informations on partitions and group memberships to etud (a dict with an etudid)"""
etud[
"partitions"
@ -457,7 +452,7 @@ def etud_add_group_infos(context, etud, sem, sep=" "):
return etud
def get_etud_groups_in_partition(context, partition_id):
def get_etud_groups_in_partition(partition_id):
"""Returns { etudid : group }, with all students in this partition"""
infos = ndb.SimpleDictFetch(
"""SELECT gd.id AS group_id, gd.*, etudid
@ -473,19 +468,19 @@ def get_etud_groups_in_partition(context, partition_id):
return R
def formsemestre_partition_list(context, formsemestre_id, format="xml", REQUEST=None):
def formsemestre_partition_list(formsemestre_id, format="xml", REQUEST=None):
"""Get partitions and groups in this semestre
Supported formats: xml, json
"""
partitions = get_partitions_list(context, formsemestre_id, with_default=True)
partitions = get_partitions_list(formsemestre_id, with_default=True)
# Ajoute les groupes
for p in partitions:
p["group"] = get_partition_groups(context, p)
p["group"] = get_partition_groups(p)
return scu.sendResult(REQUEST, partitions, name="partition", format=format)
# Encore utilisé par groupmgr.js
def XMLgetGroupsInPartition(context, partition_id, REQUEST=None): # was XMLgetGroupesTD
def XMLgetGroupsInPartition(partition_id, REQUEST=None): # was XMLgetGroupesTD
"""
Deprecated: use group_list
Liste des étudiants dans chaque groupe de cette partition.
@ -498,10 +493,10 @@ def XMLgetGroupsInPartition(context, partition_id, REQUEST=None): # was XMLgetG
from app.scodoc import sco_formsemestre
t0 = time.time()
partition = get_partition(context, partition_id)
partition = get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
groups = get_partition_groups(context, partition)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
groups = get_partition_groups(partition)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > inscrdict
etuds_set = set(nt.inscrdict)
# XML response:
@ -518,7 +513,7 @@ def XMLgetGroupsInPartition(context, partition_id, REQUEST=None): # was XMLgetG
group_name=group["group_name"],
)
x_response.append(x_group)
for e in get_group_members(context, group["group_id"]):
for e in get_group_members(group["group_id"]):
etud = sco_etud.get_etud_info(etudid=e["etudid"], filled=1)[0]
x_group.append(
Element(
@ -581,7 +576,7 @@ def comp_origin(etud, cur_sem):
return "" # parcours normal, ne le signale pas
def set_group(context, etudid, group_id):
def set_group(etudid, group_id):
"""Inscrit l'étudiant au groupe.
Return True if ok, False si deja inscrit.
Warning: don't check if group_id exists (the caller should check).
@ -606,14 +601,12 @@ def set_group(context, etudid, group_id):
return True
def change_etud_group_in_partition(
context, etudid, group_id, partition=None, REQUEST=None
):
def change_etud_group_in_partition(etudid, group_id, partition=None, REQUEST=None):
"""Inscrit etud au groupe de cette partition, et le desinscrit d'autres groupes de cette partition."""
log("change_etud_group_in_partition: etudid=%s group_id=%s" % (etudid, group_id))
# 0- La partition
group = get_group(context, group_id)
group = get_group(group_id)
if partition:
# verifie que le groupe est bien dans cette partition:
if group["partition_id"] != partition["partition_id"]:
@ -622,7 +615,7 @@ def change_etud_group_in_partition(
% (group_id, partition["partition_id"])
)
else:
partition = get_partition(context, group["partition_id"])
partition = get_partition(group["partition_id"])
# 1- Supprime membership dans cette partition
ndb.SimpleQuery(
"""DELETE FROM group_membership gm
@ -635,7 +628,7 @@ def change_etud_group_in_partition(
{"etudid": etudid, "partition_id": partition["partition_id"]},
)
# 2- associe au nouveau groupe
set_group(context, etudid, group_id)
set_group(etudid, group_id)
# 3- log
formsemestre_id = partition["formsemestre_id"]
@ -656,7 +649,6 @@ def change_etud_group_in_partition(
def setGroups(
context,
partition_id,
groupsLists="", # members of each existing group
groupsToCreate="", # name and members of new groups
@ -670,7 +662,7 @@ def setGroups(
"""
from app.scodoc import sco_formsemestre
partition = get_partition(context, partition_id)
partition = get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"]
if not sco_permissions_check.can_change_groups(formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
@ -678,23 +670,21 @@ def setGroups(
log("groupsLists=%s" % groupsLists)
log("groupsToCreate=%s" % groupsToCreate)
log("groupsToDelete=%s" % groupsToDelete)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not sem["etat"]:
raise AccessDenied("Modification impossible: semestre verrouillé")
groupsToDelete = [g for g in groupsToDelete.split(";") if g]
etud_groups = formsemestre_get_etud_groupnames(
context, formsemestre_id, attr="group_id"
)
etud_groups = formsemestre_get_etud_groupnames(formsemestre_id, attr="group_id")
for line in groupsLists.split("\n"): # for each group_id (one per line)
fs = line.split(";")
group_id = fs[0].strip()
if not group_id:
continue
group = get_group(context, group_id)
group = get_group(group_id)
# Anciens membres du groupe:
old_members = get_group_members(context, group_id)
old_members = get_group_members(group_id)
old_members_set = set([x["etudid"] for x in old_members])
# Place dans ce groupe les etudiants indiqués:
for etudid_str in fs[1:-1]:
@ -707,7 +697,7 @@ def setGroups(
group_id != etud_groups[etudid].get(partition_id, "")
): # pas le meme groupe qu'actuel
change_etud_group_in_partition(
context, etudid, group_id, partition, REQUEST=REQUEST
etudid, group_id, partition, REQUEST=REQUEST
)
# Retire les anciens membres:
cnx = ndb.GetDBConnexion()
@ -729,7 +719,7 @@ def setGroups(
# Supprime les groupes indiqués comme supprimés:
for group_id in groupsToDelete:
suppressGroup(context, group_id, partition_id=partition_id, REQUEST=REQUEST)
suppressGroup(group_id, partition_id=partition_id, REQUEST=REQUEST)
# Crée les nouveaux groupes
for line in groupsToCreate.split("\n"): # for each group_name (one per line)
@ -741,12 +731,10 @@ def setGroups(
# group_name = six.text_type(group_name, "utf-8").encode(
# scu.SCO_ENCODING
# ) # #py3 #sco8
group_id = createGroup(context, partition_id, group_name)
group_id = createGroup(partition_id, group_name)
# Place dans ce groupe les etudiants indiqués:
for etudid in fs[1:-1]:
change_etud_group_in_partition(
context, etudid, group_id, partition, REQUEST=REQUEST
)
change_etud_group_in_partition(etudid, group_id, partition, REQUEST=REQUEST)
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
return (
@ -754,9 +742,9 @@ def setGroups(
)
def createGroup(context, partition_id, group_name="", default=False):
def createGroup(partition_id, group_name="", default=False):
"""Create a new group in this partition"""
partition = get_partition(context, partition_id)
partition = get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"]
if not sco_permissions_check.can_change_groups(formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
@ -766,9 +754,7 @@ def createGroup(context, partition_id, group_name="", default=False):
if not group_name and not default:
raise ValueError("invalid group name: ()")
# checkGroupName(group_name)
if group_name in [
g["group_name"] for g in get_partition_groups(context, partition)
]:
if group_name in [g["group_name"] for g in get_partition_groups(partition)]:
raise ValueError(
"group_name %s already exists in partition" % group_name
) # XXX FIX: incorrect error handling (in AJAX)
@ -781,31 +767,30 @@ def createGroup(context, partition_id, group_name="", default=False):
return group_id
def suppressGroup(context, group_id, partition_id=None, REQUEST=None):
def suppressGroup(group_id, partition_id=None, REQUEST=None):
"""form suppression d'un groupe.
(ne desinscrit pas les etudiants, change juste leur
affectation aux groupes)
partition_id est optionnel et ne sert que pour verifier que le groupe
est bien dans cette partition.
"""
group = get_group(context, group_id)
group = get_group(group_id)
if partition_id:
if partition_id != group["partition_id"]:
raise ValueError("inconsistent partition/group")
else:
partition_id = group["partition_id"]
partition = get_partition(context, partition_id)
partition = get_partition(partition_id)
if not sco_permissions_check.can_change_groups(partition["formsemestre_id"]):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
log(
"suppressGroup: group_id=%s group_name=%s partition_name=%s"
% (group_id, group["group_name"], partition["partition_name"])
)
group_delete(context, group)
group_delete(group)
def partition_create(
context,
formsemestre_id,
partition_name="",
default=False,
@ -824,7 +809,7 @@ def partition_create(
redirect = int(redirect)
# checkGroupName(partition_name)
if partition_name in [
p["partition_name"] for p in get_partitions_list(context, formsemestre_id)
p["partition_name"] for p in get_partitions_list(formsemestre_id)
]:
raise ScoValueError(
"Il existe déjà une partition %s dans ce semestre" % partition_name
@ -858,12 +843,12 @@ def getArrowIconsTags():
return arrow_up, arrow_down, arrow_none
def editPartitionForm(context, formsemestre_id=None, REQUEST=None):
def editPartitionForm(formsemestre_id=None, REQUEST=None):
"""Form to create/suppress partitions"""
# ad-hoc form
if not sco_permissions_check.can_change_groups(formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
partitions = get_partitions_list(context, formsemestre_id)
partitions = get_partitions_list(formsemestre_id)
arrow_up, arrow_down, arrow_none = getArrowIconsTags()
suppricon = scu.icontag(
"delete_small_img", border="0", alt="supprimer", title="Supprimer"
@ -918,9 +903,9 @@ def editPartitionForm(context, formsemestre_id=None, REQUEST=None):
"%s (%d)"
% (
group["group_name"],
len(get_group_members(context, group["group_id"])),
len(get_group_members(group["group_id"])),
)
for group in get_partition_groups(context, p)
for group in get_partition_groups(p)
]
H.append(", ".join(lg))
H.append(
@ -986,12 +971,12 @@ def editPartitionForm(context, formsemestre_id=None, REQUEST=None):
return "\n".join(H) + html_sco_header.sco_footer()
def partition_set_attr(context, partition_id, attr, value, REQUEST=None):
def partition_set_attr(partition_id, attr, value, REQUEST=None):
"""Set partition attribute: bul_show_rank or show_in_lists"""
if attr not in {"bul_show_rank", "show_in_lists"}:
raise ValueError("invalid partition attribute: %s" % attr)
partition = get_partition(context, partition_id)
partition = get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"]
if not sco_permissions_check.can_change_groups(formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
@ -1010,11 +995,11 @@ def partition_set_attr(context, partition_id, attr, value, REQUEST=None):
def partition_delete(
context, partition_id, REQUEST=None, force=False, redirect=1, dialog_confirmed=False
partition_id, REQUEST=None, force=False, redirect=1, dialog_confirmed=False
):
"""Suppress a partition (and all groups within).
default partition cannot be suppressed (unless force)"""
partition = get_partition(context, partition_id)
partition = get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"]
if not sco_permissions_check.can_change_groups(formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
@ -1023,7 +1008,7 @@ def partition_delete(
raise ValueError("cannot suppress this partition")
redirect = int(redirect)
cnx = ndb.GetDBConnexion()
groups = get_partition_groups(context, partition)
groups = get_partition_groups(partition)
if not dialog_confirmed:
if groups:
@ -1043,7 +1028,7 @@ def partition_delete(
log("partition_delete: partition_id=%s" % partition_id)
# 1- groups
for group in groups:
group_delete(context, group, force=force)
group_delete(group, force=force)
# 2- partition
partitionEditor.delete(cnx, partition_id)
@ -1054,9 +1039,9 @@ def partition_delete(
)
def partition_move(context, partition_id, after=0, REQUEST=None, redirect=1):
def partition_move(partition_id, after=0, REQUEST=None, redirect=1):
"""Move before/after previous one (decrement/increment numero)"""
partition = get_partition(context, partition_id)
partition = get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"]
if not sco_permissions_check.can_change_groups(formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
@ -1065,7 +1050,7 @@ def partition_move(context, partition_id, after=0, REQUEST=None, redirect=1):
after = int(after) # 0: deplace avant, 1 deplace apres
if after not in (0, 1):
raise ValueError('invalid value for "after"')
others = get_partitions_list(context, formsemestre_id)
others = get_partitions_list(formsemestre_id)
if len(others) > 1:
pidx = [p["partition_id"] for p in others].index(partition_id)
log("partition_move: after=%s pidx=%s" % (after, pidx))
@ -1089,9 +1074,9 @@ def partition_move(context, partition_id, after=0, REQUEST=None, redirect=1):
)
def partition_rename(context, partition_id, REQUEST=None):
def partition_rename(partition_id, REQUEST=None):
"""Form to rename a partition"""
partition = get_partition(context, partition_id)
partition = get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"]
if not sco_permissions_check.can_change_groups(formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
@ -1129,16 +1114,16 @@ def partition_rename(context, partition_id, REQUEST=None):
else:
# form submission
return partition_set_name(
context, partition_id, tf[2]["partition_name"], REQUEST=REQUEST, redirect=1
partition_id, tf[2]["partition_name"], REQUEST=REQUEST, redirect=1
)
def partition_set_name(context, partition_id, partition_name, REQUEST=None, redirect=1):
def partition_set_name(partition_id, partition_name, REQUEST=None, redirect=1):
"""Set partition name"""
partition_name = partition_name.strip()
if not partition_name:
raise ValueError("partition name must be non empty")
partition = get_partition(context, partition_id)
partition = get_partition(partition_id)
if partition["partition_name"] is None:
raise ValueError("can't set a name to default partition")
formsemestre_id = partition["formsemestre_id"]
@ -1171,13 +1156,13 @@ def partition_set_name(context, partition_id, partition_name, REQUEST=None, redi
)
def group_set_name(context, group_id, group_name, REQUEST=None, redirect=1):
def group_set_name(group_id, group_name, REQUEST=None, redirect=1):
"""Set group name"""
if group_name:
group_name = group_name.strip()
if not group_name:
raise ScoValueError("nom de groupe vide !")
group = get_group(context, group_id)
group = get_group(group_id)
if group["group_name"] is None:
raise ValueError("can't set a name to default group")
formsemestre_id = group["formsemestre_id"]
@ -1198,9 +1183,9 @@ def group_set_name(context, group_id, group_name, REQUEST=None, redirect=1):
)
def group_rename(context, group_id, REQUEST=None):
def group_rename(group_id, REQUEST=None):
"""Form to rename a group"""
group = get_group(context, group_id)
group = get_group(group_id)
formsemestre_id = group["formsemestre_id"]
if not sco_permissions_check.can_change_groups(formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
@ -1242,17 +1227,17 @@ def group_rename(context, group_id, REQUEST=None):
else:
# form submission
return group_set_name(
context, group_id, tf[2]["group_name"], REQUEST=REQUEST, redirect=1
group_id, tf[2]["group_name"], REQUEST=REQUEST, redirect=1
)
def groups_auto_repartition(context, partition_id=None, REQUEST=None):
def groups_auto_repartition(partition_id=None, REQUEST=None):
"""Reparti les etudiants dans des groupes dans une partition, en respectant le niveau
et la mixité.
"""
from app.scodoc import sco_formsemestre
partition = get_partition(context, partition_id)
partition = get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"]
# renvoie sur page édition groupes
dest_url = url_for(
@ -1260,7 +1245,7 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None):
)
if not sco_permissions_check.can_change_groups(formsemestre_id):
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
descr = [
("partition_id", {"input_type": "hidden"}),
@ -1308,8 +1293,8 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None):
groupNames = tf[2]["groupNames"]
group_names = sorted(set([x.strip() for x in groupNames.split(",")]))
# Détruit les groupes existant de cette partition
for old_group in get_partition_groups(context, partition):
group_delete(context, old_group)
for old_group in get_partition_groups(partition):
group_delete(old_group)
# Crée les nouveaux groupes
group_ids = []
for group_name in group_names:
@ -1318,7 +1303,7 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None):
# except:
# H.append('<p class="warning">Nom de groupe invalide: %s</p>'%group_name)
# return '\n'.join(H) + tf[1] + html_sco_header.sco_footer( REQUEST)
group_ids.append(createGroup(context, partition_id, group_name))
group_ids.append(createGroup(partition_id, group_name))
#
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > identdict
identdict = nt.identdict
@ -1327,7 +1312,7 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None):
listes = {}
for civilite in civilites:
listes[civilite] = [
(get_prev_moy(context, x["etudid"], formsemestre_id), x["etudid"])
(_get_prev_moy(x["etudid"], formsemestre_id), x["etudid"])
for x in identdict.values()
if x["civilite"] == civilite
]
@ -1345,13 +1330,13 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None):
group_id = group_ids[igroup]
igroup = (igroup + 1) % nbgroups
change_etud_group_in_partition(
context, etudid, group_id, partition, REQUEST=REQUEST
etudid, group_id, partition, REQUEST=REQUEST
)
log("%s in group %s" % (etudid, group_id))
return flask.redirect(dest_url)
def get_prev_moy(context, etudid, formsemestre_id):
def _get_prev_moy(etudid, formsemestre_id):
"""Donne la derniere moyenne generale calculee pour cette étudiant,
ou 0 si on n'en trouve pas (nouvel inscrit,...).
"""
@ -1361,7 +1346,7 @@ def get_prev_moy(context, etudid, formsemestre_id):
if not info:
raise ScoValueError("etudiant invalide: etudid=%s" % etudid)
etud = info[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
if Se.prev:
nt = sco_cache.NotesTableCache.get(
Se.prev["formsemestre_id"]
@ -1371,7 +1356,7 @@ def get_prev_moy(context, etudid, formsemestre_id):
return 0.0
def create_etapes_partition(context, formsemestre_id, partition_name="apo_etapes"):
def create_etapes_partition(formsemestre_id, partition_name="apo_etapes"):
"""Crée une partition "apo_etapes" avec un groupe par étape Apogée.
Cette partition n'est crée que si plusieurs étapes différentes existent dans ce
semestre.
@ -1382,10 +1367,10 @@ def create_etapes_partition(context, formsemestre_id, partition_name="apo_etapes
log("create_etapes_partition(%s)" % formsemestre_id)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
args={"formsemestre_id": formsemestre_id}
)
etapes = {i["etape"] for i in ins if i["etape"]}
partitions = get_partitions_list(context, formsemestre_id, with_default=False)
partitions = get_partitions_list(formsemestre_id, with_default=False)
partition = None
for p in partitions:
if p["partition_name"] == partition_name:
@ -1397,21 +1382,21 @@ def create_etapes_partition(context, formsemestre_id, partition_name="apo_etapes
pid = partition["partition_id"]
else:
pid = partition_create(
context, formsemestre_id, partition_name=partition_name, redirect=False
formsemestre_id, partition_name=partition_name, redirect=False
)
partition = get_partition(context, pid)
groups = get_partition_groups(context, partition)
partition = get_partition(pid)
groups = get_partition_groups(partition)
groups_by_names = {g["group_name"]: g for g in groups}
for etape in etapes:
if not (etape in groups_by_names):
gid = createGroup(context, pid, etape)
g = get_group(context, gid)
gid = createGroup(pid, etape)
g = get_group(gid)
groups_by_names[etape] = g
# Place les etudiants dans les groupes
for i in ins:
if i["etape"]:
change_etud_group_in_partition(
context, i["etudid"], groups_by_names[i["etape"]]["group_id"], partition
i["etudid"], groups_by_names[i["etape"]]["group_id"], partition
)
@ -1466,7 +1451,7 @@ def do_evaluation_listeetuds_groups(
return [x[0] for x in res]
def do_evaluation_listegroupes(context, evaluation_id, include_default=False):
def do_evaluation_listegroupes(evaluation_id, include_default=False):
"""Donne la liste des groupes dans lesquels figurent des etudiants inscrits
au module/semestre auquel appartient cette evaluation.
Si include_default, inclue aussi le groupe par defaut ('tous')
@ -1493,10 +1478,10 @@ def do_evaluation_listegroupes(context, evaluation_id, include_default=False):
)
res = cursor.fetchall()
group_ids = [x[0] for x in res]
return listgroups(context, group_ids)
return listgroups(group_ids)
def listgroups(context, group_ids):
def listgroups(group_ids):
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
groups = []
@ -1540,7 +1525,6 @@ def listgroups_abbrev(groups):
# form_group_choice replaces formChoixGroupe
def form_group_choice(
context,
formsemestre_id,
allow_none=True, # offre un choix vide dans chaque partition
select_default=True, # Le groupe par defaut est mentionné (hidden).
@ -1551,26 +1535,26 @@ def form_group_choice(
"""
from app.scodoc import sco_formsemestre
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if display_sem_title:
sem_title = "%s: " % sem["titremois"]
else:
sem_title = ""
#
H = ["""<table>"""]
for p in get_partitions_list(context, formsemestre_id):
for p in get_partitions_list(formsemestre_id):
if p["partition_name"] is None:
if select_default:
H.append(
'<input type="hidden" name="group_ids:list" value="%s"/>'
% get_partition_groups(context, p)[0]["group_id"]
% get_partition_groups(p)[0]["group_id"]
)
else:
H.append("<tr><td>Groupe de %(partition_name)s</td><td>" % p)
H.append('<select name="group_ids:list">')
if allow_none:
H.append('<option value="">aucun</option>')
for group in get_partition_groups(context, p):
for group in get_partition_groups(p):
H.append(
'<option value="%s">%s %s</option>'
% (group["group_id"], sem_title, group["group_name"])
@ -1596,8 +1580,8 @@ class GroupIdInferer(object):
partition_name:group_name
"""
def __init__(self, context, formsemestre_id):
groups = get_sem_groups(context, formsemestre_id)
def __init__(self, formsemestre_id):
groups = get_sem_groups(formsemestre_id)
self.name2group_id = {}
self.partitionname2group_id = {}
for group in groups:

View File

@ -38,7 +38,7 @@ def affectGroups(context, partition_id, REQUEST=None):
Permet aussi la creation et la suppression de groupes.
"""
# Ported from DTML and adapted to new group management (nov 2009)
partition = sco_groups.get_partition(context, partition_id)
partition = sco_groups.get_partition(partition_id)
formsemestre_id = partition["formsemestre_id"]
if not sco_groups.sco_permissions_check.can_change_groups(formsemestre_id):
raise AccessDenied("vous n'avez pas la permission d'effectuer cette opération")
@ -73,9 +73,7 @@ Editer groupes de
<select name="other_partition_id" onchange="GotoAnother();">"""
% formsemestre_id,
]
for p in sco_groups.get_partitions_list(
context, formsemestre_id, with_default=False
):
for p in sco_groups.get_partitions_list(formsemestre_id, with_default=False):
H.append('<option value="%s"' % p["partition_id"])
if p["partition_id"] == partition_id:
H.append(" selected")

View File

@ -212,7 +212,7 @@ def menu_groups_choice(context, groups_infos, submit_on_change=False):
% (klass,)
]
n_members = len(sco_groups.get_group_members(context, default_group_id))
n_members = len(sco_groups.get_group_members(default_group_id))
if default_group_id in groups_infos.group_ids:
selected = "selected"
else:
@ -225,13 +225,13 @@ def menu_groups_choice(context, groups_infos, submit_on_change=False):
for partition in groups_infos.partitions:
H.append('<optgroup label="%s">' % partition["partition_name"])
# Les groupes dans cette partition:
for g in sco_groups.get_partition_groups(context, partition):
for g in sco_groups.get_partition_groups(partition):
if g["group_id"] in groups_infos.group_ids:
selected = "selected"
else:
selected = ""
if g["group_name"]:
n_members = len(sco_groups.get_group_members(context, g["group_id"]))
n_members = len(sco_groups.get_group_members(g["group_id"]))
H.append(
'<option value="%s" %s>%s (%s)</option>'
% (g["group_id"], selected, g["group_name"], n_members)
@ -247,7 +247,7 @@ def menu_group_choice(context, group_id=None, formsemestre_id=None):
Si aucun groupe selectionné, utilise formsemestre_id pour lister les groupes.
"""
if group_id:
group = sco_groups.get_group(context, group_id)
group = sco_groups.get_group(group_id)
formsemestre_id = group["formsemestre_id"]
elif not formsemestre_id:
raise ValueError("missing formsemestre_id")
@ -258,17 +258,17 @@ def menu_group_choice(context, group_id=None, formsemestre_id=None):
]
if not group_id:
H.append('<option value="">choisir...</option>')
for partition in sco_groups.get_partitions_list(context, formsemestre_id):
for partition in sco_groups.get_partitions_list(formsemestre_id):
if partition["partition_name"]:
H.append('<optgroup label="%s">' % partition["partition_name"])
groups = sco_groups.get_partition_groups(context, partition)
groups = sco_groups.get_partition_groups(partition)
for group in groups:
if group["group_id"] == group_id:
selected = "selected"
else:
selected = ""
name = group["group_name"] or "Tous"
n_members = len(sco_groups.get_group_members(context, group["group_id"]))
n_members = len(sco_groups.get_group_members(group["group_id"]))
H.append(
'<option value="%s" %s>%s (%s)</option>'
% (group["group_id"], selected, name, n_members)
@ -334,9 +334,9 @@ class DisplayedGroupsInfos(object):
else:
# selectionne le premier groupe trouvé, s'il y en a un
partition = sco_groups.get_partitions_list(
context, formsemestre_id, with_default=True
formsemestre_id, with_default=True
)[0]
groups = sco_groups.get_partition_groups(context, partition)
groups = sco_groups.get_partition_groups(partition)
if groups:
group_ids = [groups[0]["group_id"]]
else:
@ -362,7 +362,7 @@ class DisplayedGroupsInfos(object):
selected_partitions = set()
for group_id in group_ids:
group_members, group, group_tit, sem, nbdem = sco_groups.get_group_infos(
context, group_id, etat=etat
group_id, etat=etat
)
self.groups.append(group)
self.nbdem += nbdem
@ -383,9 +383,7 @@ class DisplayedGroupsInfos(object):
] # -> [ partition_id ]
if not self.formsemestre: # aucun groupe selectionne
self.formsemestre = sco_formsemestre.get_formsemestre(
context, formsemestre_id
)
self.formsemestre = sco_formsemestre.get_formsemestre(formsemestre_id)
self.sortuniq()
@ -407,7 +405,7 @@ class DisplayedGroupsInfos(object):
# gère le cas où les étudiants appartiennent à des semestres différents
self.partitions = [] # les partitions, sans celle par defaut
for formsemestre_id in self.sems:
for partition in sco_groups.get_partitions_list(context, formsemestre_id):
for partition in sco_groups.get_partitions_list(formsemestre_id):
if partition["partition_name"]:
self.partitions.append(partition)
@ -723,7 +721,7 @@ def groups_table(
):
if format == "moodlecsv":
format = "csv"
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
elif format == "xlsappel":
xls = sco_excel.excel_feuille_listeappel(
@ -779,9 +777,7 @@ def groups_table(
"codeparcours",
]
titles = keys[:]
other_partitions = sco_groups.get_group_other_partitions(
context, groups_infos.groups[0]
)
other_partitions = sco_groups.get_group_other_partitions(groups_infos.groups[0])
keys += [p["partition_id"] for p in other_partitions]
titles += [p["partition_name"] for p in other_partitions]
# remplis infos lycee si on a que le code lycée
@ -792,7 +788,7 @@ def groups_table(
sco_etud.etud_add_lycee_infos(etud)
# et ajoute le parcours
Se = sco_parcours_dut.SituationEtudParcours(
context, etud, groups_infos.formsemestre_id
etud, groups_infos.formsemestre_id
)
m["parcours"] = Se.get_parcours_descr()
m["codeparcours"], _ = sco_report.get_codeparcoursetud(context, etud)
@ -970,15 +966,15 @@ def export_groups_as_moodle_csv(context, formsemestre_id=None, REQUEST=None):
if not formsemestre_id:
raise ScoValueError("missing parameter: formsemestre_id")
_, partitions_etud_groups = sco_groups.get_formsemestre_groups(
context, formsemestre_id, with_default=True
formsemestre_id, with_default=True
)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
moodle_sem_name = sem["session_id"]
columns_ids = ("email", "semestre_groupe")
T = []
for partition_id in partitions_etud_groups:
partition = sco_groups.get_partition(context, partition_id)
partition = sco_groups.get_partition(partition_id)
members = partitions_etud_groups[partition_id]
for etudid in members:
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
@ -1000,4 +996,4 @@ def export_groups_as_moodle_csv(context, formsemestre_id=None, REQUEST=None):
text_with_titles=prefs["moodle_csv_with_headerline"],
preferences=prefs,
)
return tab.make_page(context, format="csv", REQUEST=REQUEST)
return tab.make_page(format="csv", REQUEST=REQUEST)

View File

@ -207,7 +207,7 @@ def sco_import_generate_excel_sample(
for field in titles:
if field == "groupes":
sco_groups.etud_add_group_infos(
context, etud, groups_infos.formsemestre, sep=";"
etud, groups_infos.formsemestre, sep=";"
)
l.append(etud["partitionsgroupes"])
else:
@ -563,9 +563,7 @@ def _import_one_student(
formsemestre_id = values["codesemestre"]
# recupere liste des groupes:
if formsemestre_id not in GroupIdInferers:
GroupIdInferers[formsemestre_id] = sco_groups.GroupIdInferer(
context, formsemestre_id
)
GroupIdInferers[formsemestre_id] = sco_groups.GroupIdInferer(formsemestre_id)
gi = GroupIdInferers[formsemestre_id]
if args["groupes"]:
groupes = args["groupes"].split(";")
@ -621,7 +619,7 @@ def scolars_import_admission(
log("scolars_import_admission: formsemestre_id=%s" % formsemestre_id)
members = sco_groups.get_group_members(
context, sco_groups.get_default_group(formsemestre_id)
sco_groups.get_default_group(formsemestre_id)
)
etuds_by_nomprenom = {} # { nomprenom : etud }
diag = []
@ -716,7 +714,7 @@ def scolars_import_admission(
# log('import_adm: %s' % args )
# Change les groupes si nécessaire:
if args["groupes"]:
gi = sco_groups.GroupIdInferer(context, formsemestre_id)
gi = sco_groups.GroupIdInferer(formsemestre_id)
groupes = args["groupes"].split(";")
group_ids = [gi[group_name] for group_name in groupes]
group_ids = list({}.fromkeys(group_ids).keys()) # uniq
@ -728,7 +726,7 @@ def scolars_import_admission(
for group_id in group_ids:
sco_groups.change_etud_group_in_partition(
context, args["etudid"], group_id, REQUEST=REQUEST
args["etudid"], group_id, REQUEST=REQUEST
)
#
diag.append("import de %s" % (etud["nomprenom"]))

View File

@ -111,13 +111,11 @@ def list_inscrits(context, formsemestre_id, with_dems=False):
"""
if not with_dems:
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
context, formsemestre_id
formsemestre_id
) # optimized
else:
args = {"formsemestre_id": formsemestre_id}
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args=args
)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(args=args)
inscr = {}
for i in ins:
etudid = i["etudid"]
@ -186,12 +184,12 @@ def do_inscrit(context, sem, etudids, REQUEST=None, inscrit_groupes=False):
if len(etud["sems"]) < 2:
continue
prev_formsemestre = etud["sems"][1]
sco_groups.etud_add_group_infos(context, etud, prev_formsemestre)
sco_groups.etud_add_group_infos(etud, prev_formsemestre)
cursem_groups_by_name = dict(
[
(g["group_name"], g)
for g in sco_groups.get_sem_groups(context, sem["formsemestre_id"])
for g in sco_groups.get_sem_groups(sem["formsemestre_id"])
if g["group_name"]
]
)
@ -207,7 +205,6 @@ def do_inscrit(context, sem, etudids, REQUEST=None, inscrit_groupes=False):
# inscrit aux groupes
for partition_group in partition_groups:
sco_groups.change_etud_group_in_partition(
context,
etudid,
partition_group["group_id"],
partition_group,
@ -229,7 +226,7 @@ def list_source_sems(context, sem, delai=None):
"""
# liste des semestres débutant a moins
# de delai (en jours) de la date de fin du semestre d'origine.
sems = sco_formsemestre.do_formsemestre_list(context)
sems = sco_formsemestre.do_formsemestre_list()
othersems = []
d, m, y = [int(x) for x in sem["date_debut"].split("/")]
date_debut_dst = datetime.date(y, m, d)
@ -249,9 +246,7 @@ def list_source_sems(context, sem, delai=None):
if s["semestre_id"] == sco_codes_parcours.NO_SEMESTRE_ID:
continue
#
F = sco_formations.formation_list(
context, args={"formation_id": s["formation_id"]}
)[0]
F = sco_formations.formation_list(args={"formation_id": s["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
if not parcours.ALLOW_SEM_SKIP:
if s["semestre_id"] < (sem["semestre_id"] - 1):
@ -283,7 +278,7 @@ def formsemestre_inscr_passage(
"""
inscrit_groupes = int(inscrit_groupes)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# -- check lock
if not sem["etat"]:
raise ScoValueError("opération impossible: semestre verrouille")
@ -382,12 +377,10 @@ def formsemestre_inscr_passage(
<li><a class="stdlink" href="formsemestre_status?formsemestre_id=%s">Tableau de bord du semestre</a></li>"""
% (formsemestre_id, formsemestre_id)
)
partition = sco_groups.formsemestre_get_main_partition(
context, formsemestre_id
)
partition = sco_groups.formsemestre_get_main_partition(formsemestre_id)
if (
partition["partition_id"]
!= sco_groups.formsemestre_get_main_partition(context, formsemestre_id)[
!= sco_groups.formsemestre_get_main_partition(formsemestre_id)[
"partition_id"
]
): # il y a au moins une vraie partition

View File

@ -89,7 +89,7 @@ def do_evaluation_listenotes(context, REQUEST):
H = []
# groupes
groups = sco_groups.do_evaluation_listegroupes(
context, E["evaluation_id"], include_default=True
E["evaluation_id"], include_default=True
)
grlabs = [g["group_name"] or "tous" for g in groups] # legendes des boutons
grnams = [str(g["group_id"]) for g in groups] # noms des checkbox
@ -236,7 +236,7 @@ def _make_table_notes(
moduleimpl_id = E["moduleimpl_id"]
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
Mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
# (debug) check that all evals are in same module:
for e in evals:
if e["moduleimpl_id"] != moduleimpl_id:
@ -249,7 +249,7 @@ def _make_table_notes(
# Si pas de groupe, affiche tout
if not group_ids:
group_ids = [sco_groups.get_default_group(M["formsemestre_id"])]
groups = sco_groups.listgroups(context, group_ids)
groups = sco_groups.listgroups(group_ids)
gr_title = sco_groups.listgroups_abbrev(groups)
gr_title_filename = sco_groups.listgroups_filename(groups)
@ -298,11 +298,11 @@ def _make_table_notes(
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
# infos inscription
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
{"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
)[0]
if inscr["etat"] == "I": # si inscrit, indique groupe
groups = sco_groups.get_etud_groups(context, etudid, sem)
groups = sco_groups.get_etud_groups(etudid, sem)
grc = sco_groups.listgroups_abbrev(groups)
else:
if inscr["etat"] == "D":
@ -487,7 +487,7 @@ def _make_table_notes(
# html_generate_cells=False # la derniere ligne (moyennes) est incomplete
)
t = tab.make_page(context, format=format, with_html_headers=False, REQUEST=REQUEST)
t = tab.make_page(format=format, with_html_headers=False, REQUEST=REQUEST)
if format != "html":
return t
@ -873,7 +873,7 @@ def evaluation_check_absences_html(
def formsemestre_check_absences_html(context, formsemestre_id, REQUEST=None):
"""Affiche etat verification absences pour toutes les evaluations du semestre !"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(
context,

View File

@ -48,7 +48,7 @@ def formsemestre_table_etuds_lycees(
context, formsemestre_id, group_lycees=True, only_primo=False
):
"""Récupère liste d'etudiants avec etat et decision."""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etuds = sco_report.tsp_etud_list(context, formsemestre_id, only_primo=only_primo)[0]
if only_primo:
primostr = "primo-entrants du "
@ -87,7 +87,7 @@ def scodoc_table_etuds_lycees(context, format="html", REQUEST=None):
no_links=True,
)
tab.base_url = REQUEST.URL0
t = tab.make_page(context, format=format, with_html_headers=False, REQUEST=REQUEST)
t = tab.make_page(format=format, with_html_headers=False, REQUEST=REQUEST)
if format != "html":
return t
H = [
@ -195,7 +195,7 @@ def formsemestre_etuds_lycees(
tab.base_url += "&only_primo=1"
if no_grouping:
tab.base_url += "&no_grouping=1"
t = tab.make_page(context, format=format, with_html_headers=False, REQUEST=REQUEST)
t = tab.make_page(format=format, with_html_headers=False, REQUEST=REQUEST)
if format != "html":
return t
F = [

View File

@ -262,7 +262,7 @@ def do_moduleimpl_inscrit_etuds(
# Verifie qu'ils sont tous bien inscrits au semestre
for etudid in etudids:
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id, "etudid": etudid}
args={"formsemestre_id": formsemestre_id, "etudid": etudid}
)
if not insem:
raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid)
@ -326,7 +326,7 @@ def can_change_module_resp(context, REQUEST, moduleimpl_id):
"""
M = do_moduleimpl_withmodule_list(context, moduleimpl_id=moduleimpl_id)[0]
# -- check lock
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
if not sem["etat"]:
raise ScoValueError("Modification impossible: semestre verrouille")
# -- check access
@ -344,7 +344,7 @@ def can_change_ens(context, REQUEST, moduleimpl_id, raise_exc=True):
"check if current user can modify ens list (raise exception if not)"
M = do_moduleimpl_withmodule_list(context, moduleimpl_id=moduleimpl_id)[0]
# -- check lock
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
if not sem["etat"]:
if raise_exc:
raise ScoValueError("Modification impossible: semestre verrouille")

View File

@ -67,7 +67,7 @@ def moduleimpl_inscriptions_edit(
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
formsemestre_id = M["formsemestre_id"]
mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# -- check lock
if not sem["etat"]:
raise ScoValueError("opération impossible: semestre verrouille")
@ -93,7 +93,7 @@ def moduleimpl_inscriptions_edit(
]
# Liste des inscrits à ce semestre
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
context, formsemestre_id
formsemestre_id
)
for ins in inscrits:
etuds_info = sco_etud.get_etud_info(etudid=ins["etudid"], filled=1)
@ -112,7 +112,7 @@ def moduleimpl_inscriptions_edit(
)
in_module = set([x["etudid"] for x in in_m])
#
partitions = sco_groups.get_partitions_list(context, formsemestre_id)
partitions = sco_groups.get_partitions_list(formsemestre_id)
#
if not submitted:
H.append(
@ -185,7 +185,7 @@ def moduleimpl_inscriptions_edit(
)
H.append("""</input></td>""")
groups = sco_groups.get_etud_groups(context, etud["etudid"], sem)
groups = sco_groups.get_etud_groups(etud["etudid"], sem)
for partition in partitions:
if partition["partition_name"]:
gr_name = ""
@ -214,7 +214,7 @@ def _make_menu(context, partitions, title="", check="true"):
for partition in partitions:
if partition["partition_name"] != None:
p_idx += 1
for group in sco_groups.get_partition_groups(context, partition):
for group in sco_groups.get_partition_groups(partition):
items.append(
{
"title": "%s %s"
@ -252,13 +252,13 @@ def moduleimpl_inscriptions_stats(context, formsemestre_id, REQUEST=None):
"""
authuser = REQUEST.AUTHENTICATED_USER
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
args={"formsemestre_id": formsemestre_id}
)
set_all = set([x["etudid"] for x in inscrits])
partitions, partitions_etud_groups = sco_groups.get_formsemestre_groups(
context, formsemestre_id
formsemestre_id
)
can_change = authuser.has_permission(Permission.ScoEtudInscrit) and sem["etat"]
@ -441,8 +441,8 @@ def descr_inscrs_module(
gr = [] # [ ( partition_name , [ group_names ] ) ]
for partition in partitions:
grp = [] # groupe de cette partition
for group in sco_groups.get_partition_groups(context, partition):
members = sco_groups.get_group_members(context, group["group_id"])
for group in sco_groups.get_partition_groups(partition):
members = sco_groups.get_group_members(group["group_id"])
set_g = set([m["etudid"] for m in members])
if set_g.issubset(set_m):
grp.append(group["group_name"])
@ -492,7 +492,7 @@ def get_etuds_with_capitalized_ue(context, formsemestre_id):
UECaps = scu.DictDefault(defaultvalue=[])
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_ues, get_etud_ue_status
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
args={"formsemestre_id": formsemestre_id}
)
ues = nt.get_ues()
for ue in ues:
@ -569,7 +569,7 @@ def do_etud_inscrit_ue(context, etudid, formsemestre_id, ue_id, REQUEST=None):
"""Incrit l'etudiant de tous les modules de cette UE dans ce semestre."""
# Verifie qu'il est bien inscrit au semestre
insem = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id, "etudid": etudid}
args={"formsemestre_id": formsemestre_id, "etudid": etudid}
)
if not insem:
raise ScoValueError("%s n'est pas inscrit au semestre !" % etudid)

View File

@ -161,10 +161,8 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
formsemestre_id = M["formsemestre_id"]
Mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
ModInscrits = sco_moduleimpl.do_moduleimpl_inscription_list(
context, moduleimpl_id=M["moduleimpl_id"]
)
@ -312,7 +310,7 @@ def moduleimpl_status(context, moduleimpl_id=None, partition_id=None, REQUEST=No
)
#
# Liste les noms de partitions
partitions = sco_groups.get_partitions_list(context, sem["formsemestre_id"])
partitions = sco_groups.get_partitions_list(sem["formsemestre_id"])
H.append(
"""Afficher les groupes de&nbsp;<select name="partition_id" onchange="document.f.submit();">"""
)

View File

@ -188,7 +188,7 @@ def _get_formsemestre_infos_from_news(context, n):
return {}
try:
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
except:
# semestre n'existe plus
return {}

View File

@ -209,7 +209,7 @@ def ficheEtud(context, etudid=None, REQUEST=None):
info["modifadresse"] = ""
# Groupes:
sco_groups.etud_add_group_infos(context, info, info["cursem"])
sco_groups.etud_add_group_infos(info, info["cursem"])
# Parcours de l'étudiant
if info["sems"]:
@ -228,7 +228,7 @@ def ficheEtud(context, etudid=None, REQUEST=None):
)
grlink = '<span class="fontred">%s</span>' % descr["situation"]
else:
group = sco_groups.get_etud_main_group(context, etudid, sem)
group = sco_groups.get_etud_main_group(etudid, sem)
if group["partition_name"]:
gr_name = group["group_name"]
else:
@ -247,9 +247,7 @@ def ficheEtud(context, etudid=None, REQUEST=None):
sem_info[sem["formsemestre_id"]] = grlink
if info["sems"]:
Se = sco_parcours_dut.SituationEtudParcours(
context, etud, info["last_formsemestre_id"]
)
Se = sco_parcours_dut.SituationEtudParcours(etud, info["last_formsemestre_id"])
info["liste_inscriptions"] = formsemestre_recap_parcours_table(
context,
Se,
@ -571,11 +569,11 @@ def etud_info_html(context, etudid, with_photo="1", REQUEST=None, debug=False):
# Informations sur l'etudiant dans le semestre courant:
sem = None
if formsemestre_id: # un semestre est spécifié par la page
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
elif etud["cursem"]: # le semestre "en cours" pour l'étudiant
sem = etud["cursem"]
if sem:
groups = sco_groups.get_etud_groups(context, etudid, sem)
groups = sco_groups.get_etud_groups(etudid, sem)
grc = sco_groups.listgroups_abbrev(groups)
H += '<div class="eid_info">En <b>S%d</b>: %s</div>' % (sem["semestre_id"], grc)
H += "</div>" # fin partie gauche (eid_left)

View File

@ -105,7 +105,7 @@ class DecisionSem(object):
# log('%s: %s %s %s %s %s' % (self.codechoice,code_etat,new_code_prev,formsemestre_id_utilise_pour_compenser,devenir,assiduite) )
def SituationEtudParcours(context, etud, formsemestre_id):
def SituationEtudParcours(etud, formsemestre_id):
"""renvoie une instance de SituationEtudParcours (ou sous-classe spécialisée)"""
nt = sco_cache.NotesTableCache.get(
formsemestre_id
@ -113,23 +113,23 @@ def SituationEtudParcours(context, etud, formsemestre_id):
parcours = nt.parcours
#
if parcours.ECTS_ONLY:
return SituationEtudParcoursECTS(context, etud, formsemestre_id, nt)
return SituationEtudParcoursECTS(etud, formsemestre_id, nt)
else:
return SituationEtudParcoursGeneric(context, etud, formsemestre_id, nt)
return SituationEtudParcoursGeneric(etud, formsemestre_id, nt)
class SituationEtudParcoursGeneric(object):
"Semestre dans un parcours"
def __init__(self, context, etud, formsemestre_id, nt):
def __init__(self, etud, formsemestre_id, nt):
"""
etud: dict filled by fill_etuds_info()
"""
self.context = context
self.context = None # #context
self.etud = etud
self.etudid = etud["etudid"]
self.formsemestre_id = formsemestre_id
self.sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
self.sem = sco_formsemestre.get_formsemestre(formsemestre_id)
self.nt = nt
self.formation = self.nt.formation
self.parcours = self.nt.parcours
@ -672,8 +672,8 @@ class SituationEtudParcoursGeneric(object):
class SituationEtudParcoursECTS(SituationEtudParcoursGeneric):
"""Gestion parcours basés sur ECTS"""
def __init__(self, context, etud, formsemestre_id, nt):
SituationEtudParcoursGeneric.__init__(self, context, etud, formsemestre_id, nt)
def __init__(self, etud, formsemestre_id, nt):
SituationEtudParcoursGeneric.__init__(self, etud, formsemestre_id, nt)
def could_be_compensated(self):
return False # jamais de compensations dans ce parcours
@ -1098,10 +1098,8 @@ def list_formsemestre_utilisateurs_uecap(context, formsemestre_id):
(et qui doivent donc etre sortis du cache si l'on modifie ce
semestre): meme code formation, meme semestre_id, date posterieure"""
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT sem.id

View File

@ -166,7 +166,6 @@ class ScolarsPageTemplate(PageTemplate):
def __init__(
self,
document,
context=None,
pagesbookmarks={},
author=None,
title=None,
@ -304,7 +303,9 @@ def _makeTimeDict():
def pdf_basic_page(
objects, title="", preferences=None, context=None
objects,
title="",
preferences=None,
): # used by gen_table.make_page()
"""Simple convenience fonction: build a page from a list of platypus objects,
adding a title if specified.
@ -315,7 +316,6 @@ def pdf_basic_page(
document.addPageTemplates(
ScolarsPageTemplate(
document,
context=context,
title=title,
author="%s %s (E. Viennet)" % (SCONAME, SCOVERSION),
footer_template="Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s",

View File

@ -27,7 +27,7 @@ def can_edit_notes(authuser, moduleimpl_id, allow_ens=True):
context = None # XXX #context
uid = str(authuser)
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
if not sem["etat"]:
return False # semestre verrouillé
@ -69,7 +69,7 @@ def can_edit_evaluation(moduleimpl_id=None):
raise ValueError("no moduleimpl specified") # bug
uid = current_user.user_name
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=moduleimpl_id)[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
if (
current_user.has_permission(Permission.ScoEditAllEvals)
@ -110,7 +110,7 @@ def can_validate_sem(formsemestre_id):
from app.scodoc import sco_formsemestre
context = None # XXX #context
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not sem["etat"]:
return False # semestre verrouillé
@ -122,7 +122,7 @@ def can_edit_pv(formsemestre_id):
from app.scodoc import sco_formsemestre
context = None # XXX #context
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if is_chef_or_diretud(sem):
return True
# Autorise les secrétariats, repérés via la permission ScoEtudChangeAdr
@ -148,7 +148,7 @@ def check_access_diretud(formsemestre_id, required_permission=Permission.ScoImpl
context = None # XXX #context
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
header = html_sco_header.sco_header(page_title="Accès interdit")
footer = html_sco_header.sco_footer()
if (
@ -175,7 +175,7 @@ def can_change_groups(formsemestre_id):
from app.scodoc import sco_formsemestre
context = None # XXX #context
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not sem["etat"]:
return False # semestre verrouillé
if current_user.has_permission(Permission.ScoEtudChangeGroups):

View File

@ -56,7 +56,7 @@ from app.scodoc.sco_excel import *
from app.scodoc.TrivialFormulator import TrivialFormulator
def do_placement_selectetuds(context, REQUEST):
def do_placement_selectetuds(REQUEST):
"""
Choisi les étudiants et les infos sur la salle pour leur placement.
"""
@ -67,9 +67,7 @@ def do_placement_selectetuds(context, REQUEST):
E = E[0]
# M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
# groupes
groups = sco_groups.do_evaluation_listegroupes(
context, evaluation_id, include_default=True
)
groups = sco_groups.do_evaluation_listegroupes(evaluation_id, include_default=True)
grlabs = [g["group_name"] or "tous" for g in groups] # legendes des boutons
grnams = [g["group_id"] for g in groups] # noms des checkbox
no_groups = (len(groups) == 1) and groups[0]["group_name"] is None
@ -270,7 +268,7 @@ def do_placement(context, REQUEST):
# Construit liste des etudiants
group_ids = REQUEST.form.get("group_ids", [])
groups = sco_groups.listgroups(context, group_ids)
groups = sco_groups.listgroups(group_ids)
gr_title_filename = sco_groups.listgroups_filename(groups)
# gr_title = sco_groups.listgroups_abbrev(groups)
@ -287,7 +285,7 @@ def do_placement(context, REQUEST):
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
Mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
evalname = "%s-%s" % (Mod["code"], ndb.DateDMYtoISO(E["jour"]))
if E["description"]:
evaltitre = E["description"]
@ -309,7 +307,7 @@ def do_placement(context, REQUEST):
] # XXX utiliser ZScolar (parent)
# infos inscription
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
{"etudid": etudid, "formsemestre_id": M["formsemestre_id"]}
)[0]
if inscr["etat"] != "D":
nom = scu.strupper(ident["nom"])
@ -419,7 +417,7 @@ def placement_eval_selectetuds(context, evaluation_id, REQUEST=None):
formid = "placementfile"
if not REQUEST.form.get("%s-submitted" % formid, False):
# not submitted, choix groupe
r = do_placement_selectetuds(context, REQUEST)
r = do_placement_selectetuds(REQUEST)
if r:
H.append(r)

View File

@ -156,7 +156,7 @@ def _getEtudInfoGroupes(context, group_ids, etat=None):
"""
etuds = []
for group_id in group_ids:
members = sco_groups.get_group_members(context, group_id, etat=etat)
members = sco_groups.get_group_members(group_id, etat=etat)
for m in members:
etud = sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0]
etuds.append(etud)
@ -168,7 +168,7 @@ def formsemestre_poursuite_report(
context, formsemestre_id, format="html", REQUEST=None
):
"""Table avec informations "poursuite" """
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etuds = _getEtudInfoGroupes(
context, [sco_groups.get_default_group(formsemestre_id)]
)

View File

@ -2123,7 +2123,7 @@ class SemPreferences(object):
"sem_preferences.edit doit etre appele sur un semestre !"
) # a bug !
context = None # XXX TO REMOVE
sem = sco_formsemestre.get_formsemestre(context, self.formsemestre_id)
sem = sco_formsemestre.get_formsemestre(self.formsemestre_id)
H = [
html_sco_header.html_sem_header(
context, REQUEST, "Préférences du semestre", sem

View File

@ -49,12 +49,12 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
formsemestre_id
) # > get_etudids, get_etud_moy_gen, get_ues, get_etud_ue_status, get_etud_decision_sem, identdict,
etudids = nt.get_etudids(sorted=True) # tri par moy gen
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etud_groups = sco_groups.formsemestre_get_etud_groupnames(context, formsemestre_id)
main_partition_id = sco_groups.formsemestre_get_main_partition(
context, formsemestre_id
)["partition_id"]
etud_groups = sco_groups.formsemestre_get_etud_groupnames(formsemestre_id)
main_partition_id = sco_groups.formsemestre_get_main_partition(formsemestre_id)[
"partition_id"
]
prev_moy_ue = scu.DictDefault(defaultvalue={}) # ue_code_s : { etudid : moy ue }
prev_ue_acro = {} # ue_code_s : acronyme (à afficher)
@ -76,7 +76,7 @@ def feuille_preparation_jury(context, formsemestre_id, REQUEST):
if not info:
continue # should not occur...
etud = info[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
if Se.prev:
ntp = sco_cache.NotesTableCache.get(
Se.prev["formsemestre_id"]

View File

@ -226,7 +226,7 @@ def dict_pvjury(
if not etudids:
return {}
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
max_date = "0000-01-01"
has_prev = False # vrai si au moins un etudiant a un code prev
semestre_non_terminal = False # True si au moins un etudiant a un devenir
@ -235,7 +235,7 @@ def dict_pvjury(
D = {} # même chose que L, mais { etudid : dec }
for etudid in etudids:
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(context, etud, formsemestre_id)
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
semestre_non_terminal = semestre_non_terminal or Se.semestre_non_terminal
d = {}
d["identite"] = nt.identdict[etudid]
@ -299,9 +299,7 @@ def dict_pvjury(
obs = []
for compensator in compensators:
# nb: il ne devrait y en avoir qu'un !
csem = sco_formsemestre.get_formsemestre(
context, compensator["formsemestre_id"]
)
csem = sco_formsemestre.get_formsemestre(compensator["formsemestre_id"])
obs.append(
"%s compensé par %s (%s)"
% (sem["sem_id_txt"], csem["sem_id_txt"], csem["anneescolaire"])
@ -309,7 +307,7 @@ def dict_pvjury(
if d["decision_sem"] and d["decision_sem"]["compense_formsemestre_id"]:
compensed = sco_formsemestre.get_formsemestre(
context, d["decision_sem"]["compense_formsemestre_id"]
d["decision_sem"]["compense_formsemestre_id"]
)
obs.append(
"%s compense %s (%s)"
@ -362,7 +360,7 @@ def dict_pvjury(
"has_prev": has_prev,
"semestre_non_terminal": semestre_non_terminal,
"formation": sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
args={"formation_id": sem["formation_id"]}
)[0],
"decisions": L,
"decisions_dict": D,
@ -619,9 +617,9 @@ def formsemestre_pvjury_pdf(
"""Generation PV jury en PDF: saisie des paramètres
Si etudid, PV pour un seul etudiant. Sinon, tout les inscrits au groupe indiqué.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# Mise à jour des groupes d'étapes:
sco_groups.create_etapes_partition(context, formsemestre_id)
sco_groups.create_etapes_partition(formsemestre_id)
groups_infos = None
if etudid:
# PV pour ce seul étudiant:
@ -719,7 +717,7 @@ def formsemestre_pvjury_pdf(
)
finally:
PDFLOCK.release()
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
dt = time.strftime("%Y-%m-%d")
if groups_infos:
groups_filename = "-" + groups_infos.groups_filename
@ -731,7 +729,7 @@ def formsemestre_pvjury_pdf(
def descrform_pvjury(context, sem):
"""Définition de formulaire pour PV jury PDF"""
F = sco_formations.formation_list(context, formation_id=sem["formation_id"])[0]
F = sco_formations.formation_list(formation_id=sem["formation_id"])[0]
return [
(
"date_commission",
@ -816,7 +814,7 @@ def formsemestre_lettres_individuelles(
context, formsemestre_id, group_ids=[], REQUEST=None
):
"Lettres avis jury en PDF"
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not group_ids:
# tous les inscrits du semestre
group_ids = [sco_groups.get_default_group(formsemestre_id)]
@ -887,7 +885,7 @@ def formsemestre_lettres_individuelles(
formsemestre_id
)
)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
dt = time.strftime("%Y-%m-%d")
groups_filename = "-" + groups_infos.groups_filename
filename = "lettres-%s%s-%s.pdf" % (sem["titre_num"], groups_filename, dt)

View File

@ -348,7 +348,7 @@ def pdf_lettres_individuelles(
etuds = [x["identite"] for x in dpv["decisions"]]
sco_etud.fill_etuds_info(etuds)
#
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
prefs = sco_preferences.SemPreferences(formsemestre_id)
params = {
"date_jury": date_jury,

View File

@ -73,10 +73,8 @@ def formsemestre_recapcomplet(
pour tous les étudiants, les moyennes par UE et générale,
trié par moyenne générale décroissante.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
F = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
# traduit du DTML
modejury = int(modejury)
@ -276,7 +274,7 @@ def make_formsemestre_recapcomplet(
]
sem = sco_formsemestre.do_formsemestre_list(
context, args={"formsemestre_id": formsemestre_id}
args={"formsemestre_id": formsemestre_id}
)[0]
nt = sco_cache.NotesTableCache.get(
formsemestre_id
@ -285,15 +283,15 @@ def make_formsemestre_recapcomplet(
ues = nt.get_ues() # incluant le(s) UE de sport
#
partitions, partitions_etud_groups = sco_groups.get_formsemestre_groups(
context, formsemestre_id
formsemestre_id
)
if rank_partition_id and format == "html":
# Calcul rang sur une partition et non sur l'ensemble
# seulement en format HTML (car colonnes rangs toujours presentes en xls)
rank_partition = sco_groups.get_partition(context, rank_partition_id)
rank_partition = sco_groups.get_partition(rank_partition_id)
rank_label = "Rg (%s)" % rank_partition["partition_name"]
else:
rank_partition = sco_groups.get_default_partition(context, formsemestre_id)
rank_partition = sco_groups.get_default_partition(formsemestre_id)
rank_label = "Rg"
T = nt.get_table_moyennes_triees()
@ -380,7 +378,7 @@ def make_formsemestre_recapcomplet(
gr_name = "Déf."
is_dem[etudid] = False
else:
group = sco_groups.get_etud_main_group(context, etudid, sem)
group = sco_groups.get_etud_main_group(etudid, sem)
gr_name = group["group_name"] or ""
is_dem[etudid] = False
if rank_partition_id:
@ -951,9 +949,7 @@ def formsemestres_bulletins(context, annee_scolaire, REQUEST=None):
:returns: JSON
"""
jslist = []
sems = sco_formsemestre.list_formsemestre_by_etape(
context, annee_scolaire=annee_scolaire
)
sems = sco_formsemestre.list_formsemestre_by_etape(annee_scolaire=annee_scolaire)
log("formsemestres_bulletins(%s): %d sems" % (annee_scolaire, len(sems)))
for sem in sems:
J, _, _ = _formsemestre_recapcomplet_json(

View File

@ -223,7 +223,7 @@ def formsemestre_report(
"""
Tableau sur résultats (result) par type de category bac
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not category_name:
category_name = category
if not result_name:
@ -258,7 +258,7 @@ def formsemestre_report(
# """
# Tableau sur résultats par type de bac
# """
# sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
# sem = sco_formsemestre.get_formsemestre( formsemestre_id)
# title = 'Statistiques bacs ' + sem['titreannee']
# etuds = formsemestre_etuds_stats(context, sem)
# tab = formsemestre_report(context, formsemestre_id, etuds, REQUEST=REQUEST,
@ -284,7 +284,7 @@ def formsemestre_report_counts(
"""
Tableau comptage avec choix des categories
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
category_name = scu.strcapitalize(category)
title = "Comptages " + category_name
etuds = formsemestre_etuds_stats(context, sem, only_primo=only_primo)
@ -405,7 +405,7 @@ def table_suivi_cohorte(
"""
sem = sco_formsemestre.get_formsemestre(
context, formsemestre_id
formsemestre_id
) # sem est le semestre origine
t0 = time.time()
@ -465,7 +465,7 @@ def table_suivi_cohorte(
sem["members"] = orig_set
for s in sems:
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": s["formsemestre_id"]}
args={"formsemestre_id": s["formsemestre_id"]}
) # sans dems
inset = set([i["etudid"] for i in ins])
s["members"] = orig_set.intersection(inset)
@ -727,7 +727,7 @@ def formsemestre_suivi_cohorte(
)
if only_primo:
tab.base_url += "&only_primo=on"
t = tab.make_page(context, format=format, with_html_headers=False, REQUEST=REQUEST)
t = tab.make_page(format=format, with_html_headers=False, REQUEST=REQUEST)
if format != "html":
return t
@ -1033,7 +1033,7 @@ def tsp_etud_list(
ramene aussi ensembles des bacs, genres, statuts de (tous) les etudiants
"""
# log('tsp_etud_list(%s, bac="%s")' % (formsemestre_id,bac))
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_etudids,
etudids = nt.get_etudids()
etuds = []
@ -1088,7 +1088,7 @@ def table_suivi_parcours(
context, formsemestre_id, only_primo=False, grouped_parcours=True
):
"""Tableau recapitulant tous les parcours"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etuds, bacs, bacspecialites, annee_bacs, civilites, statuts = tsp_etud_list(
context, formsemestre_id, only_primo=only_primo
)
@ -1221,7 +1221,7 @@ def formsemestre_suivi_parcours(
tab.base_url += "&only_primo=1"
if no_grouping:
tab.base_url += "&no_grouping=1"
t = tab.make_page(context, format=format, with_html_headers=False, REQUEST=REQUEST)
t = tab.make_page(format=format, with_html_headers=False, REQUEST=REQUEST)
if format != "html":
return t
F = [
@ -1484,7 +1484,7 @@ def formsemestre_graph_parcours(
):
"""Graphe suivi cohortes"""
# log("formsemestre_graph_parcours")
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if format == "pdf":
(
doc,

View File

@ -763,7 +763,7 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
M = sco_moduleimpl.do_moduleimpl_list(context, moduleimpl_id=E["moduleimpl_id"])[0]
formsemestre_id = M["formsemestre_id"]
Mod = sco_edit_module.do_module_list(context, args={"module_id": M["module_id"]})[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
mod_responsable = sco_users.user_info(M["responsable_id"])
if E["jour"]:
indication_date = ndb.DateDMYtoISO(E["jour"])
@ -790,7 +790,7 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
etat=None,
REQUEST=REQUEST,
)
groups = sco_groups.listgroups(context, groups_infos.group_ids)
groups = sco_groups.listgroups(groups_infos.group_ids)
gr_title_filename = sco_groups.listgroups_filename(groups)
# gr_title = sco_groups.listgroups_abbrev(groups)
if None in [g["group_name"] for g in groups]: # tous les etudiants
@ -809,7 +809,7 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
etuds = _get_sorted_etuds(context, E, etudids, formsemestre_id)
for e in etuds:
etudid = e["etudid"]
groups = sco_groups.get_etud_groups(context, etudid, sem)
groups = sco_groups.get_etud_groups(etudid, sem)
grc = sco_groups.listgroups_abbrev(groups)
L.append(
@ -972,7 +972,7 @@ def saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
def _get_sorted_etuds(context, E, etudids, formsemestre_id):
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
NotesDB = sco_evaluations.do_evaluation_get_all_notes(
E["evaluation_id"]
) # Notes existantes
@ -985,10 +985,10 @@ def _get_sorted_etuds(context, E, etudids, formsemestre_id):
etuds.append(e)
# infos inscription dans ce semestre
e["inscr"] = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid, "formsemestre_id": formsemestre_id}
{"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0]
# Groupes auxquels appartient cet étudiant:
e["groups"] = sco_groups.get_etud_groups(context, etudid, sem)
e["groups"] = sco_groups.get_etud_groups(etudid, sem)
# Information sur absence (tenant compte de la demi-journée)
jour_iso = ndb.DateDMYtoISO(E["jour"])

View File

@ -232,7 +232,6 @@ class SemSet(dict):
sem
for sem in sems
if sco_formsemestre.sem_in_semestre_scolaire(
self.context,
sem,
year=self["annee_scolaire"],
saison=self["sem_id"],
@ -403,7 +402,7 @@ def do_semset_add_sem(context, semset_id, formsemestre_id, REQUEST=None):
raise ScoValueError("empty semset_id")
s = SemSet(context, semset_id=semset_id)
# check for valid formsemestre_id
_ = sco_formsemestre.get_formsemestre(context, formsemestre_id) # raise exc
_ = sco_formsemestre.get_formsemestre(formsemestre_id) # raise exc
s.add(formsemestre_id)
@ -474,7 +473,7 @@ def semset_page(context, format="html", REQUEST=None):
preferences=sco_preferences.SemPreferences(),
)
if format != "html":
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
page_title = "Ensembles de semestres"
H = [

View File

@ -90,7 +90,7 @@ def formsemestre_synchro_etuds(
que l'on va importer/inscrire
"""
log("formsemestre_synchro_etuds: formsemestre_id=%s" % formsemestre_id)
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
sem["etape_apo_str"] = sco_formsemestre.formsemestre_etape_apo_str(sem)
# Write access ?
authuser = REQUEST.AUTHENTICATED_USER
@ -252,7 +252,7 @@ def formsemestre_synchro_etuds(
)
#
partitions = sco_groups.get_partitions_list(
context, formsemestre_id, with_default=False
formsemestre_id, with_default=False
)
if partitions: # il y a au moins une vraie partition
H.append(
@ -782,9 +782,9 @@ def formsemestre_import_etud_admission(
de chaque étudiant depuis le portail.
N'affecte pas les etudiants inconnus sur le portail.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"formsemestre_id": formsemestre_id}
{"formsemestre_id": formsemestre_id}
)
log(
"formsemestre_import_etud_admission: %s (%d etuds)"

View File

@ -385,7 +385,6 @@ def _trombino_pdf(context, groups_infos, REQUEST):
document.addPageTemplates(
sco_pdf.ScolarsPageTemplate(
document,
context=context,
preferences=sco_preferences.SemPreferences(sem["formsemestre_id"]),
)
)
@ -462,7 +461,6 @@ def _listeappel_photos_pdf(context, groups_infos, REQUEST):
document.addPageTemplates(
sco_pdf.ScolarsPageTemplate(
document,
context,
preferences=sco_preferences.SemPreferences(sem["formsemestre_id"]),
)
)

View File

@ -141,7 +141,7 @@ def pdf_trombino_tours(
for group_id in groups_infos.group_ids:
if group_id != "None":
members, group, group_tit, sem, nbdem = sco_groups.get_group_infos(
context, group_id, "I"
group_id, "I"
)
groups += " %s" % group_tit
L = []
@ -179,9 +179,7 @@ def pdf_trombino_tours(
img = sco_trombino._get_etud_platypus_image(
context, m, image_width=PHOTOWIDTH
)
etud_main_group = sco_groups.get_etud_main_group(
context, m["etudid"], sem
)
etud_main_group = sco_groups.get_etud_main_group(m["etudid"], sem)
if group_id != etud_main_group["group_id"]:
text_group = " (" + etud_main_group["group_name"] + ")"
else:
@ -271,7 +269,6 @@ def pdf_trombino_tours(
document.addPageTemplates(
ScolarsPageTemplate(
document,
context=context,
preferences=sco_preferences.SemPreferences(),
)
)
@ -391,7 +388,7 @@ def pdf_feuille_releve_absences(
for group_id in groups_infos.group_ids:
members, group, group_tit, sem, nbdem = sco_groups.get_group_infos(
context, group_id, "I"
group_id, "I"
)
L = []
@ -467,7 +464,6 @@ def pdf_feuille_releve_absences(
document.addPageTemplates(
ScolarsPageTemplate(
document,
context=context,
preferences=sco_preferences.SemPreferences(),
)
)

View File

@ -86,7 +86,7 @@ def external_ue_create(
):
"""Crée UE/matiere/module/evaluation puis saisie les notes"""
log("external_ue_create( formsemestre_id=%s, titre=%s )" % (formsemestre_id, titre))
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# Contrôle d'accès:
if not current_user.has_permission(Permission.ScoImplement):
if not sem["resp_can_edit"] or (current_user.id not in sem["responsables"]):
@ -219,7 +219,7 @@ def external_ue_create_form(context, formsemestre_id, etudid, REQUEST=None):
Note: pour l'édition éventuelle de ces informations, on utilisera les
fonctions standards sur les UE/modules/notes
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# Contrôle d'accès:
if not current_user.has_permission(Permission.ScoImplement):
if not sem["resp_can_edit"] or (current_user.id not in sem["responsables"]):
@ -246,9 +246,7 @@ def external_ue_create_form(context, formsemestre_id, etudid, REQUEST=None):
""",
]
html_footer = html_sco_header.sco_footer()
Fo = sco_formations.formation_list(
context, args={"formation_id": sem["formation_id"]}
)[0]
Fo = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
parcours = sco_codes_parcours.get_parcours_from_code(Fo["type_parcours"])
ue_types = parcours.ALLOWED_UE_TYPES
ue_types.sort()

View File

@ -167,7 +167,7 @@ def evaluation_list_operations(context, REQUEST, evaluation_id):
% (E["description"], E["jour"]),
preferences=sco_preferences.SemPreferences(M["formsemestre_id"]),
)
return tab.make_page(context, REQUEST=REQUEST)
return tab.make_page(REQUEST=REQUEST)
def formsemestre_list_saisies_notes(
@ -176,7 +176,7 @@ def formsemestre_list_saisies_notes(
"""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(formsemestre_id)
r = ndb.SimpleDictFetch(
"""SELECT i.nom, n.*, mod.titre, e.description, e.jour
FROM notes_notes n, notes_evaluation e, notes_moduleimpl mi,
@ -222,7 +222,7 @@ def formsemestre_list_saisies_notes(
base_url="%s?formsemestre_id=%s" % (REQUEST.URL0, formsemestre_id),
origin="Généré par %s le " % VERSION.SCONAME + scu.timedate_human_repr() + "",
)
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
def get_note_history(context, evaluation_id, etudid, REQUEST=None, fmt=""):

View File

@ -134,7 +134,7 @@ def _toboolean(x):
def index_html(context, REQUEST=None):
"""Gestionnaire absences, page principale"""
# crude portage from 1999 DTML
sems = sco_formsemestre.do_formsemestre_list(context)
sems = sco_formsemestre.do_formsemestre_list()
authuser = REQUEST.AUTHENTICATED_USER
H = [
@ -194,7 +194,7 @@ def cal_select_week(context, year=None):
"display calendar allowing week selection"
if not year:
year = scu.AnneeScolaire()
sems = sco_formsemestre.do_formsemestre_list(context)
sems = sco_formsemestre.do_formsemestre_list()
if not sems:
js = ""
else:
@ -364,9 +364,7 @@ def SignaleAbsenceGrHebdo(
# Si aucun etudiant n'est inscrit au module choisi...
moduleimpl_id = None
nt = sco_cache.NotesTableCache.get(formsemestre_id)
sem = sco_formsemestre.do_formsemestre_list(
context, {"formsemestre_id": formsemestre_id}
)[0]
sem = sco_formsemestre.do_formsemestre_list({"formsemestre_id": formsemestre_id})[0]
# calcule dates jours de cette semaine
# liste de dates iso "yyyy-mm-dd"
@ -535,7 +533,7 @@ def SignaleAbsenceGrSemestre(
if etuds:
nt = sco_cache.NotesTableCache.get(formsemestre_id)
sem = sco_formsemestre.do_formsemestre_list(
context, {"formsemestre_id": formsemestre_id}
{"formsemestre_id": formsemestre_id}
)[0]
work_saturday = sco_abs.is_work_saturday(context)
jourdebut = sco_abs.ddmmyyyy(datedebut, work_saturday=work_saturday)
@ -986,7 +984,7 @@ ou entrez une date pour visualiser les absents un jour donné&nbsp;:
"""
% (REQUEST.URL0, formsemestre_id, groups_infos.get_form_elem()),
)
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
@bp.route("/EtatAbsencesDate")
@ -1129,7 +1127,7 @@ def AddBilletAbsence(
billets = sco_abs.billet_absence_list(cnx, {"billet_id": billet_id})
tab = _tableBillets(context, billets, etud=etud)
log("AddBilletAbsence: new billet_id=%s (%gs)" % (billet_id, time.time() - t0))
return tab.make_page(context, REQUEST=REQUEST, format="xml")
return tab.make_page(REQUEST=REQUEST, format="xml")
else:
return billet_id
@ -1261,7 +1259,7 @@ def listeBilletsEtud(context, etudid=False, REQUEST=None, format="html"):
cnx = ndb.GetDBConnexion()
billets = sco_abs.billet_absence_list(cnx, {"etudid": etud["etudid"]})
tab = _tableBillets(context, billets, etud=etud)
return tab.make_page(context, REQUEST=REQUEST, format=format)
return tab.make_page(REQUEST=REQUEST, format=format)
@bp.route("/XMLgetBilletsEtud")

View File

@ -236,7 +236,7 @@ def index_html(
preferences=context.get_preferences(),
)
if format != "html":
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page( format=format, REQUEST=REQUEST)
else:
H = [
entreprise_header(context, REQUEST=REQUEST, page_title="Suivi entreprises"),
@ -311,7 +311,7 @@ def entreprise_contact_list(context, entreprise_id=None, format="html", REQUEST=
preferences=context.get_preferences(),
)
if format != "html":
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page( format=format, REQUEST=REQUEST)
H.append(tab.html())
@ -422,7 +422,7 @@ def entreprise_correspondant_list(
preferences=context.get_preferences(),
)
if format != "html":
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page( format=format, REQUEST=REQUEST)
H.append(tab.html())

View File

@ -441,7 +441,7 @@ def formation_list(context, format=None, REQUEST=None, formation_id=None, args={
"""List formation(s) with given id, or matching args
(when args is given, formation_id is ignored).
"""
r = sco_formations.formation_list(context, formation_id=formation_id, args=args)
r = sco_formations.formation_list(formation_id=formation_id, args=args)
return scu.sendResult(REQUEST, r, name="formation", format=format)
@ -557,9 +557,7 @@ sco_publish(
@scodoc7func(context)
def formation_count_sems(context, formation_id):
"Number of formsemestre in this formation (locked or not)"
sems = sco_formsemestre.do_formsemestre_list(
context, args={"formation_id": formation_id}
)
sems = sco_formsemestre.do_formsemestre_list(args={"formation_id": formation_id})
return len(sems)
@ -606,7 +604,7 @@ def formsemestre_list(
for argname in ("formsemestre_id", "formation_id", "etape_apo"):
if L[argname] is not None:
args[argname] = L[argname]
sems = sco_formsemestre.do_formsemestre_list(context, args=args)
sems = sco_formsemestre.do_formsemestre_list(args=args)
# log('formsemestre_list: format="%s", %s semestres found' % (format,len(sems)))
return scu.sendResult(REQUEST, sems, name="formsemestre", format=format)
@ -628,7 +626,7 @@ def XMLgetFormsemestres(context, etape_apo=None, formsemestre_id=None, REQUEST=N
if REQUEST:
REQUEST.RESPONSE.setHeader("content-type", scu.XML_MIMETYPE)
doc = ElementTree.Element("formsemestrelist")
for sem in sco_formsemestre.do_formsemestre_list(context, args=args):
for sem in sco_formsemestre.do_formsemestre_list(args=args):
doc.append("formsemestre", **sem)
return sco_xml.XML_HEADER + ElementTree.tostring(doc).decode(scu.SCO_ENCODING)
@ -974,7 +972,7 @@ def view_module_abs(context, REQUEST, moduleimpl_id, format="html"):
M = sco_moduleimpl.do_moduleimpl_withmodule_list(
context, moduleimpl_id=moduleimpl_id
)[0]
sem = sco_formsemestre.get_formsemestre(context, M["formsemestre_id"])
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
debut_sem = ndb.DateDMYtoISO(sem["date_debut"])
fin_sem = ndb.DateDMYtoISO(sem["date_fin"])
list_insc = sco_moduleimpl.do_moduleimpl_listeetuds(context, moduleimpl_id)
@ -1041,7 +1039,7 @@ def view_module_abs(context, REQUEST, moduleimpl_id, format="html"):
)
if format != "html":
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
return "\n".join(H) + tab.html() + html_sco_header.sco_footer()
@ -1129,7 +1127,7 @@ def formsemestre_enseignants_list(context, REQUEST, formsemestre_id, format="htm
"""Liste les enseignants intervenants dans le semestre (resp. modules et chargés de TD)
et indique les absences saisies par chacun.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# resp. de modules:
mods = sco_moduleimpl.do_moduleimpl_withmodule_list(
context, formsemestre_id=formsemestre_id
@ -1274,7 +1272,7 @@ def do_formsemestre_inscription_listinscrits(
):
"""Liste les inscrits (état I) à ce semestre et cache le résultat"""
r = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits(
context, formsemestre_id
formsemestre_id
)
return scu.sendResult(REQUEST, r, format=format, name="inscrits")
@ -1291,7 +1289,7 @@ def formsemestre_desinscription(
S'il s'agit d'un semestre extérieur et qu'il n'y a plus d'inscrit,
le semestre sera supprimé.
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# -- check lock
if not sem["etat"]:
raise ScoValueError("desinscription impossible: semestre verrouille")
@ -1332,7 +1330,7 @@ def formsemestre_desinscription(
sem["date_fin"],
)
inscrits = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
args={"formsemestre_id": formsemestre_id}
)
nbinscrits = len(inscrits)
if nbinscrits <= 1:
@ -1722,7 +1720,7 @@ def formsemestre_bulletins_choice(
context, REQUEST, formsemestre_id, title="", explanation="", choose_mail=False
):
"""Choix d'une version de bulletin"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
H = [
html_sco_header.html_sem_header(context, REQUEST, title, sem),
"""
@ -1841,7 +1839,7 @@ def appreciation_add_form(
edit = 1
else:
edit = 0
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
# check custom access permission
can_edit_app = (current_user.id in sem["responsables"]) or (
current_user.has_permission(Permission.ScoEtudInscrit)
@ -2144,7 +2142,7 @@ def formsemestre_validation_suppress_etud(
dest_url=scu.ScoURL(),
)
if not dialog_confirmed:
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
etud = sco_etud.get_etud_info(etudid=etudid, filled=1)[0]
nt = sco_cache.NotesTableCache.get(formsemestre_id) # > get_etud_decision_sem
decision_jury = nt.get_etud_decision_sem(etudid)
@ -2378,7 +2376,7 @@ def check_sem_integrity(context, formsemestre_id, REQUEST, fix=False):
"""Debug.
Check that ue and module formations are consistents
"""
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
modimpls = sco_moduleimpl.do_moduleimpl_list(
context, formsemestre_id=formsemestre_id
@ -2427,7 +2425,7 @@ def check_sem_integrity(context, formsemestre_id, REQUEST, fix=False):
formation_id = formations_set.pop()
if sem["formation_id"] != formation_id:
sem["formation_id"] = formation_id
sco_formsemestre.do_formsemestre_edit(context, sem)
sco_formsemestre.do_formsemestre_edit(sem)
H.append("""<p class="alert">Problème réparé: vérifiez</p>""")
else:
H.append(
@ -2541,12 +2539,10 @@ def check_formsemestre_integrity(context, formsemestre_id, REQUEST=None):
def check_integrity_all(context, REQUEST=None):
"debug: verifie tous les semestres et tt les formations"
# formations
for F in sco_formations.formation_list(
context,
):
for F in sco_formations.formation_list():
check_form_integrity(context, F["formation_id"], REQUEST=REQUEST)
# semestres
for sem in sco_formsemestre.do_formsemestre_list(context):
for sem in sco_formsemestre.do_formsemestre_list():
check_formsemestre_integrity(context, sem["formsemestre_id"], REQUEST=REQUEST)
return (
html_sco_header.sco_header()

View File

@ -185,7 +185,7 @@ def edit_preferences(context, REQUEST):
def formsemestre_edit_preferences(context, formsemestre_id, REQUEST):
"""Edit preferences for a semestre"""
authuser = REQUEST.AUTHENTICATED_USER
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
ok = (
authuser.has_permission(Permission.ScoImplement)
or ((str(authuser) in sem["responsables"]) and sem["resp_can_edit"])
@ -249,7 +249,7 @@ def showEtudLog(context, etudid, format="html", REQUEST=None):
preferences=sco_preferences.SemPreferences(),
)
return tab.make_page(context, format=format, REQUEST=REQUEST)
return tab.make_page(format=format, REQUEST=REQUEST)
# ---------- PAGE ACCUEIL (listes) --------------
@ -403,7 +403,7 @@ def etud_info(context, etudid=None, format="xml", REQUEST=None):
sem = etud["cursem"]
if sem:
sco_groups.etud_add_group_infos(context, etud, sem)
sco_groups.etud_add_group_infos(etud, sem)
d["insemestre"] = [
{
"current": "1",
@ -736,7 +736,7 @@ sco_publish(
# default=False,
# numero=None,
# redirect=1):
# return sco_groups.partition_create(context, formsemestre_id,
# return sco_groups.partition_create( formsemestre_id,
sco_publish("/etud_info_html", sco_page_etud.etud_info_html, Permission.ScoView)
@ -893,7 +893,7 @@ def _formDem_of_Def(
):
"Formulaire démission ou défaillance Etudiant"
etud = sco_etud.get_etud_info(etudid=etudid, filled=1, REQUEST=REQUEST)[0]
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not sem["etat"]:
raise ScoValueError("Modification impossible: semestre verrouille")
@ -980,12 +980,12 @@ def _do_dem_or_def_etud(
# un "evenement" scolarite
cnx = ndb.GetDBConnexion()
# check lock
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not sem["etat"]:
raise ScoValueError("Modification impossible: semestre verrouille")
#
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid, "formsemestre_id": formsemestre_id}
{"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0]
if not ins:
raise ScoException("etudiant non inscrit ?!")
@ -1070,7 +1070,7 @@ def _do_cancel_dem_or_def(
):
"Annule une demission ou une défaillance"
# check lock
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
if not sem["etat"]:
raise ScoValueError("Modification impossible: semestre verrouille")
# verif
@ -1095,7 +1095,7 @@ def _do_cancel_dem_or_def(
)
#
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, {"etudid": etudid, "formsemestre_id": formsemestre_id}
{"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0]
if ins["etat"] != etat_current:
raise ScoException("etudiant non %s !!!" % etat_current) # obviously a bug
@ -1620,7 +1620,7 @@ def check_group_apogee(
XXX A re-écrire pour API 2: prendre liste dans l'étape et vérifier à partir de cela.
"""
etat = etat or None
members, group, _, sem, _ = sco_groups.get_group_infos(context, group_id, etat=etat)
members, group, _, sem, _ = sco_groups.get_group_infos(group_id, etat=etat)
formsemestre_id = group["formsemestre_id"]
cnx = ndb.GetDBConnexion()
@ -1766,7 +1766,7 @@ def check_group_apogee(
def form_students_import_excel(context, REQUEST, formsemestre_id=None):
"formulaire import xls"
if formsemestre_id:
sem = sco_formsemestre.get_formsemestre(context, formsemestre_id)
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
dest_url = (
# scu.ScoURL() + "/formsemestre_status?formsemestre_id=%s" % formsemestre_id # TODO: Remplacer par for_url ?
url_for(
@ -1929,7 +1929,7 @@ def import_generate_excel_sample(context, REQUEST, with_codesemestre="1"):
@scodoc7func(context)
def import_generate_admission_sample(context, REQUEST, formsemestre_id):
"une feuille excel pour importation données admissions"
group = sco_groups.get_group(context, sco_groups.get_default_group(formsemestre_id))
group = sco_groups.get_group(sco_groups.get_default_group(formsemestre_id))
fmt = sco_import_etuds.sco_import_format()
data = sco_import_etuds.sco_import_generate_excel_sample(
fmt,
@ -2110,7 +2110,7 @@ def stat_bac(context, formsemestre_id):
"Renvoie statistisques sur nb d'etudiants par bac"
cnx = ndb.GetDBConnexion()
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
context, args={"formsemestre_id": formsemestre_id}
args={"formsemestre_id": formsemestre_id}
)
Bacs = {} # type bac : nb etud
for i in ins:

View File

@ -1,191 +0,0 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*
"""Outil pour migration ScoDoc 7 => ScoDoc 8
- Liste des appels de la forme context.xxx
./refactor.py showcontextcalls app/scodoc/*.p
- remplace context.xxx par module.xxx
./refactor.py refactor module.method app/scodoc/*.py
Pour chaque module dans views:
- construire la liste des fonctions définies dans ce module:
get_module_functions
Pour chaque module dans views et dans scodoc:
- remplacer context.xxx par app.views.M.xxx
M est le module de views définissant xxx
Si xxx n'est pas trouvé, erreur !
"""
from __future__ import print_function
import re
from pprint import pprint as pp
import os
import sys
import types
import tempfile
import shutil
import click
TYPES_TO_SCAN = {
types.FunctionType,
# types.ClassType,
# types.DictionaryType,
# types.FloatType,
# types.IntType,
# types.ListType,
# types.StringType,
# types.TupleType,
}
def get_module_symbols(module):
"""returns list of symbols (functions and constants) defined in the given module"""
return [
f.__name__
for f in [getattr(module, name) for name in dir(module)]
if (type(f) in TYPES_TO_SCAN)
and ((type(f) != types.FunctionType) or (f.__module__ == module.__name__))
]
# print("\n".join(f.__name__ for f in get_module_functions(notes)))
def scan_views_symbols():
"""Scan modules in app.views and returns
{ }
"""
import app
views_modules = [
getattr(app.views, mod_name)
for mod_name in dir(app.views)
if type(getattr(app.views, mod_name)) == types.ModuleType
]
sym2mod = {} # symbole_name : module
for module in views_modules:
start = "app.views."
assert module.__name__.startswith(start)
module_name = module.__name__[len(start) :]
symbols = set(get_module_symbols(module))
print("%d symbols defined in %s" % (len(symbols), module))
dups = symbols.intersection(sym2mod)
if len(dups):
print("duplicated symbols !")
for dup in dups:
print("%s:\t%s\t%s" % (dup, sym2mod[dup], module_name))
sym2mod.update({s: module_name for s in symbols})
return sym2mod
def replace_context_calls(sourcefilename, sym2mod):
undefined_list = [] # noms de fonctions non présents dans les modules "views"
def repl(m):
funcname = m.group(1)
module = sym2mod.get(funcname, False)
if module:
return module + "." + funcname
else:
undefined_list.append((sourcefilename, funcname))
return m.group(0) # leave unchanged
print("reading %s" % sourcefilename)
source = open(sourcefilename).read()
exp = re.compile(r"context\.([a-zA-Z0-9_]+)")
source2 = exp.sub(repl, source)
return source2, undefined_list
# sym2mod = scan_views_symbols()
# source2, undefined_list = replace_context_calls("app/scodoc/sco_core.py", sym2mod)
def list_context_calls(sourcefilename):
"""List of methods called on context in this file"""
source = open(sourcefilename).read()
exp = re.compile(r"context\.([a-zA-Z0-9_]+)")
return sorted(set(exp.findall(source)))
def get_context_calls(src_filenames):
"""returns { method_name : [ list of module names in which it is called ] }"""
S = {}
for sourcefilename in src_filenames:
l = list_context_calls(sourcefilename)
module_name = os.path.splitext(os.path.split(sourcefilename)[1])[0]
for m in l:
if m in S:
S[m].append(module_name)
else:
S[m] = [module_name]
return S
@click.group()
def cli():
pass
@cli.command()
@click.argument("src_filenames", nargs=-1)
def showcontextcalls(src_filenames):
click.echo("Appels de méthodes sur l'object context")
S = get_context_calls(src_filenames)
#
for method in sorted(S.keys()):
print(method + ":\t" + ", ".join(S[method]))
@cli.command()
@click.argument("modulemethod", nargs=1)
@click.argument("src_filenames", nargs=-1)
def refactor(modulemethod, src_filenames):
"""Replace call context.method(...)
by module.method(context, ...)
in all given source filenames
"""
modulemethod = str(modulemethod) # avoid unicode in Python2
frags = modulemethod.split(".")
if len(frags) < 2:
raise click.BadParameter("must be module.method", param_hint="modulemethod")
module = ".".join(frags[:-1])
method = frags[-1]
backup = tempfile.mkdtemp(dir="/tmp")
for sourcefilename in src_filenames:
source_module_name = os.path.splitext(os.path.split(sourcefilename)[1])[0]
is_local = source_module_name == module
source = open(sourcefilename).read()
if not is_local:
source2 = source.replace(
"context." + method + "(", module + "." + method + "(context, "
)
source2 = source2.replace(
"context.Notes." + method + "(", module + "." + method + "(context, "
)
else:
# call in the same module:
source2 = source.replace("context." + method + "(", method + "(context, ")
if source2 != source:
print("changed %s" % sourcefilename)
shutil.move(sourcefilename, backup)
open(sourcefilename, "w").write(source2)
print("Done.\noriginal files saved in %s\n" % backup)
if __name__ == "__main__":
try:
cli(obj={})
except SystemExit as e:
if e.code != 0:
raise

View File

@ -292,12 +292,8 @@ for etud in etuds[10:]:
# --- Liste des groupes présents aux évaluation
lig1 = sco_groups.do_evaluation_listegroupes(
context.Scolarite, e1["evaluation_id"], include_default=False
)
lig2 = sco_groups.do_evaluation_listegroupes(
context.Scolarite, e2["evaluation_id"], include_default=False
)
lig1 = sco_groups.do_evaluation_listegroupes(e1["evaluation_id"], include_default=False)
lig2 = sco_groups.do_evaluation_listegroupes(e2["evaluation_id"], include_default=False)
assert len(lig1) == 2

View File

@ -73,7 +73,7 @@ modele = "un_avis.tex" # Modele à actualiser au regard des résultats de l'ét
# Calcul du Jury PE
# *****************************************************************************
# semsDUT = [sem for sem in sems if 1 <= sem['semestre_id'] <= 4 ]
semBase = sco_formsemestre.get_formsemestre(context, fid)
semBase = sco_formsemestre.get_formsemestre(fid)
jury = pe_jurype.JuryPE(context, semBase)

View File

@ -154,7 +154,7 @@ class ScoFake(object):
if not acronyme:
acronyme = "TEST" + str(random.randint(100000, 999999))
oid = sco_edit_formation.do_formation_create(context, locals())
oids = sco_formations.formation_list(context, formation_id=oid)
oids = sco_formations.formation_list(formation_id=oid)
if not oids:
raise ScoValueError("formation not created !")
return oids[0]
@ -241,7 +241,7 @@ class ScoFake(object):
responsables = (self.default_user.id,)
oid = sco_formsemestre.do_formsemestre_create(locals())
oids = sco_formsemestre.do_formsemestre_list(
context, args={"formsemestre_id": oid}
args={"formsemestre_id": oid}
) # API inconsistency
if not oids:
raise ScoValueError("formsemestre not created !")

View File

@ -280,18 +280,17 @@ def test_abs_basic(test_client):
# --- Création d'un groupe
_ = sco_groups.partition_create(
context,
formsemestre_id=sem["formsemestre_id"],
partition_name="Eleve",
)
li1 = sco_groups.get_partitions_list(context, sem["formsemestre_id"])
_ = sco_groups.createGroup(context, li1[0]["partition_id"], "Groupe 1")
li1 = sco_groups.get_partitions_list(sem["formsemestre_id"])
_ = sco_groups.createGroup(li1[0]["partition_id"], "Groupe 1")
# --- Affectation des élèves dans des groupes
li_grp1 = sco_groups.get_partition_groups(context, li1[0])
li_grp1 = sco_groups.get_partition_groups(li1[0])
for etud in etuds:
sco_groups.set_group(context, etud["etudid"], li_grp1[0]["group_id"])
sco_groups.set_group(etud["etudid"], li_grp1[0]["group_id"])
# --- Test de EtatAbsencesGroupes

View File

@ -31,7 +31,7 @@ def test_notes_table(test_client):
# prépare le département avec quelques semestres:
run_sco_basic()
#
sems = sco_formsemestre.do_formsemestre_list(context)
sems = sco_formsemestre.do_formsemestre_list()
assert len(sems)
sem = sems[0]
formsemestre_id = sem["formsemestre_id"]