Compare commits

...

6 Commits

11 changed files with 400 additions and 212 deletions

View File

@ -50,38 +50,17 @@ from app.api.errors import error_response
from app import models
from app.models import FormSemestre, FormSemestreInscription, Identite
from app.models import ApcReferentielCompetences
from app.scodoc.sco_abs import annule_absence, annule_justif
from app.scodoc.sco_bulletins import formsemestre_bulletinetud_dict
from app.scodoc.sco_bulletins_json import make_json_formsemestre_bulletinetud
from app.scodoc.sco_formations import formation_export
from app.scodoc.sco_formsemestre_inscriptions import do_formsemestre_inscription_listinscrits
from app.scodoc.sco_groups import setGroups, get_etud_groups
from app.scodoc.sco_moduleimpl import moduleimpl_list
from app.scodoc.sco_permissions import Permission
@bp.route("/list_depts", methods=["GET"])
@token_auth.login_required
def list_depts():
depts = models.Departement.query.filter_by(visible=True).all()
data = [d.to_dict() for d in depts]
return jsonify(data)
@bp.route("/etudiants/courant", methods=["GET"])
@token_auth.login_required
def etudiants():
"""Liste de tous les étudiants actuellement inscrits à un semestre
en cours.
"""
# Vérification de l'accès: permission Observateur sur tous les départements
# (c'est un exemple à compléter)
if not g.current_user.has_permission(Permission.ScoObservateur, None):
return error_response(401, message="accès interdit")
query = db.session.query(Identite).filter(
FormSemestreInscription.formsemestre_id == FormSemestre.id,
FormSemestreInscription.etudid == Identite.id,
FormSemestre.date_debut <= func.now(),
FormSemestre.date_fin >= func.now(),
)
return jsonify([e.to_dict_bul(include_urls=False) for e in query])
######################## Departements ##################################
############################################### Departements ##########################################################
@bp.route("/departements", methods=["GET"])
@ -97,7 +76,7 @@ def departements():
@bp.route("/departements/<string:dept>/etudiants/liste/<int:sem_id>", methods=["GET"])
@token_auth.login_required
def liste_etudiants(dept, *args, sem_id): # XXX TODO A REVOIR
def liste_etudiants(dept: str, *args, sem_id): # XXX TODO A REVOIR
"""
Liste des étudiants d'un département
"""
@ -133,145 +112,273 @@ def liste_etudiants(dept, *args, sem_id): # XXX TODO A REVOIR
@bp.route("/departements/<string:dept>/semestres_actifs", methods=["GET"])
@token_auth.login_required
def liste_semestres_actifs(dept): # TODO : changer nom
def liste_semestres_courant(dept: str):
"""
Liste des semestres actifs d'un départements donné
"""
# Récupération de l'id du dept
dept_id = models.Departement.query.filter(models.Departement.acronym == dept)
# Puis ici récupération du FormSemestre correspondant
depts_actifs = models.FormSemestre.query.filter_by(
etat=True,
dept_id=dept_id,
)
data = [da.to_dict() for da in depts_actifs]
depts = models.Departement.query.filter_by(acronym=dept).all()
# return jsonify(data)
return error_response(501, message="Not implemented")
id_dept = depts[0].id
semestres = models.FormSemestre.query.filter_by(dept_id=id_dept, etat=True).all()
@bp.route("/referentiel_competences/<int:referentiel_competence_id>")
@token_auth.login_required
def referentiel_competences(referentiel_competence_id):
data = semestres[0].to_dict()
return jsonify(data)
@bp.route(
"/departements/<string:dept>/formations/<int:formation_id>/referentiel_competences",
methods=["GET"],
)
def referenciel_competences(dept: str, formation_id: int):
"""
Le référentiel de compétences
"""
ref = ApcReferentielCompetences.query.get_or_404(referentiel_competence_id)
# depts = models.Departement.query.filter_by(acronym=dept).all()
#
# id_dept = depts[0].id
#
# formations = models.Formation.query.filter_by(id=formation_id, dept_id=id_dept).all()
#
# ref_comp = formations[0].referentiel_competence_id
#
# if ref_comp is None:
# return error_response(204, message="Pas de référenciel de compétences pour cette formation")
# else:
# return jsonify(ref_comp)
ref = ApcReferentielCompetences.query.get_or_404(formation_id)
return jsonify(ref.to_dict())
####################### Etudiants ##################################
@bp.route("/etudiant/<int:etudid>", methods=["GET"])
@token_auth.login_required
def etudiant(etudid):
@bp.route("/departements/<string:dept>/formations/programme/<string:sem_idx>", methods=["GET"])
def semestre_index(dept: str, sem_idx: str):
"""
Un dictionnaire avec les informations de l'étudiant correspondant à l'id passé en paramètres.
"""
etud: Identite = Identite.query.get_or_404(etudid)
return jsonify(etud.to_dict_bul())
return error_response(501, message="not implemented")
@bp.route("/etudiant/<int:etudid>/semestre/<int:sem_id>/bulletin", methods=["GET"])
@token_auth.login_required
def etudiant_bulletin_semestre(etudid, sem_id):
#################################################### Etudiants ########################################################
@bp.route("/etudiants", methods=["GET"])
def etudiants():
"""
La liste des étudiants
"""
etu = models.Identite.query.all()
data = [d.to_dict_bul(include_urls=False) for d in etu]
return jsonify(data)
# return error_response(501, message="Not implemented")
@bp.route("/etudiants/courant", methods=["GET"])
def etudiants_courant():
"""
La liste des étudiants courant
"""
etus = models.Identite.query.all()
data = []
for etu in etus:
if etu.inscription_courante() is not None:
data.append(etu.to_dict_bul(include_urls=False))
return jsonify(data)
# return error_response(501, message="Not implemented")
@bp.route("/etudiant/etudid/<int:etudid>", methods=["GET"])
@bp.route("/etudiant/nip/<int:nip>", methods=["GET"])
@bp.route("/etudiant/ine/<int:ine>", methods=["GET"])
def etudiant(etudid=None, nip=None, ine=None):
"""
Les informations de l'étudiant correspondant à l'id passé en paramètres.
"""
etu = []
if etudid is not None:
etu = models.Identite.query.filter_by(id=etudid).first()
if nip is not None:
etu = models.Identite.query.filter_by(code_nip=etudid).first()
if ine is not None:
etu = models.Identite.query.filter_by(code_ine=etudid).first()
data = etu.to_dict_bul(include_urls=False)
return jsonify(data)
@bp.route("/etudiant/etudid/<int:etudid>/formsemestres")
@bp.route("/etudiant/nip/<int:nip>/formsemestres")
@bp.route("/etudiant/ine/<int:ine>/formsemestres")
def etudiant_formsemestres(etudid=None, nip=None, ine=None):
"""
Retourne les semestres qu'un étudiant a suivi
"""
inscriptions = models.FormSemestreInscription.query.all()
sems = []
for sem in inscriptions:
if etudid is not None:
if sem.etudid == etudid:
sems.append(sem)
if nip is not None:
etu = models.Identite.query.filter_by(code_nip=nip).first()
if sem.etudid == etu.etudid:
sems.append(sem)
if ine is not None:
etu = models.Identite.query.filter_by(code_ine=ine).firt()
if sem.etudid == etu.etudid:
sems.append(sem)
data_inscriptions = [d.to_dict() for d in sems]
formsemestres = []
for sem in data_inscriptions:
res = models.FormSemestre.query.filter_by(id=sem['formsemestre_id']).first()
formsemestres.append(res)
data = []
for formsem in formsemestres:
data.append(formsem.to_dict())
return jsonify(data)
@bp.route("/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin", methods=["GET"])
@bp.route("/etudiant/nip/<int:nip>/formsemestre/<int:formsemestre_id>/bulletin", methods=["GET"])
@bp.route("/etudiant/ine/<int:ine>/formsemestre/<int:formsemestre_id>/bulletin", methods=["GET"])
def etudiant_bulletin_semestre(formsemestre_id, etudid=None, nip=None, ine=None):
"""
Le bulletin d'un étudiant en fonction de son id et d'un semestre donné
"""
# return jsonify(models.BulAppreciations.query.filter_by(etudid=etudid, formsemestre_id=sem_id))
return error_response(501, message="Not implemented")
@bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/nip/<int:NIP>/releve",
methods=["GET"],
)
@bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/id/<int:etudid>/releve",
methods=["GET"],
)
@bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/ine/<int:numScodoc>/releve",
methods=["GET"],
)
@token_auth.login_required
def etudiant_bulletin(formsemestre_id, dept, etudid, format="json", *args, size):
"""
Un bulletin de note
"""
formsemestres = models.FormSemestre.query.filter_by(id=formsemestre_id)
depts = models.Departement.query.filter_by(acronym=dept)
etud = ""
data = []
if args[0] == "short":
pass
elif args[0] == "selectevals":
pass
elif args[0] == "long":
pass
# fonction to use: make_json_formsemestre_bulletinetud()
if etudid is not None:
return make_json_formsemestre_bulletinetud(formsemestre_id, etudid)
else:
return "erreur"
etu = None
if nip is not None:
etu = models.Identite.query.filter_by(code_nip=nip).first()
# return jsonify(data)
return error_response(501, message="Not implemented")
if ine is not None:
etu = models.Identite.query.filter_by(code_nip=ine).first()
if etu is not None:
return make_json_formsemestre_bulletinetud(formsemestre_id, etu.etudid)
# return error_response(501, message="Not implemented")
@bp.route(
"/etudiant/<int:etudid>/semestre/<int:formsemestre_id>/groups", methods=["GET"]
"/etudiant/etudid/<int:etudid>/semestre/<int:formsemestre_id>/groups", methods=["GET"]
)
@token_auth.login_required
def etudiant_groups(etudid: int, formsemestre_id: int):
@bp.route(
"/etudiant/nip/<int:nip>/semestre/<int:formsemestre_id>/groups", methods=["GET"]
)
@bp.route(
"/etudiant/ine/<int:ine>/semestre/<int:formsemestre_id>/groups", methods=["GET"]
)
def etudiant_groups(formsemestre_id: int, etudid=None, nip=None, ine=None):
"""
Liste des groupes auxquels appartient l'étudiant dans le semestre indiqué
"""
semestre = models.FormSemestre.query.filter_by(id=formsemestre_id)
etudiant = models.Identite.query.filter_by(id=etudid)
# fonction to use : get_etud_groups
groups = models.Partition.query.filter(
models.Partition.formsemestre_id == semestre,
models.GroupDescr.etudiants == etudiant,
)
data = [d.to_dict() for d in groups]
# return jsonify(data)
if etudid is None:
if nip is not None:
etu = models.Identite.query.filter_by(code_nip=nip).first()
etudid = etu.etudid
if ine is not None:
etu = models.Identite.query.filter_by(code_ine=ine).first()
etudid = etu.etudid
sem = models.FormSemestre.query.filter_by(id=formsemestre_id).first()
try:
data = get_etud_groups(etudid, sem.to_dict())
except ValueError:
return error_response(409, message="La requête ne peut être traitée en létat actuel")
return error_response(501, message="Not implemented")
return jsonify(data)
#######################" Programmes de formations #########################
##############################################" Formations ############################################################
@bp.route("/formations", methods=["GET"])
@bp.route("/formations/<int:formation_id>", methods=["GET"])
@token_auth.login_required
def formations(formation_id: int):
def formations():
"""
Liste des formations
"""
formations = models.Formation.query.filter_by(id=formation_id)
data = [d.to_dict() for d in formations]
# return jsonify(data)
list_formations = models.Formation.query.all()
return error_response(501, message="Not implemented")
data = [d.to_dict() for d in list_formations]
return jsonify(data)
@bp.route("/formations/<int:formation_id>", methods=["GET"])
def formations_by_id(formation_id: int):
"""
Formation en fonction d'un id donné
"""
forma = models.Formation.query.filter_by(id=formation_id).all()
data = [d.to_dict() for d in forma]
return jsonify(data)
@bp.route("/formations/formation_export/<int:formation_id>", methods=["GET"])
@token_auth.login_required
def formation_export(formation_id: int, export_ids=False):
def formation_export_by_formation_id(formation_id: int, export_ids=False):
"""
La formation, avec UE, matières, modules
"""
data = formation_export(formation_id)
return jsonify(data)
@bp.route("/formations/apo/<int:etape_apo>", methods=["GET"])
def formsemestre_apo(etape_apo: int):
"""
Information sur les formsemestres
"""
return error_response(501, message="Not implemented")
###################### UE #######################################
@bp.route("/formations/moduleimpl/<int:moduleimpl_id>", methods=["GET"])
def moduleimpls(moduleimpl_id: int):
"""
Liste des moduleimpl
"""
list_moduleimpls = models.ModuleImpl.query.filter_by(id=moduleimpl_id)
data = list_moduleimpls[0].to_dict()
return jsonify(data)
@bp.route(
"/formations/moduleimpl/<int:moduleimpl_id>/formsemestre/<int:formsemestre_id>",
methods=["GET"],
)
def moduleimpls_sem(moduleimpl_id: int, formsemestre_id: int):
"""
Liste de moduleimpl d'un semestre
"""
data = moduleimpl_list(moduleimpl_id, formsemestre_id)
return jsonify(data)
# return error_response(501, message="Not implemented")
#################################################### UE ###############################################################
@bp.route(
"/departements/<string:dept>/formations/programme/<string:sem_id>", methods=["GET"]
)
@token_auth.login_required
def eus(dept: str, sem_id: int):
"""
Liste des UES, ressources et SAE d'un semestre
@ -279,42 +386,70 @@ def eus(dept: str, sem_id: int):
return error_response(501, message="Not implemented")
######## Semestres de formation ###############
########################################## Formsemestres ##############################################################
@bp.route("/formations/formsemestre/<int:formsemestre_id>", methods=["GET"])
@bp.route("/formations/apo/<int:etape_apo>", methods=["GET"])
@token_auth.login_required
def formsemestre(
id: int,
):
def formsemestre(formsemestre_id: int):
"""
Information sur les formsemestres
Information sur le formsemestre correspondant au formsemestre_id
"""
return error_response(501, message="Not implemented")
list_formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id)
data = list_formsemetre[0].to_dict()
return jsonify(data)
############ Modules de formation ##############
@bp.route("/formations/moduleimpl/<int:moduleimpl_id>", methods=["GET"])
@bp.route(
"/formations/moduleimpl/<int:moduleimpl_id>/formsemestre/<int:formsemestre_id>",
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/etudid/<int:etudid>/bulletin",
methods=["GET"],
)
@token_auth.login_required
def moduleimpl(id: int):
@bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/nip/<int:nip>/bulletin",
methods=["GET"],
)
@bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/ine/<int:ine>/bulletin",
methods=["GET"],
)
def etudiant_bulletin(formsemestre_id, dept, etudid, format="json", *args, size):
"""
Liste de moduleimpl
Un bulletin de note
"""
data = []
if args[0] == "short":
data = formsemestre_bulletinetud_dict(formsemestre_id, etudid, version=args[0])
elif args[0] == "selectevals":
data = formsemestre_bulletinetud_dict(formsemestre_id, etudid, version=args[0])
elif args[0] == "long":
data = formsemestre_bulletinetud_dict(formsemestre_id, etudid)
else:
return error_response(501, message="Not implemented")
return jsonify(data)
@bp.route("/formsemestre/<int:formsemestre_id>/bulletins", methods=["GET"])
def bulletins(formsemestre_id: int):
"""
Les bulletins d'un formsemestre donné
"""
return error_response(501, message="Not implemented")
########### Groupes et partitions ###############
@bp.route("/formsemestre/<int:formsemestre_id>/jury", methods=["GET"])
def jury(formsemestre_id: int):
"""
"""
return error_response(501, message="Not implemented")
############################################### Partitions ############################################################
@bp.route("/partitions/<int:formsemestre_id>", methods=["GET"])
@token_auth.login_required
def partition(formsemestre_id: int):
"""
La liste de toutes les partitions d'un formsemestre
@ -330,7 +465,6 @@ def partition(formsemestre_id: int):
"/partitions/formsemestre/<int:formsemestre_id>/groups/group_ids?with_codes=&all_groups=&etat=",
methods=["GET"],
)
@token_auth.login_required
def groups(formsemestre_id: int, group_ids: int):
"""
Liste des étudiants dans un groupe
@ -339,24 +473,27 @@ def groups(formsemestre_id: int, group_ids: int):
@bp.route(
"/partitions/set_groups?partition_id=<int:partition_id>&groups=<int:groups>&groups_to_delete=<int:groups_to_delete>&groups_to_create=<int:groups_to_create>",
methods=["POST"],
"/partitions/set_groups?partition_id=<int:partition_id>&groups_lists=<int:groups_lists>&groups_to_create=<int"
":groups_to_create>&groups_to_delete=<int:groups_to_delete>", methods=["POST"],
)
@token_auth.login_required
def set_groups(
partition_id: int, groups: int, groups_to_delete: int, groups_to_create: int
partition_id: int, groups_lists: int, groups_to_delete: int, groups_to_create: int
):
"""
Set les groups
"""
return error_response(501, message="Not implemented")
try:
setGroups(partition_id, groups_lists, groups_to_create, groups_to_delete)
return error_response(200, message="Groups set")
except ValueError:
return error_response(409, message="La requête ne peut être traitée en létat actuel")
####### Bulletins de notes ###########
################################################### Evaluations #######################################################
@bp.route("/evaluations/<int:moduleimpl_id>", methods=["GET"])
@token_auth.login_required
def evaluations(moduleimpl_id: int):
"""
Liste des évaluations à partir de l'id d'un moduleimpl
@ -364,22 +501,21 @@ def evaluations(moduleimpl_id: int):
evals = models.Evaluation.query.filter_by(id=moduleimpl_id)
data = [d.to_dict() for d in evals]
# return jsonify(data)
return error_response(501, message="Not implemented")
return jsonify(data)
# return error_response(501, message="Not implemented")
@bp.route("/evaluations/eval_notes/<int:evaluation_id>", methods=["GET"])
@token_auth.login_required
def evaluation_notes(evaluation_id: int):
"""
Liste des notes à partir de l'id d'une évaluation donnée
"""
evals = models.Evaluation.query.filter_by(id=evaluation_id)
notes = evals.get_notes()
notes = models.NotesNotes.query.filter_by(evaluation_id=evaluation_id).all()
data = [d.to_dict() for d in notes]
# return jsonify(data)
return error_response(501, message="Not implemented")
return jsonify(data)
# return error_response(501, message="Not implemented")
@bp.route(
@ -394,20 +530,52 @@ def evaluation_set_notes(eval_id: int, etudid: int, note: float):
return error_response(501, message="Not implemented")
############## Absences #############
#################################################### Absences #########################################################
@bp.route("/absences/<int:etudid>", methods=["GET"])
@bp.route("/absences/<int:etudid>/abs_just_only", methods=["GET"])
def absences(etudid: int):
def absences(etudid=None, nip=None, ine=None):
"""
Liste des absences d'un étudiant donnée
Liste des absences d'un étudiant donné
"""
abs = models.Absence.query.filter_by(id=etudid)
abs = ""
if etudid is not None:
abs = models.Absence.query.filter_by(etudid=etudid).all()
else:
if nip is not None:
etu = models.Identite.query.filter_by(code_nip=nip).first()
abs = models.Absence.query.filter_by(etudid=etu.etudid).all()
if ine is not None:
etu = models.Identite.query.filter_by(code_ine=ine).first()
abs = models.Absence.query.filter_by(etudid=etu.etudid).all()
if abs != "":
data = [d.to_dict() for d in abs]
# return jsonify(data)
return jsonify(data)
return error_response(501, message="Not implemented")
@bp.route("/absences/<int:etudid>/abs_just_only", methods=["GET"])
def absences_justify(etudid=None, nip=None, ine=None):
"""
Liste des absences justifiés d'un étudiant donné
"""
abs = ""
if etudid is not None:
abs = models.Absence.query.filter_by(etudid=etudid, estjust=True).all()
else:
if nip is not None:
etu = models.Identite.query.filter_by(code_nip=nip).first()
abs = models.Absence.query.filter_by(etudid=etu.etudid, estjust=True).all()
if ine is not None:
etu = models.Identite.query.filter_by(code_ine=ine).first()
abs = models.Absence.query.filter_by(etudid=etu.etudid, estjust=True).all()
if abs != "":
data = [d.to_dict() for d in abs]
return jsonify(data)
return error_response(501, message="Not implemented")
@ -420,43 +588,73 @@ def abs_signale():
return error_response(501, message="Not implemented")
@bp.route("/absences/abs_annule", methods=["POST"])
@bp.route("/absences/abs_annule?etudid=<int:etudid>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
@bp.route("/absences/abs_annule?nip=<int:nip>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
@bp.route("/absences/abs_annule?ine=<int:ine>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
@token_auth.login_required
def abs_annule():
def abs_annule(jour: datetime, matin: str, etudid=None, nip=None, ine=None):
"""
Retourne un html
"""
return error_response(501, message="Not implemented")
# fonction to use : annule_absence
if etudid is None:
if nip is not None:
etu = models.Identite.query.filter_by(code_nip=nip).first()
etudid = etu.etudid
if ine is not None:
etu = models.Identite.query.filter_by(code_ine=ine).first()
etudid = etu.etudid
try:
annule_absence(etudid, jour, matin)
except ValueError:
return error_response(409, message="La requête ne peut être traitée en létat actuel")
return error_response(200, message="OK")
@bp.route("/absences/abs_annule_justif", methods=["POST"])
@bp.route("/absences/abs_annule_justif?etudid=<int:etudid>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
@bp.route("/absences/abs_annule_justif?nip=<int:nip>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
@bp.route("/absences/abs_annule_justif?ine=<int:ine>&jour=<string:jour>&matin=<string:matin>", methods=["POST"])
@token_auth.login_required
def abs_annule_justif():
def abs_annule_justif(jour: datetime, matin: str, etudid=None, nip=None, ine=None):
"""
Retourne un html
"""
return error_response(501, message="Not implemented")
# fonction to use : annule_justif
if etudid is None:
if nip is not None:
etu = models.Identite.query.filter_by(code_nip=nip).first()
etudid = etu.etudid
if ine is not None:
etu = models.Identite.query.filter_by(code_ine=ine).first()
etudid = etu.etudid
try:
annule_justif(etudid, jour, matin)
except ValueError:
return error_response(409, message="La requête ne peut être traitée en létat actuel")
return error_response(200, message="OK")
@bp.route(
"/absences/abs_group_etat/?group_ids=<int:group_ids>&date_debut=date_debut&date_fin=date_fin",
methods=["GET"],
)
@token_auth.login_required
def abs_groupe_etat(
group_ids: int, date_debut, date_fin, with_boursier=True, format="html"
):
"""
Liste des absences d'un ou plusieurs groupes entre deux dates
"""
# list_abs_date
return error_response(501, message="Not implemented")
################ Logos ################
###################################################### Logos ##########################################################
@bp.route("/logos", methods=["GET"])
@token_auth.login_required
def liste_logos(format="json"):
"""
Liste des logos définis pour le site scodoc.
@ -465,7 +663,6 @@ def liste_logos(format="json"):
@bp.route("/logos/<string:nom>", methods=["GET"])
@token_auth.login_required
def recup_logo_global(nom: str):
"""
Retourne l'image au format png ou jpg
@ -474,7 +671,6 @@ def recup_logo_global(nom: str):
@bp.route("/departements/<string:dept>/logos", methods=["GET"])
@token_auth.login_required
def logo_dept(dept: str):
"""
Liste des logos définis pour le département visé.
@ -483,7 +679,6 @@ def logo_dept(dept: str):
@bp.route("/departement/<string:dept>/logos/<string:nom>", methods=["GET"])
@token_auth.login_required
def recup_logo_dept_global(dept: str, nom: str):
"""
L'image format png ou jpg

View File

@ -387,7 +387,7 @@ class BonusBordeaux1(BonusSportMultiplicatif):
"""
name = "bonus_iutBordeaux1"
displayed_name = "IUT de Bordeaux 1"
displayed_name = "IUT de Bordeaux"
classic_use_bonus_ues = True # s'applique aux UEs en DUT et LP
seuil_moy_gen = 10.0
amplitude = 0.005

View File

@ -218,21 +218,25 @@ def compute_ue_moys_apc(
ues: list,
modimpl_inscr_df: pd.DataFrame,
modimpl_coefs_df: pd.DataFrame,
modimpl_mask: np.array,
) -> pd.DataFrame:
"""Calcul de la moyenne d'UE en mode APC (BUT).
La moyenne d'UE est un nombre (note/20), ou NI ou NA ou ERR
NI non inscrit à (au moins un) module de cette UE
NA pas de notes disponibles
ERR erreur dans une formule utilisateur. [XXX pas encore gérées ici]
ERR erreur dans une formule utilisateurs (pas gérées ici).
sem_cube: notes moyennes aux modules
ndarray (etuds x modimpls x UEs)
(floats avec des NaN)
etuds : liste des étudiants (dim. 0 du cube)
modimpls : liste des modules à considérer (dim. 1 du cube)
modimpls : liste des module_impl (dim. 1 du cube)
ues : liste des UE (dim. 2 du cube)
modimpl_inscr_df: matrice d'inscription du semestre (etud x modimpl)
modimpl_coefs_df: matrice coefficients (UE x modimpl), sans UEs bonus sport
modimpl_mask: liste de booléens, indiquants le module doit être pris ou pas.
(utilisé pour éliminer les bonus, et pourra servir à cacluler
sur des sous-ensembles de modules)
Résultat: DataFrame columns UE (sans bonus), rows etudid
"""
@ -249,7 +253,8 @@ def compute_ue_moys_apc(
assert modimpl_coefs_df.shape[0] == nb_ues_no_bonus
assert modimpl_coefs_df.shape[1] == nb_modules
modimpl_inscr = modimpl_inscr_df.values
modimpl_coefs = modimpl_coefs_df.values
# Met à zéro tous les coefs des modules non sélectionnés dans le masque:
modimpl_coefs = np.where(modimpl_mask, modimpl_coefs_df.values, 0.0)
# Duplique les inscriptions sur les UEs non bonus:
modimpl_inscr_stacked = np.stack([modimpl_inscr] * nb_ues_no_bonus, axis=2)

View File

@ -56,14 +56,11 @@ class ResultatsSemestreBUT(NotesTableCompat):
# modimpl_coefs_df.columns.get_loc(modimpl.id)
# idx de l'UE: modimpl_coefs_df.index.get_loc(ue.id)
# Elimine les coefs des modimpl bonus sports:
modimpls_sport = [
modimpl
# Masque de tous les modules _sauf_ les bonus (sport)
modimpls_mask = [
modimpl.module.ue.type != UE_SPORT
for modimpl in self.formsemestre.modimpls_sorted
if modimpl.module.ue.type == UE_SPORT
]
for modimpl in modimpls_sport:
self.modimpl_coefs_df[modimpl.id] = 0
self.etud_moy_ue = moy_ue.compute_ue_moys_apc(
self.sem_cube,
@ -72,6 +69,7 @@ class ResultatsSemestreBUT(NotesTableCompat):
self.ues,
self.modimpl_inscr_df,
self.modimpl_coefs_df,
modimpls_mask,
)
# Les coefficients d'UE ne sont pas utilisés en APC
self.etud_coef_ue_df = pd.DataFrame(
@ -85,7 +83,7 @@ class ResultatsSemestreBUT(NotesTableCompat):
self.etud_moy_ue -= self.malus
# --- Bonus Sport & Culture
if len(modimpls_sport) > 0:
if not all(modimpls_mask): # au moins un module bonus
bonus_class = ScoDocSiteConfig.get_bonus_sport_class()
if bonus_class is not None:
bonus: BonusSport = bonus_class(

View File

@ -104,6 +104,11 @@ class FormSemestre(db.Model):
lazy=True,
backref=db.backref("formsemestres", lazy=True),
)
partitions = db.relationship(
"Partition",
backref=db.backref("formsemestre", lazy=True),
lazy="dynamic",
)
# Ancien id ScoDoc7 pour les migrations de bases anciennes
# ne pas utiliser après migrate_scodoc7_dept_archives
scodoc7_id = db.Column(db.Text(), nullable=True)

View File

@ -31,6 +31,11 @@ class Partition(db.Model):
show_in_lists = db.Column(
db.Boolean(), nullable=False, default=True, server_default="true"
)
groups = db.relationship(
"GroupDescr",
backref=db.backref("partition", lazy=True),
lazy="dynamic",
)
def __init__(self, **kwargs):
super(Partition, self).__init__(**kwargs)
@ -42,6 +47,9 @@ class Partition(db.Model):
else:
self.numero = 1
def __repr__(self):
return f"""<{self.__class__.__name__} {self.id} "{self.partition_name or '(default)'}">"""
class GroupDescr(db.Model):
"""Description d'un groupe d'une partition"""
@ -55,6 +63,11 @@ class GroupDescr(db.Model):
# "A", "C2", ... (NULL for 'all'):
group_name = db.Column(db.String(GROUPNAME_STR_LEN))
def __repr__(self):
return (
f"""<{self.__class__.__name__} {self.id} "{self.group_name or '(tous)'}">"""
)
group_membership = db.Table(
"group_membership",

View File

@ -91,7 +91,7 @@ class releveBUT extends HTMLElement {
<div>
<div class=decision></div>
<div class=dateInscription>Inscrit le </div>
<em>Les moyennes servent à situer l'étudiant dans la promotion et ne correspondent pas à des validations de compétences ou d'UE.</em>
<em>Les moyennes ci-dessus servent à situer l'étudiant dans la promotion et ne correspondent pas à des validations de compétences ou d'UE.</em>
</div>
</div>

View File

@ -4,7 +4,7 @@
<div class="sidebar">
{# sidebar_common #}
<a class="scodoc_title" href="{{
url_for('scodoc.index', scodoc_dept=g.scodoc_dept) }}">ScoDoc 9.2a</a>
url_for('scodoc.index', scodoc_dept=g.scodoc_dept) }}">ScoDoc {{ sco.SCOVERSION }}</a>
<div id="authuser"><a id="authuserlink" href="{{
url_for('users.user_info_page', scodoc_dept=g.scodoc_dept, user_name=current_user.user_name)
}}">{{current_user.user_name}}</a>

View File

@ -16,6 +16,7 @@ from app.scodoc import sco_formsemestre_status
from app.scodoc import sco_preferences
from app.scodoc.sco_permissions import Permission
from app.scodoc import sco_utils as scu
import sco_version
scodoc_bp = Blueprint("scodoc", __name__)
scolar_bp = Blueprint("scolar", __name__)
@ -53,6 +54,7 @@ class ScoData:
# Champs utilisés par toutes les pages ScoDoc (sidebar, en-tête)
self.Permission = Permission
self.scu = scu
self.SCOVERSION = sco_version.SCOVERSION
# -- Informations étudiant courant, si sélectionné:
etudid = g.get("etudid", None)
if not etudid:

View File

@ -19,31 +19,6 @@ depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("apc_competence", sa.Column("id_orebut", sa.Text(), nullable=True))
op.drop_constraint(
"apc_competence_referentiel_id_titre_key", "apc_competence", type_="unique"
)
op.create_index(
op.f("ix_apc_competence_id_orebut"),
"apc_competence",
["id_orebut"],
)
op.add_column(
"apc_referentiel_competences", sa.Column("annexe", sa.Text(), nullable=True)
)
op.add_column(
"apc_referentiel_competences",
sa.Column("type_structure", sa.Text(), nullable=True),
)
op.add_column(
"apc_referentiel_competences",
sa.Column("type_departement", sa.Text(), nullable=True),
)
op.add_column(
"apc_referentiel_competences",
sa.Column("version_orebut", sa.Text(), nullable=True),
)
op.create_index(
op.f("ix_notes_formsemestre_uecoef_formsemestre_id"),
"notes_formsemestre_uecoef",
@ -80,15 +55,10 @@ def downgrade():
table_name="notes_formsemestre_uecoef",
)
op.drop_column("apc_referentiel_competences", "version_orebut")
op.drop_column("apc_referentiel_competences", "type_departement")
op.drop_column("apc_referentiel_competences", "type_structure")
op.drop_column("apc_referentiel_competences", "annexe")
op.drop_index(op.f("ix_apc_competence_id_orebut"), table_name="apc_competence")
op.create_unique_constraint(
"apc_competence_referentiel_id_titre_key",
"apc_competence",
["referentiel_id", "titre"],
)
op.drop_column("apc_competence", "id_orebut")
# ### end Alembic commands ###

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.1.57"
SCOVERSION = "9.1.58"
SCONAME = "ScoDoc"