forked from ScoDoc/ScoDoc
API: revision pour multi-départements
This commit is contained in:
parent
1209cf4ef3
commit
f9ec454da5
@ -5,73 +5,62 @@ from flask import jsonify
|
|||||||
from app.api import bp
|
from app.api import bp
|
||||||
from app.api.errors import error_response
|
from app.api.errors import error_response
|
||||||
from app.api.auth import token_auth, token_permission_required
|
from app.api.auth import token_auth, token_permission_required
|
||||||
from app.api.tools import get_etud_from_etudid_or_nip_or_ine
|
from app.models import Identite
|
||||||
from app.scodoc import notesdb as ndb
|
|
||||||
|
|
||||||
|
from app.scodoc import notesdb as ndb
|
||||||
from app.scodoc import sco_abs
|
from app.scodoc import sco_abs
|
||||||
from app.scodoc.sco_groups import get_group_members
|
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/absences/etudid/<int:etudid>", methods=["GET"])
|
@bp.route("/absences/etudid/<int:etudid>", methods=["GET"])
|
||||||
@bp.route("/absences/nip/<string:nip>", methods=["GET"])
|
|
||||||
@bp.route("/absences/ine/<string:ine>", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
@token_auth.login_required
|
||||||
@token_permission_required(Permission.APIView)
|
@token_permission_required(Permission.APIView)
|
||||||
def absences(etudid: int = None, nip: int = None, ine: int = None):
|
def absences(etudid: int = None):
|
||||||
"""
|
"""
|
||||||
Retourne la liste des absences d'un étudiant donné
|
Retourne la liste des absences d'un étudiant donné
|
||||||
|
|
||||||
etudid : l'etudid d'un étudiant
|
etudid : l'etudid d'un étudiant
|
||||||
nip: le code nip d'un étudiant
|
|
||||||
ine : le code ine d'un étudiant
|
|
||||||
|
|
||||||
Exemple de résultat:
|
Exemple de résultat:
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"jour": "2022-04-15",
|
"jour": "2022-04-15",
|
||||||
"matin": true,
|
"matin": true,
|
||||||
"estabs": true,
|
"estabs": true,
|
||||||
"estjust": true,
|
"estjust": true,
|
||||||
"description": "",
|
"description": "",
|
||||||
"begin": "2022-04-15 08:00:00",
|
"begin": "2022-04-15 08:00:00",
|
||||||
"end": "2022-04-15 11:59:59"
|
"end": "2022-04-15 11:59:59"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"jour": "2022-04-15",
|
"jour": "2022-04-15",
|
||||||
"matin": false,
|
"matin": false,
|
||||||
"estabs": true,
|
"estabs": true,
|
||||||
"estjust": false,
|
"estjust": false,
|
||||||
"description": "",
|
"description": "",
|
||||||
"begin": "2022-04-15 12:00:00",
|
"begin": "2022-04-15 12:00:00",
|
||||||
"end": "2022-04-15 17:59:59"
|
"end": "2022-04-15 17:59:59"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
if etudid is None:
|
etud = Identite.query.get(etudid)
|
||||||
# Récupération de l'étudiant
|
if etud is None:
|
||||||
etud = get_etud_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
return error_response(
|
||||||
if etud is None:
|
404,
|
||||||
return error_response(
|
message="id de l'étudiant (etudid, nip, ine) inconnu",
|
||||||
404,
|
)
|
||||||
message="id de l'étudiant (etudid, nip, ine) inconnu",
|
# Absences de l'étudiant
|
||||||
)
|
|
||||||
etudid = etud.etudid
|
|
||||||
|
|
||||||
# Récupération des absences de l'étudiant
|
|
||||||
ndb.open_db_connection()
|
ndb.open_db_connection()
|
||||||
absences = sco_abs.list_abs_date(etudid)
|
absences = sco_abs.list_abs_date(etud.id)
|
||||||
for absence in absences:
|
for absence in absences:
|
||||||
absence["jour"] = absence["jour"].isoformat()
|
absence["jour"] = absence["jour"].isoformat()
|
||||||
return jsonify(absences)
|
return jsonify(absences)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/absences/etudid/<int:etudid>/just", methods=["GET"])
|
@bp.route("/absences/etudid/<int:etudid>/just", methods=["GET"])
|
||||||
@bp.route("/absences/nip/<int:nip>/just", methods=["GET"])
|
|
||||||
@bp.route("/absences/ine/<int:ine>/just", methods=["GET"])
|
|
||||||
@token_auth.login_required
|
@token_auth.login_required
|
||||||
@token_permission_required(Permission.APIView)
|
@token_permission_required(Permission.APIView)
|
||||||
def absences_just(etudid: int = None, nip: int = None, ine: int = None):
|
def absences_just(etudid: int = None):
|
||||||
"""
|
"""
|
||||||
Retourne la liste des absences justifiées d'un étudiant donné
|
Retourne la liste des absences justifiées d'un étudiant donné
|
||||||
|
|
||||||
@ -80,39 +69,37 @@ def absences_just(etudid: int = None, nip: int = None, ine: int = None):
|
|||||||
ine : le code ine d'un étudiant
|
ine : le code ine d'un étudiant
|
||||||
|
|
||||||
Exemple de résultat :
|
Exemple de résultat :
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"jour": "2022-04-15",
|
"jour": "2022-04-15",
|
||||||
"matin": true,
|
"matin": true,
|
||||||
"estabs": true,
|
"estabs": true,
|
||||||
"estjust": true,
|
"estjust": true,
|
||||||
"description": "",
|
"description": "",
|
||||||
"begin": "2022-04-15 08:00:00",
|
"begin": "2022-04-15 08:00:00",
|
||||||
"end": "2022-04-15 11:59:59"
|
"end": "2022-04-15 11:59:59"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"jour": "Fri, 15 Apr 2022 00:00:00 GMT",
|
"jour": "Fri, 15 Apr 2022 00:00:00 GMT",
|
||||||
"matin": false,
|
"matin": false,
|
||||||
"estabs": true,
|
"estabs": true,
|
||||||
"estjust": true,
|
"estjust": true,
|
||||||
"description": "",
|
"description": "",
|
||||||
"begin": "2022-04-15 12:00:00",
|
"begin": "2022-04-15 12:00:00",
|
||||||
"end": "2022-04-15 17:59:59"
|
"end": "2022-04-15 17:59:59"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
if etudid is None:
|
etud = Identite.query.get(etudid)
|
||||||
etud = get_etud_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
if etud is None:
|
||||||
if etud is None:
|
return error_response(
|
||||||
return error_response(
|
404,
|
||||||
404,
|
message="id de l'étudiant (etudid, nip, ine) inconnu",
|
||||||
message="id de l'étudiant (etudid, nip, ine) inconnu",
|
)
|
||||||
)
|
|
||||||
etudid = etud.etudid
|
|
||||||
|
|
||||||
# Récupération des absences justifiées de l'étudiant
|
# Absences justifiées de l'étudiant
|
||||||
abs_just = [
|
abs_just = [
|
||||||
absence for absence in sco_abs.list_abs_date(etudid) if absence["estjust"]
|
absence for absence in sco_abs.list_abs_date(etud.id) if absence["estjust"]
|
||||||
]
|
]
|
||||||
for absence in abs_just:
|
for absence in abs_just:
|
||||||
absence["jour"] = absence["jour"].isoformat()
|
absence["jour"] = absence["jour"].isoformat()
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
#################################################### Etudiants ########################################################
|
##############################################################################
|
||||||
|
# ScoDoc
|
||||||
|
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
|
||||||
|
# See LICENSE
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
"""
|
||||||
|
API : accès aux étudiants
|
||||||
|
"""
|
||||||
|
|
||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
|
|
||||||
import app
|
import app
|
||||||
from app import models
|
|
||||||
from app.api import bp
|
from app.api import bp
|
||||||
from app.api.errors import error_response
|
from app.api.errors import error_response
|
||||||
from app.api.auth import token_auth, token_permission_required
|
from app.api.auth import token_auth, token_permission_required
|
||||||
from app.api.tools import get_etud_from_etudid_or_nip_or_ine
|
from app.models import Departement, FormSemestreInscription, FormSemestre, Identite
|
||||||
from app.models import FormSemestreInscription, FormSemestre, Identite
|
|
||||||
from app.scodoc import sco_bulletins
|
from app.scodoc import sco_bulletins
|
||||||
from app.scodoc import sco_groups
|
from app.scodoc import sco_groups
|
||||||
from app.scodoc.sco_permissions import Permission
|
from app.scodoc.sco_permissions import Permission
|
||||||
@ -59,53 +65,102 @@ def etudiants_courant(long=False):
|
|||||||
@bp.route("/etudiant/ine/<string:ine>", methods=["GET"])
|
@bp.route("/etudiant/ine/<string:ine>", methods=["GET"])
|
||||||
@token_auth.login_required
|
@token_auth.login_required
|
||||||
@token_permission_required(Permission.APIView)
|
@token_permission_required(Permission.APIView)
|
||||||
def etudiant(etudid: int = None, nip: int = None, ine: int = None):
|
def etudiant(etudid: int = None, nip: str = None, ine: str = None):
|
||||||
"""
|
"""
|
||||||
Retourne les informations de l'étudiant correspondant à l'id passé en paramètres.
|
Retourne les informations de l'étudiant correspondant, ou 404 si non trouvé.
|
||||||
|
|
||||||
etudid : l'etudid d'un étudiant
|
etudid : l'etudid de l'étudiant
|
||||||
nip : le code nip d'un étudiant
|
nip : le code nip de l'étudiant
|
||||||
ine : le code ine d'un étudiant
|
ine : le code ine de l'étudiant
|
||||||
|
|
||||||
|
Les codes INE et NIP sont uniques au sein d'un département.
|
||||||
|
Si plusieurs objets ont le même code, on ramène le plus récemment inscrit.
|
||||||
|
|
||||||
Exemple de résultat :
|
Exemple de résultat :
|
||||||
{
|
{
|
||||||
"civilite": "X",
|
"civilite": "X",
|
||||||
"code_ine": "1",
|
"code_ine": "1",
|
||||||
"code_nip": "1",
|
"code_nip": "1",
|
||||||
"date_naissance": "",
|
"date_naissance": "",
|
||||||
"email": "SACHA.COSTA@example.com",
|
"email": "SACHA.COSTA@example.com",
|
||||||
"emailperso": "",
|
"emailperso": "",
|
||||||
"etudid": 1,
|
"etudid": 1,
|
||||||
"nom": "COSTA",
|
"nom": "COSTA",
|
||||||
"prenom": "SACHA",
|
"prenom": "SACHA",
|
||||||
"nomprenom": "Sacha COSTA",
|
"nomprenom": "Sacha COSTA",
|
||||||
"lieu_naissance": "",
|
"lieu_naissance": "",
|
||||||
"dept_naissance": "",
|
"dept_naissance": "",
|
||||||
"nationalite": "",
|
"nationalite": "",
|
||||||
"boursier": "",
|
"boursier": "",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"codepostaldomicile": "",
|
"codepostaldomicile": "",
|
||||||
"paysdomicile": "",
|
"paysdomicile": "",
|
||||||
"telephonemobile": "",
|
"telephonemobile": "",
|
||||||
"typeadresse": "domicile",
|
"typeadresse": "domicile",
|
||||||
"domicile": "",
|
"domicile": "",
|
||||||
"villedomicile": "",
|
"villedomicile": "",
|
||||||
"telephone": "",
|
"telephone": "",
|
||||||
"fax": "",
|
"fax": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
# Récupération de l'étudiant
|
if etudid is not None:
|
||||||
etud = get_etud_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
etud = Identite.query.get(etudid)
|
||||||
|
else:
|
||||||
|
if nip is not None:
|
||||||
|
query = Identite.query.filter_by(code_nip=nip)
|
||||||
|
elif ine is not None:
|
||||||
|
query = Identite.query.filter_by(code_ine=ine)
|
||||||
|
else:
|
||||||
|
return error_response(
|
||||||
|
404,
|
||||||
|
message="parametre manquant",
|
||||||
|
)
|
||||||
|
if query.count() > 1: # cas rare d'un étudiant présent dans plusieurs depts
|
||||||
|
etuds = []
|
||||||
|
for e in query:
|
||||||
|
admission = e.admission.first()
|
||||||
|
etuds.append((((admission.annee or 0) if admission else 0), e))
|
||||||
|
etuds.sort()
|
||||||
|
etud = etuds[-1][1]
|
||||||
|
else:
|
||||||
|
etud = query.first()
|
||||||
|
|
||||||
if etud is None:
|
if etud is None:
|
||||||
return error_response(
|
return error_response(
|
||||||
404,
|
404,
|
||||||
message="id de l'étudiant (etudid, nip, ine) inconnu",
|
message="étudiant inconnu",
|
||||||
)
|
)
|
||||||
# Mise en forme des données
|
|
||||||
data = etud.to_dict_bul(include_urls=False)
|
|
||||||
|
|
||||||
return jsonify(data)
|
return jsonify(etud.to_dict_bul(include_urls=False))
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/etudiants/etudid/<int:etudid>", methods=["GET"])
|
||||||
|
@bp.route("/etudiants/nip/<string:nip>", methods=["GET"])
|
||||||
|
@bp.route("/etudiants/ine/<string:ine>", methods=["GET"])
|
||||||
|
@token_auth.login_required
|
||||||
|
@token_permission_required(Permission.APIView)
|
||||||
|
def etudiants(etudid: int = None, nip: str = None, ine: str = None):
|
||||||
|
"""
|
||||||
|
Info sur le ou les étudiants correspondant. Comme /etudiant mais renvoie
|
||||||
|
toujours une liste.
|
||||||
|
Si non trouvé, liste vide, pas d'erreur.
|
||||||
|
Dans 99% des cas, la liste contient un seul étudiant, mais si l'étudiant a
|
||||||
|
été inscrit dans plusieurs départements, on a plusieurs objets (1 par dept.).
|
||||||
|
"""
|
||||||
|
if etudid is not None:
|
||||||
|
query = Identite.query.filter_by(id=etudid)
|
||||||
|
elif nip is not None:
|
||||||
|
query = Identite.query.filter_by(code_nip=nip)
|
||||||
|
elif ine is not None:
|
||||||
|
query = Identite.query.filter_by(code_ine=ine)
|
||||||
|
else:
|
||||||
|
return error_response(
|
||||||
|
404,
|
||||||
|
message="parametre manquant",
|
||||||
|
)
|
||||||
|
|
||||||
|
return jsonify([etud.to_dict_bul(include_urls=False) for etud in query])
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/etudiant/etudid/<int:etudid>/formsemestres")
|
@bp.route("/etudiant/etudid/<int:etudid>/formsemestres")
|
||||||
@ -115,56 +170,65 @@ def etudiant(etudid: int = None, nip: int = None, ine: int = None):
|
|||||||
@token_permission_required(Permission.APIView)
|
@token_permission_required(Permission.APIView)
|
||||||
def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None):
|
def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None):
|
||||||
"""
|
"""
|
||||||
Retourne la liste des semestres qu'un étudiant a suivis, triés par ordre chronologique.
|
Liste des semestres qu'un étudiant a suivi, triés par ordre chronologique.
|
||||||
|
Accès par etudid, nip ou ine
|
||||||
etudid : l'etudid d'un étudiant
|
|
||||||
nip : le code nip d'un étudiant
|
|
||||||
ine : le code ine d'un étudiant
|
|
||||||
|
|
||||||
Exemple de résultat :
|
Exemple de résultat :
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"date_fin": "31/08/2022",
|
"date_fin": "31/08/2022",
|
||||||
"resp_can_edit": false,
|
"resp_can_edit": false,
|
||||||
"dept_id": 1,
|
"dept_id": 1,
|
||||||
"etat": true,
|
"etat": true,
|
||||||
"resp_can_change_ens": true,
|
"resp_can_change_ens": true,
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"modalite": "FI",
|
"modalite": "FI",
|
||||||
"ens_can_edit_eval": false,
|
"ens_can_edit_eval": false,
|
||||||
"formation_id": 1,
|
"formation_id": 1,
|
||||||
"gestion_compensation": false,
|
"gestion_compensation": false,
|
||||||
"elt_sem_apo": null,
|
"elt_sem_apo": null,
|
||||||
"semestre_id": 1,
|
"semestre_id": 1,
|
||||||
"bul_hide_xml": false,
|
"bul_hide_xml": false,
|
||||||
"elt_annee_apo": null,
|
"elt_annee_apo": null,
|
||||||
"titre": "Semestre test",
|
"titre": "Semestre test",
|
||||||
"block_moyennes": false,
|
"block_moyennes": false,
|
||||||
"scodoc7_id": null,
|
"scodoc7_id": null,
|
||||||
"date_debut": "01/09/2021",
|
"date_debut": "01/09/2021",
|
||||||
"gestion_semestrielle": false,
|
"gestion_semestrielle": false,
|
||||||
"bul_bgcolor": "white",
|
"bul_bgcolor": "white",
|
||||||
"formsemestre_id": 1,
|
"formsemestre_id": 1,
|
||||||
"titre_num": "Semestre test semestre 1",
|
"titre_num": "Semestre test semestre 1",
|
||||||
"date_debut_iso": "2021-09-01",
|
"date_debut_iso": "2021-09-01",
|
||||||
"date_fin_iso": "2022-08-31",
|
"date_fin_iso": "2022-08-31",
|
||||||
"responsables": []
|
"responsables": []
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
# Récupération de l'étudiant
|
if etudid is not None:
|
||||||
etud = get_etud_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
query = FormSemestre.query.filter(
|
||||||
if etud is None:
|
FormSemestreInscription.etudid == etudid,
|
||||||
|
FormSemestreInscription.formsemestre_id == FormSemestre.id,
|
||||||
|
)
|
||||||
|
elif nip is not None:
|
||||||
|
query = FormSemestre.query.filter(
|
||||||
|
Identite.code_nip == nip,
|
||||||
|
FormSemestreInscription.etudid == Identite.id,
|
||||||
|
FormSemestreInscription.formsemestre_id == FormSemestre.id,
|
||||||
|
)
|
||||||
|
elif ine is not None:
|
||||||
|
query = FormSemestre.query.filter(
|
||||||
|
Identite.code_ine == ine,
|
||||||
|
FormSemestreInscription.etudid == Identite.id,
|
||||||
|
FormSemestreInscription.formsemestre_id == FormSemestre.id,
|
||||||
|
)
|
||||||
|
else:
|
||||||
return error_response(
|
return error_response(
|
||||||
404,
|
404,
|
||||||
message="id de l'étudiant (etudid, nip, ine) inconnu",
|
message="parametre manquant",
|
||||||
)
|
)
|
||||||
|
|
||||||
formsemestres = models.FormSemestre.query.filter(
|
formsemestres = query.order_by(FormSemestre.date_debut)
|
||||||
models.FormSemestreInscription.etudid == etud.id,
|
|
||||||
models.FormSemestreInscription.formsemestre_id == models.FormSemestre.id,
|
|
||||||
).order_by(models.FormSemestre.date_debut)
|
|
||||||
|
|
||||||
return jsonify([formsemestre.to_dict() for formsemestre in formsemestres])
|
return jsonify([formsemestre.to_dict() for formsemestre in formsemestres])
|
||||||
|
|
||||||
@ -204,8 +268,8 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
|
|||||||
def etudiant_bulletin_semestre(
|
def etudiant_bulletin_semestre(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
etudid: int = None,
|
etudid: int = None,
|
||||||
nip: int = None,
|
nip: str = None,
|
||||||
ine: int = None,
|
ine: str = None,
|
||||||
version="long",
|
version="long",
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
@ -216,12 +280,12 @@ def etudiant_bulletin_semestre(
|
|||||||
nip : le code nip d'un étudiant
|
nip : le code nip d'un étudiant
|
||||||
ine : le code ine d'un étudiant
|
ine : le code ine d'un étudiant
|
||||||
Exemple de résultat :
|
Exemple de résultat :
|
||||||
{
|
{
|
||||||
"version": "0",
|
"version": "0",
|
||||||
"type": "BUT",
|
"type": "BUT",
|
||||||
"date": "2022-04-27T07:18:16.450634Z",
|
"date": "2022-04-27T07:18:16.450634Z",
|
||||||
"publie": true,
|
"publie": true,
|
||||||
"etudiant": {
|
"etudiant": {
|
||||||
"civilite": "X",
|
"civilite": "X",
|
||||||
"code_ine": "1",
|
"code_ine": "1",
|
||||||
"code_nip": "1",
|
"code_nip": "1",
|
||||||
@ -247,17 +311,17 @@ def etudiant_bulletin_semestre(
|
|||||||
"villedomicile": "",
|
"villedomicile": "",
|
||||||
"telephone": "",
|
"telephone": "",
|
||||||
"fax": "",
|
"fax": "",
|
||||||
"description": ""
|
"description": "",
|
||||||
},
|
},
|
||||||
"formation": {
|
"formation": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"acronyme": "BUT R&T",
|
"acronyme": "BUT R&T",
|
||||||
"titre_officiel": "Bachelor technologique r\u00e9seaux et t\u00e9l\u00e9communications",
|
"titre_officiel": "Bachelor technologique r\u00e9seaux et t\u00e9l\u00e9communications",
|
||||||
"titre": "BUT R&T"
|
"titre": "BUT R&T",
|
||||||
},
|
},
|
||||||
"formsemestre_id": 1,
|
"formsemestre_id": 1,
|
||||||
"etat_inscription": "I",
|
"etat_inscription": "I",
|
||||||
"options": {
|
"options": {
|
||||||
"show_abs": true,
|
"show_abs": true,
|
||||||
"show_abs_modules": false,
|
"show_abs_modules": false,
|
||||||
"show_ects": true,
|
"show_ects": true,
|
||||||
@ -276,128 +340,113 @@ def etudiant_bulletin_semestre(
|
|||||||
"show_temporary": true,
|
"show_temporary": true,
|
||||||
"temporary_txt": "Provisoire",
|
"temporary_txt": "Provisoire",
|
||||||
"show_uevalid": true,
|
"show_uevalid": true,
|
||||||
"show_date_inscr": true
|
"show_date_inscr": true,
|
||||||
},
|
},
|
||||||
"ressources": {
|
"ressources": {
|
||||||
"R101": {
|
"R101": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"titre": "Initiation aux r\u00e9seaux informatiques",
|
"titre": "Initiation aux r\u00e9seaux informatiques",
|
||||||
"code_apogee": null,
|
"code_apogee": null,
|
||||||
"url": "/ScoDoc/TAPI/Scolarite/Notes/moduleimpl_status?moduleimpl_id=1",
|
"url": "/ScoDoc/TAPI/Scolarite/Notes/moduleimpl_status?moduleimpl_id=1",
|
||||||
"moyenne": {},
|
"moyenne": {},
|
||||||
"evaluations": [
|
"evaluations": [
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"description": "eval1",
|
"description": "eval1",
|
||||||
"date": "2022-04-20",
|
"date": "2022-04-20",
|
||||||
"heure_debut": "08:00",
|
"heure_debut": "08:00",
|
||||||
"heure_fin": "09:00",
|
"heure_fin": "09:00",
|
||||||
"coef": "01.00",
|
"coef": "01.00",
|
||||||
"poids": {
|
"poids": {
|
||||||
"RT1.1": 1.0,
|
"RT1.1": 1.0,
|
||||||
},
|
},
|
||||||
"note": {
|
"note": {
|
||||||
"value": "12.00",
|
"value": "12.00",
|
||||||
"min": "00.00",
|
"min": "00.00",
|
||||||
"max": "18.00",
|
"max": "18.00",
|
||||||
"moy": "10.88"
|
"moy": "10.88",
|
||||||
},
|
},
|
||||||
"url": "/ScoDoc/TAPI/Scolarite/Notes/evaluation_listenotes?evaluation_id=1"
|
"url": "/ScoDoc/TAPI/Scolarite/Notes/evaluation_listenotes?evaluation_id=1",
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"saes": {
|
"saes": {
|
||||||
"SAE11": {
|
"SAE11": {
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"titre": "Se sensibiliser \u00e0 l'hygi\u00e8ne informatique et \u00e0 la cybers\u00e9curit\u00e9",
|
"titre": "Se sensibiliser \u00e0 l'hygi\u00e8ne informatique et \u00e0 la cybers\u00e9curit\u00e9",
|
||||||
"code_apogee": null,
|
"code_apogee": null,
|
||||||
"url": "/ScoDoc/TAPI/Scolarite/Notes/moduleimpl_status?moduleimpl_id=2",
|
"url": "/ScoDoc/TAPI/Scolarite/Notes/moduleimpl_status?moduleimpl_id=2",
|
||||||
"moyenne": {},
|
"moyenne": {},
|
||||||
"evaluations": []
|
"evaluations": [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ues": {
|
"ues": {
|
||||||
"RT1.1": {
|
"RT1.1": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"titre": "Administrer les r\u00e9seaux et l\u2019Internet",
|
"titre": "Administrer les r\u00e9seaux et l\u2019Internet",
|
||||||
"numero": 1,
|
"numero": 1,
|
||||||
"type": 0,
|
"type": 0,
|
||||||
"color": "#B80004",
|
"color": "#B80004",
|
||||||
"competence": null,
|
"competence": null,
|
||||||
"moyenne": {
|
"moyenne": {
|
||||||
"value": "08.50",
|
"value": "08.50",
|
||||||
"min": "06.00",
|
"min": "06.00",
|
||||||
"max": "16.50",
|
"max": "16.50",
|
||||||
"moy": "11.31",
|
"moy": "11.31",
|
||||||
"rang": "12",
|
"rang": "12",
|
||||||
"total": 16
|
"total": 16,
|
||||||
},
|
|
||||||
"bonus": "00.00",
|
|
||||||
"malus": "00.00",
|
|
||||||
"capitalise": null,
|
|
||||||
"ressources": {
|
|
||||||
"R101": {
|
|
||||||
"id": 1,
|
|
||||||
"coef": 12.0,
|
|
||||||
"moyenne": "12.00"
|
|
||||||
},
|
},
|
||||||
},
|
"bonus": "00.00",
|
||||||
"saes": {
|
"malus": "00.00",
|
||||||
"SAE11": {
|
"capitalise": null,
|
||||||
"id": 2,
|
"ressources": {
|
||||||
"coef": 16.0,
|
"R101": {"id": 1, "coef": 12.0, "moyenne": "12.00"},
|
||||||
"moyenne": "~"
|
|
||||||
},
|
},
|
||||||
},
|
"saes": {
|
||||||
"ECTS": {
|
"SAE11": {"id": 2, "coef": 16.0, "moyenne": "~"},
|
||||||
"acquis": 0.0,
|
},
|
||||||
"total": 12.0
|
"ECTS": {"acquis": 0.0, "total": 12.0},
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"semestre": {
|
"semestre": {
|
||||||
"etapes": [],
|
"etapes": [],
|
||||||
"date_debut": "2021-09-01",
|
"date_debut": "2021-09-01",
|
||||||
"date_fin": "2022-08-31",
|
"date_fin": "2022-08-31",
|
||||||
"annee_universitaire": "2021 - 2022",
|
"annee_universitaire": "2021 - 2022",
|
||||||
"numero": 1,
|
"numero": 1,
|
||||||
"inscription": "",
|
"inscription": "",
|
||||||
"groupes": [],
|
"groupes": [],
|
||||||
"absences": {
|
"absences": {"injustifie": 1, "total": 2},
|
||||||
"injustifie": 1,
|
"ECTS": {"acquis": 0, "total": 30.0},
|
||||||
"total": 2
|
"notes": {"value": "10.60", "min": "02.40", "moy": "11.05", "max": "17.40"},
|
||||||
|
"rang": {"value": "10", "total": 16},
|
||||||
},
|
},
|
||||||
"ECTS": {
|
},
|
||||||
"acquis": 0,
|
}
|
||||||
"total": 30.0
|
|
||||||
},
|
|
||||||
"notes": {
|
|
||||||
"value": "10.60",
|
|
||||||
"min": "02.40",
|
|
||||||
"moy": "11.05",
|
|
||||||
"max": "17.40"
|
|
||||||
},
|
|
||||||
"rang": {
|
|
||||||
"value": "10",
|
|
||||||
"total": 16
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
formsemestre = models.FormSemestre.query.filter_by(
|
formsemestre = FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
||||||
id=formsemestre_id
|
dept = Departement.query.filter_by(id=formsemestre.dept_id).first_or_404()
|
||||||
).first_or_404()
|
|
||||||
|
|
||||||
dept = models.Departement.query.filter_by(id=formsemestre.dept_id).first_or_404()
|
if etudid is not None:
|
||||||
|
query = Identite.query.filter_by(id=etudid)
|
||||||
|
elif nip is not None:
|
||||||
|
query = Identite.query.filter_by(code_nip=nip, dept_id=dept.id)
|
||||||
|
elif ine is not None:
|
||||||
|
query = Identite.query.filter_by(code_ine=ine, dept_id=dept.id)
|
||||||
|
else:
|
||||||
|
return error_response(
|
||||||
|
404,
|
||||||
|
message="parametre manquant",
|
||||||
|
)
|
||||||
|
|
||||||
app.set_sco_dept(dept.acronym)
|
etud = query.first()
|
||||||
|
|
||||||
etud = get_etud_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
|
||||||
if etud is None:
|
if etud is None:
|
||||||
return error_response(
|
return error_response(
|
||||||
404,
|
404,
|
||||||
message="id de l'étudiant (etudid, nip, ine) inconnu",
|
message="id de l'étudiant (etudid, nip, ine) inconnu",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
app.set_sco_dept(dept.acronym)
|
||||||
return sco_bulletins.get_formsemestre_bulletin_etud_json(
|
return sco_bulletins.get_formsemestre_bulletin_etud_json(
|
||||||
formsemestre, etud, version
|
formsemestre, etud, version
|
||||||
)
|
)
|
||||||
@ -429,44 +478,57 @@ def etudiant_groups(
|
|||||||
ine : le code ine d'un étudiant
|
ine : le code ine d'un étudiant
|
||||||
|
|
||||||
Exemple de résultat :
|
Exemple de résultat :
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"partition_id": 1,
|
"partition_id": 1,
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"formsemestre_id": 1,
|
"formsemestre_id": 1,
|
||||||
"partition_name": null,
|
"partition_name": null,
|
||||||
"numero": 0,
|
"numero": 0,
|
||||||
"bul_show_rank": false,
|
"bul_show_rank": false,
|
||||||
"show_in_lists": true,
|
"show_in_lists": true,
|
||||||
"group_id": 1,
|
"group_id": 1,
|
||||||
"group_name": null
|
"group_name": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"partition_id": 2,
|
"partition_id": 2,
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"formsemestre_id": 1,
|
"formsemestre_id": 1,
|
||||||
"partition_name": "TD",
|
"partition_name": "TD",
|
||||||
"numero": 1,
|
"numero": 1,
|
||||||
"bul_show_rank": false,
|
"bul_show_rank": false,
|
||||||
"show_in_lists": true,
|
"show_in_lists": true,
|
||||||
"group_id": 2,
|
"group_id": 2,
|
||||||
"group_name": "A"
|
"group_name": "A"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
if etudid is None:
|
|
||||||
etud = get_etud_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
|
||||||
if etud is None:
|
|
||||||
return error_response(
|
|
||||||
404,
|
|
||||||
message="id de l'étudiant (etudid, nip, ine) inconnu",
|
|
||||||
)
|
|
||||||
etudid = etud.etudid
|
|
||||||
|
|
||||||
# Récupération du formsemestre
|
formsemestre = FormSemestre.query.filter_by(id=formsemestre_id).first()
|
||||||
sem = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
if formsemestre is None:
|
||||||
dept = models.Departement.query.get(sem.dept_id)
|
return error_response(
|
||||||
|
404,
|
||||||
|
message="formsemestre inconnu",
|
||||||
|
)
|
||||||
|
dept = Departement.query.get(formsemestre.dept_id)
|
||||||
|
if etudid is not None:
|
||||||
|
query = Identite.query.filter_by(id=etudid)
|
||||||
|
elif nip is not None:
|
||||||
|
query = Identite.query.filter_by(code_nip=nip, dept_id=dept.id)
|
||||||
|
elif ine is not None:
|
||||||
|
query = Identite.query.filter_by(code_ine=ine, dept_id=dept.id)
|
||||||
|
else:
|
||||||
|
return error_response(
|
||||||
|
404,
|
||||||
|
message="parametre manquant",
|
||||||
|
)
|
||||||
|
etud = query.first()
|
||||||
|
if etud is None:
|
||||||
|
return error_response(
|
||||||
|
404,
|
||||||
|
message="etudiant inconnu",
|
||||||
|
)
|
||||||
app.set_sco_dept(dept.acronym)
|
app.set_sco_dept(dept.acronym)
|
||||||
data = sco_groups.get_etud_groups(etudid, sem.id)
|
data = sco_groups.get_etud_groups(etud.id, formsemestre.id)
|
||||||
|
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
@ -178,6 +178,7 @@ class Identite(db.Model):
|
|||||||
"date_naissance": self.date_naissance.strftime("%d/%m/%Y")
|
"date_naissance": self.date_naissance.strftime("%d/%m/%Y")
|
||||||
if self.date_naissance
|
if self.date_naissance
|
||||||
else "",
|
else "",
|
||||||
|
"dept_id": self.dept_id,
|
||||||
"email": self.get_first_email() or "",
|
"email": self.get_first_email() or "",
|
||||||
"emailperso": self.get_first_email("emailperso"),
|
"emailperso": self.get_first_email("emailperso"),
|
||||||
"etudid": self.id,
|
"etudid": self.id,
|
||||||
|
@ -26,13 +26,17 @@ import urllib3
|
|||||||
from pprint import pprint as pp
|
from pprint import pprint as pp
|
||||||
|
|
||||||
# --- Lecture configuration (variables d'env ou .env)
|
# --- Lecture configuration (variables d'env ou .env)
|
||||||
BASEDIR = os.path.abspath(os.path.dirname(__file__))
|
try:
|
||||||
|
BASEDIR = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
except NameError:
|
||||||
|
BASEDIR = "."
|
||||||
|
|
||||||
load_dotenv(os.path.join(BASEDIR, ".env"))
|
load_dotenv(os.path.join(BASEDIR, ".env"))
|
||||||
CHK_CERT = bool(int(os.environ.get("CHECK_CERTIFICATE", False)))
|
CHK_CERT = bool(int(os.environ.get("CHECK_CERTIFICATE", False)))
|
||||||
SCODOC_URL = os.environ["SCODOC_URL"]
|
SCODOC_URL = os.environ["SCODOC_URL"]
|
||||||
API_URL = SCODOC_URL + "/ScoDoc/api"
|
API_URL = SCODOC_URL + "/ScoDoc/api"
|
||||||
SCODOC_USER = os.environ["SCODOC_USER"]
|
SCODOC_USER = os.environ["SCODOC_USER"]
|
||||||
SCODOC_PASSWORD = os.environ["SCODOC_PASSWD"]
|
SCODOC_PASSWORD = os.environ["SCODOC_PASSWORD"]
|
||||||
print(f"SCODOC_URL={SCODOC_URL}")
|
print(f"SCODOC_URL={SCODOC_URL}")
|
||||||
print(f"API URL={API_URL}")
|
print(f"API URL={API_URL}")
|
||||||
|
|
||||||
@ -90,6 +94,23 @@ formsemestre_id = 1028 # A adapter
|
|||||||
etudid = 14721
|
etudid = 14721
|
||||||
bul_dut = GET(f"/etudiant/etudid/{etudid}/formsemestre/{formsemestre_id}/bulletin")
|
bul_dut = GET(f"/etudiant/etudid/{etudid}/formsemestre/{formsemestre_id}/bulletin")
|
||||||
|
|
||||||
|
|
||||||
|
# Infos sur un étudiant
|
||||||
|
etudid = 3561
|
||||||
|
code_nip = "11303314"
|
||||||
|
etud = GET(f"/etudiant/etudid/{etudid}")
|
||||||
|
print(etud)
|
||||||
|
|
||||||
|
etud = GET(f"/etudiant/nip/{code_nip}")
|
||||||
|
print(etud)
|
||||||
|
|
||||||
|
sems = GET(f"/etudiant/etudid/{etudid}/formsemestres")
|
||||||
|
print("\n".join([s["titre_num"] for s in sems]))
|
||||||
|
|
||||||
|
sems = GET(f"/etudiant/nip/{code_nip}/formsemestres")
|
||||||
|
print("\n".join([s["titre_num"] for s in sems]))
|
||||||
|
|
||||||
|
|
||||||
# # --- Recupere la liste de tous les semestres:
|
# # --- Recupere la liste de tous les semestres:
|
||||||
# sems = GET(s, "Notes/formsemestre_list?format=json", "Aucun semestre !")
|
# sems = GET(s, "Notes/formsemestre_list?format=json", "Aucun semestre !")
|
||||||
|
|
||||||
|
@ -22,8 +22,7 @@ from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
|
|||||||
|
|
||||||
# Etudiant pour les tests
|
# Etudiant pour les tests
|
||||||
ETUDID = 1
|
ETUDID = 1
|
||||||
INE = "1"
|
|
||||||
NIP = "1"
|
|
||||||
|
|
||||||
# absences
|
# absences
|
||||||
def test_absences(api_headers):
|
def test_absences(api_headers):
|
||||||
@ -37,20 +36,6 @@ def test_absences(api_headers):
|
|||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
|
||||||
r = requests.get(
|
|
||||||
f"{API_URL}/absences/nip/{NIP}",
|
|
||||||
headers=api_headers,
|
|
||||||
verify=CHECK_CERTIFICATE,
|
|
||||||
)
|
|
||||||
assert r.status_code == 200
|
|
||||||
|
|
||||||
r = requests.get(
|
|
||||||
f"{API_URL}/absences/ine/{INE}",
|
|
||||||
headers=api_headers,
|
|
||||||
verify=CHECK_CERTIFICATE,
|
|
||||||
)
|
|
||||||
assert r.status_code == 200
|
|
||||||
|
|
||||||
|
|
||||||
# absences_justify
|
# absences_justify
|
||||||
def test_absences_justify(api_headers):
|
def test_absences_justify(api_headers):
|
||||||
@ -65,22 +50,6 @@ def test_absences_justify(api_headers):
|
|||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
# TODO vérifier résultat
|
# TODO vérifier résultat
|
||||||
|
|
||||||
r = requests.get(
|
|
||||||
API_URL + f"/absences/nip/{NIP}/just",
|
|
||||||
headers=api_headers,
|
|
||||||
verify=CHECK_CERTIFICATE,
|
|
||||||
)
|
|
||||||
assert r.status_code == 200
|
|
||||||
# TODO vérifier résultat
|
|
||||||
|
|
||||||
r = requests.get(
|
|
||||||
API_URL + f"/absences/ine/{INE}/just",
|
|
||||||
headers=api_headers,
|
|
||||||
verify=CHECK_CERTIFICATE,
|
|
||||||
)
|
|
||||||
assert r.status_code == 200
|
|
||||||
# TODO vérifier résultat
|
|
||||||
|
|
||||||
|
|
||||||
# XXX TODO
|
# XXX TODO
|
||||||
# def test_abs_groupe_etat(api_headers):
|
# def test_abs_groupe_etat(api_headers):
|
||||||
|
@ -93,7 +93,7 @@ def test_etudiant(api_headers):
|
|||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
etud = r.json()
|
etud = r.json()
|
||||||
assert len(etud) == 24
|
assert len(etud) == 25
|
||||||
fields_ok = verify_fields(etud, ETUD_FIELDS)
|
fields_ok = verify_fields(etud, ETUD_FIELDS)
|
||||||
assert fields_ok is True
|
assert fields_ok is True
|
||||||
|
|
||||||
|
@ -24,6 +24,11 @@ from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
|
|||||||
from tests.api.tools_test_api import MODIMPL_FIELDS, verify_fields
|
from tests.api.tools_test_api import MODIMPL_FIELDS, verify_fields
|
||||||
from tests.api.tools_test_api import FSEM_FIELDS, UE_FIELDS, MODULE_FIELDS
|
from tests.api.tools_test_api import FSEM_FIELDS, UE_FIELDS, MODULE_FIELDS
|
||||||
|
|
||||||
|
# Etudiant pour les tests
|
||||||
|
ETUDID = 1
|
||||||
|
NIP = "1"
|
||||||
|
INE = "INE1"
|
||||||
|
|
||||||
|
|
||||||
def test_formsemestre(api_headers):
|
def test_formsemestre(api_headers):
|
||||||
"""
|
"""
|
||||||
@ -53,7 +58,7 @@ def test_etudiant_bulletin(api_headers):
|
|||||||
bull_a = r.json()
|
bull_a = r.json()
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
f"{API_URL}/etudiant/nip/1/formsemestre/{formsemestre_id}/bulletin",
|
f"{API_URL}/etudiant/nip/{NIP}/formsemestre/{formsemestre_id}/bulletin",
|
||||||
headers=api_headers,
|
headers=api_headers,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
@ -61,7 +66,7 @@ def test_etudiant_bulletin(api_headers):
|
|||||||
bull_b = r.json()
|
bull_b = r.json()
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
f"{API_URL}/etudiant/ine/1/formsemestre/{formsemestre_id}/bulletin",
|
f"{API_URL}/etudiant/ine/{INE}/formsemestre/{formsemestre_id}/bulletin",
|
||||||
headers=api_headers,
|
headers=api_headers,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user