2022-03-02 16:45:47 +01:00
|
|
|
############################################### Departements ##########################################################
|
2022-04-21 15:57:02 +02:00
|
|
|
import app
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
from app import models
|
|
|
|
from app.api import bp
|
2022-04-26 15:23:10 +02:00
|
|
|
from app.api.auth import token_permission_required
|
2022-03-02 16:45:47 +01:00
|
|
|
from app.api.errors import error_response
|
2022-03-04 17:16:08 +01:00
|
|
|
from app.scodoc.sco_permissions import Permission
|
2022-03-02 16:45:47 +01:00
|
|
|
|
2022-04-25 15:25:45 +02:00
|
|
|
from flask import jsonify
|
|
|
|
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
@bp.route("/departements", methods=["GET"])
|
2022-04-13 12:39:10 +02:00
|
|
|
@token_permission_required(Permission.APIView)
|
2022-03-02 16:45:47 +01:00
|
|
|
def departements():
|
|
|
|
"""
|
|
|
|
Retourne la liste des ids de départements visibles
|
|
|
|
|
|
|
|
Exemple de résultat : [2, 5, 8, 1, 4, 18]
|
|
|
|
"""
|
|
|
|
# Récupération de tous les départements
|
2022-04-26 15:23:10 +02:00
|
|
|
depts = models.Departement.query.filter_by(visible=True)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
# Mise en place de la liste avec tous les ids de départements
|
|
|
|
depts_ids = [d.id for d in depts]
|
|
|
|
|
|
|
|
return jsonify(depts_ids)
|
|
|
|
|
|
|
|
|
2022-03-03 16:25:29 +01:00
|
|
|
@bp.route("/departements/<string:dept>/etudiants/liste", methods=["GET"])
|
2022-04-13 12:39:10 +02:00
|
|
|
@bp.route(
|
|
|
|
"/departements/<string:dept>/etudiants/liste/<int:formsemestre_id>", methods=["GET"]
|
|
|
|
)
|
2022-04-14 14:56:36 +02:00
|
|
|
@token_permission_required(Permission.APIView)
|
2022-03-04 17:16:08 +01:00
|
|
|
def liste_etudiants(dept: str, formsemestre_id=None):
|
2022-03-02 16:45:47 +01:00
|
|
|
"""
|
|
|
|
Retourne la liste des étudiants d'un département
|
|
|
|
|
|
|
|
dept: l'acronym d'un département
|
|
|
|
formsemestre_id: l'id d'un formesemestre
|
|
|
|
|
|
|
|
Exemple de résultat :
|
|
|
|
{
|
|
|
|
"civilite": "X",
|
|
|
|
"code_ine": null,
|
|
|
|
"code_nip": null,
|
|
|
|
"date_naissance": null,
|
|
|
|
"email": null,
|
|
|
|
"emailperso": null,
|
|
|
|
"etudid": 18,
|
|
|
|
"nom": "MOREL",
|
|
|
|
"prenom": "JACQUES"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"civilite": "X",
|
|
|
|
"code_ine": null,
|
|
|
|
"code_nip": null,
|
|
|
|
"date_naissance": null,
|
|
|
|
"email": null,
|
|
|
|
"emailperso": null,
|
|
|
|
"etudid": 19,
|
|
|
|
"nom": "FOURNIER",
|
|
|
|
"prenom": "ANNE"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
"""
|
|
|
|
# Si le formsemestre_id a été renseigné
|
|
|
|
if formsemestre_id is not None:
|
2022-03-03 16:25:29 +01:00
|
|
|
# Récupération du formsemestre
|
2022-04-26 17:12:30 +02:00
|
|
|
formsemestre = models.FormSemestre.query.filter_by(
|
|
|
|
id=formsemestre_id
|
|
|
|
).first_or_404()
|
2022-03-03 16:25:29 +01:00
|
|
|
# Récupération du département
|
|
|
|
departement = formsemestre.departement
|
|
|
|
|
|
|
|
# Si le formsemestre_id n'a pas été renseigné
|
|
|
|
else:
|
|
|
|
# Récupération du formsemestre
|
2022-04-26 15:23:10 +02:00
|
|
|
departement = models.Departement.query.filter_by(acronym=dept).first_or_404()
|
2022-03-03 16:25:29 +01:00
|
|
|
|
2022-04-22 16:22:10 +02:00
|
|
|
# Récupération des étudiants
|
|
|
|
etudiants = departement.etudiants.all()
|
|
|
|
|
|
|
|
# Mise en forme des données
|
|
|
|
list_etu = [etu.to_dict_bul(include_urls=False) for etu in etudiants]
|
2022-03-03 16:25:29 +01:00
|
|
|
|
|
|
|
return jsonify(list_etu)
|
|
|
|
|
|
|
|
|
2022-03-02 16:45:47 +01:00
|
|
|
@bp.route("/departements/<string:dept>/semestres_courants", methods=["GET"])
|
2022-04-14 14:56:36 +02:00
|
|
|
@token_permission_required(Permission.APIView)
|
2022-03-02 16:45:47 +01:00
|
|
|
def liste_semestres_courant(dept: str):
|
|
|
|
"""
|
|
|
|
Liste des semestres actifs d'un départements donné
|
|
|
|
|
|
|
|
dept: l'acronym d'un département
|
|
|
|
|
|
|
|
Exemple de résultat :
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"titre": "master machine info",
|
|
|
|
"gestion_semestrielle": false,
|
|
|
|
"scodoc7_id": null,
|
|
|
|
"date_debut": "01/09/2021",
|
|
|
|
"bul_bgcolor": null,
|
|
|
|
"date_fin": "15/12/2022",
|
|
|
|
"resp_can_edit": false,
|
|
|
|
"dept_id": 1,
|
|
|
|
"etat": true,
|
|
|
|
"resp_can_change_ens": false,
|
|
|
|
"id": 1,
|
|
|
|
"modalite": "FI",
|
|
|
|
"ens_can_edit_eval": false,
|
|
|
|
"formation_id": 1,
|
|
|
|
"gestion_compensation": false,
|
|
|
|
"elt_sem_apo": null,
|
|
|
|
"semestre_id": 1,
|
|
|
|
"bul_hide_xml": false,
|
|
|
|
"elt_annee_apo": null,
|
|
|
|
"block_moyennes": false,
|
|
|
|
"formsemestre_id": 1,
|
|
|
|
"titre_num": "master machine info semestre 1",
|
|
|
|
"date_debut_iso": "2021-09-01",
|
|
|
|
"date_fin_iso": "2022-12-15",
|
|
|
|
"responsables": [
|
|
|
|
3,
|
|
|
|
2
|
|
|
|
]
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
"""
|
|
|
|
# Récupération des départements comportant l'acronym mit en paramètre
|
2022-04-26 15:23:10 +02:00
|
|
|
dept = models.Departement.query.filter_by(acronym=dept).first_or_404()
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
# Récupération des semestres suivant id_dept
|
2022-04-26 15:23:10 +02:00
|
|
|
semestres = models.FormSemestre.query.filter_by(dept_id=dept.id, etat=True)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
# Mise en forme des données
|
|
|
|
data = [d.to_dict() for d in semestres]
|
|
|
|
|
|
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
|
2022-04-13 12:39:10 +02:00
|
|
|
@bp.route(
|
|
|
|
"/departements/<string:dept>/formations/<int:formation_id>/referentiel_competences",
|
|
|
|
methods=["GET"],
|
|
|
|
)
|
2022-04-14 14:56:36 +02:00
|
|
|
@token_permission_required(Permission.APIView)
|
2022-03-02 16:45:47 +01:00
|
|
|
def referenciel_competences(dept: str, formation_id: int):
|
|
|
|
"""
|
|
|
|
Retourne le référentiel de compétences
|
|
|
|
|
|
|
|
dept : l'acronym d'un département
|
|
|
|
formation_id : l'id d'une formation
|
|
|
|
"""
|
2022-04-26 15:23:10 +02:00
|
|
|
dept = models.Departement.query.filter_by(acronym=dept).first_or_404()
|
2022-03-10 17:43:12 +01:00
|
|
|
|
2022-04-26 15:23:10 +02:00
|
|
|
formation = models.Formation.query.filter_by(
|
|
|
|
id=formation_id, dept_id=dept.id
|
|
|
|
).first_or_404()
|
2022-03-10 17:43:12 +01:00
|
|
|
|
2022-04-26 15:23:10 +02:00
|
|
|
ref_comp = formation.referentiel_competence_id
|
2022-03-02 16:45:47 +01:00
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
if ref_comp is None:
|
2022-04-13 12:39:10 +02:00
|
|
|
return error_response(
|
|
|
|
204, message="Pas de référenciel de compétences pour cette formation"
|
|
|
|
)
|
2022-03-10 17:43:12 +01:00
|
|
|
else:
|
|
|
|
return jsonify(ref_comp)
|
|
|
|
|
2022-03-02 16:45:47 +01:00
|
|
|
|
2022-04-13 12:39:10 +02:00
|
|
|
@bp.route(
|
|
|
|
"/departements/<string:dept>/formsemestre/<string:formsemestre_id>/programme",
|
|
|
|
methods=["GET"],
|
|
|
|
)
|
2022-04-14 14:56:36 +02:00
|
|
|
@token_permission_required(Permission.APIView)
|
2022-03-02 16:45:47 +01:00
|
|
|
def semestre_index(dept: str, formsemestre_id: int):
|
|
|
|
"""
|
|
|
|
Retourne la liste des Ues, ressources et SAE d'un semestre
|
2022-04-27 14:11:06 +02:00
|
|
|
|
|
|
|
dept : l'acronym d'un département
|
|
|
|
formsemestre_id : l'id d'un formesemestre
|
|
|
|
|
|
|
|
Exemple de résultat :
|
|
|
|
{
|
|
|
|
"ues": [
|
|
|
|
{
|
|
|
|
"type": 0,
|
|
|
|
"formation_id": 1,
|
|
|
|
"ue_code": "UCOD11",
|
|
|
|
"id": 1,
|
|
|
|
"ects": 12.0,
|
|
|
|
"acronyme": "RT1.1",
|
|
|
|
"is_external": false,
|
|
|
|
"numero": 1,
|
|
|
|
"code_apogee": "",
|
|
|
|
"titre": "Administrer les r\u00e9seaux et l\u2019Internet",
|
|
|
|
"coefficient": 0.0,
|
|
|
|
"semestre_idx": 1,
|
|
|
|
"color": "#B80004",
|
|
|
|
"ue_id": 1
|
|
|
|
},
|
|
|
|
...
|
|
|
|
],
|
|
|
|
"ressources": [
|
|
|
|
{
|
|
|
|
"titre": "Fondamentaux de la programmation",
|
|
|
|
"coefficient": 1.0,
|
|
|
|
"module_type": 2,
|
|
|
|
"id": 17,
|
|
|
|
"ects": null,
|
|
|
|
"abbrev": null,
|
|
|
|
"ue_id": 3,
|
|
|
|
"code": "R107",
|
|
|
|
"formation_id": 1,
|
|
|
|
"heures_cours": 0.0,
|
|
|
|
"matiere_id": 3,
|
|
|
|
"heures_td": 0.0,
|
|
|
|
"semestre_id": 1,
|
|
|
|
"heures_tp": 0.0,
|
|
|
|
"numero": 70,
|
|
|
|
"code_apogee": "",
|
|
|
|
"module_id": 17
|
|
|
|
},
|
|
|
|
...
|
|
|
|
],
|
|
|
|
"saes": [
|
|
|
|
{
|
|
|
|
"titre": "Se pr\u00e9senter sur Internet",
|
|
|
|
"coefficient": 1.0,
|
|
|
|
"module_type": 3,
|
|
|
|
"id": 14,
|
|
|
|
"ects": null,
|
|
|
|
"abbrev": null,
|
|
|
|
"ue_id": 3,
|
|
|
|
"code": "SAE14",
|
|
|
|
"formation_id": 1,
|
|
|
|
"heures_cours": 0.0,
|
|
|
|
"matiere_id": 3,
|
|
|
|
"heures_td": 0.0,
|
|
|
|
"semestre_id": 1,
|
|
|
|
"heures_tp": 0.0,
|
|
|
|
"numero": 40,
|
|
|
|
"code_apogee": "",
|
|
|
|
"module_id": 14
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2022-03-02 16:45:47 +01:00
|
|
|
"""
|
|
|
|
|
2022-04-21 15:57:02 +02:00
|
|
|
app.set_sco_dept(dept)
|
|
|
|
|
2022-04-26 17:12:30 +02:00
|
|
|
formsemestre = models.FormSemestre.query.filter_by(
|
|
|
|
id=formsemestre_id
|
|
|
|
).first_or_404()
|
2022-04-21 15:57:02 +02:00
|
|
|
|
|
|
|
ues = formsemestre.query_ues()
|
|
|
|
|
|
|
|
ues_dict = []
|
2022-04-22 16:22:10 +02:00
|
|
|
ressources = []
|
|
|
|
saes = []
|
|
|
|
|
2022-04-21 15:57:02 +02:00
|
|
|
for ue in ues:
|
|
|
|
ues_dict.append(ue.to_dict())
|
|
|
|
ressources = ue.get_ressources()
|
|
|
|
saes = ue.get_saes()
|
|
|
|
|
|
|
|
data_ressources = []
|
|
|
|
for ressource in ressources:
|
|
|
|
data_ressources.append(ressource.to_dict())
|
|
|
|
|
|
|
|
data_saes = []
|
|
|
|
for sae in saes:
|
|
|
|
data_saes.append(sae.to_dict())
|
|
|
|
|
|
|
|
data = {
|
|
|
|
"ues": ues_dict,
|
|
|
|
"ressources": data_ressources,
|
|
|
|
"saes": data_saes,
|
|
|
|
}
|
|
|
|
|
|
|
|
return data
|