Merge branch 'master' of https://scodoc.org/git/ScoDoc/ScoDoc into entreprises

This commit is contained in:
Arthur ZHU 2022-05-04 00:08:34 +02:00
commit 54a71b513a
18 changed files with 820 additions and 576 deletions

View File

@ -93,7 +93,7 @@ def absences_just(etudid: int = None, nip: int = None, ine: int = None):
"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": false, "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"
@ -120,7 +120,11 @@ def absences_just(etudid: int = None, nip: int = None, ine: int = None):
@bp.route( @bp.route(
"/absences/abs_group_etat/?group_id=<int:group_id>&date_debut=date_debut&date_fin=date_fin", "/absences/abs_group_etat/<int:group_id>",
methods=["GET"],
)
@bp.route(
"/absences/abs_group_etat/group_id/<int:group_id>/date_debut/<string:date_debut>/date_fin/<string:date_fin>",
methods=["GET"], methods=["GET"],
) )
@token_permission_required(Permission.APIView) @token_permission_required(Permission.APIView)

View File

@ -187,117 +187,3 @@ def referenciel_competences(dept: str, formation_id: int):
) )
else: else:
return jsonify(ref_comp) return jsonify(ref_comp)
@bp.route(
"/departements/<string:dept>/formsemestre/<string:formsemestre_id>/programme",
methods=["GET"],
)
@token_permission_required(Permission.APIView)
def semestre_index(dept: str, formsemestre_id: int):
"""
Retourne la liste des Ues, ressources et SAE d'un semestre
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
},
...
]
}
"""
app.set_sco_dept(dept)
formsemestre = models.FormSemestre.query.filter_by(
id=formsemestre_id
).first_or_404()
ues = formsemestre.query_ues()
ues_dict = []
ressources = []
saes = []
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

View File

@ -12,41 +12,33 @@ 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
from app.scodoc import notesdb as ndb
@bp.route("/etudiants/courant", methods=["GET"]) @bp.route("/etudiants/courant", defaults={"long": False})
@bp.route("/etudiants/courant/long", defaults={"long": True})
@token_permission_required(Permission.APIView) @token_permission_required(Permission.APIView)
def etudiants_courant(): def etudiants_courant(long=False):
""" """
Retourne la liste des étudiants courant Retourne la liste des étudiants courant
Exemple de résultat : Exemple de résultat :
{ [
{ {
"civilite": "X", "id": 1,
"code_ine": null, "nip": 1,
"code_nip": null,
"date_naissance": null,
"email": null,
"emailperso": null,
"etudid": 18,
"nom": "MOREL", "nom": "MOREL",
"prenom": "JACQUES" "prenom": "JACQUES",
},
{
"civilite": "X", "civilite": "X",
"code_ine": null, },
"code_nip": null, {
"date_naissance": null, "id": 2,
"email": null, "nip": 2,
"emailperso": null, "nom": "GILLES",
"etudid": 19, "prenom": "MAXIME",
"nom": "FOURNIER", "civilite": "X",
"prenom": "ANNE" },
}, ...
... ]
}
""" """
# Récupération de tous les étudiants # Récupération de tous les étudiants
etuds = Identite.query.filter( etuds = Identite.query.filter(
@ -55,9 +47,11 @@ def etudiants_courant():
FormSemestre.date_debut <= app.db.func.now(), FormSemestre.date_debut <= app.db.func.now(),
FormSemestre.date_fin >= app.db.func.now(), FormSemestre.date_fin >= app.db.func.now(),
) )
if long:
data = [etu.to_dict_bul(include_urls=False) for etu in etuds] data = [etud.to_dict_bul(include_urls=False) for etud in etuds]
else:
data = [etud.to_dict_short() for etud in etuds]
print(jsonify(data))
return jsonify(data) return jsonify(data)
@ -74,17 +68,32 @@ def etudiant(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 :
{ {
"civilite": "X", "civilite": "X",
"code_ine": null, "code_ine": "1",
"code_nip": null, "code_nip": "1",
"date_naissance": null, "date_naissance": "",
"email": null, "email": "SACHA.COSTA@example.com",
"emailperso": null, "emailperso": "",
"etudid": 18, "etudid": 1,
"nom": "MOREL", "nom": "COSTA",
"prenom": "JACQUES" "prenom": "SACHA",
} "nomprenom": "Sacha COSTA",
"lieu_naissance": "",
"dept_naissance": "",
"nationalite": "",
"boursier": "",
"id": 1,
"codepostaldomicile": "",
"paysdomicile": "",
"telephonemobile": "",
"typeadresse": "domicile",
"domicile": "",
"villedomicile": "",
"telephone": "",
"fax": "",
"description": ""
}
""" """
# Récupération de l'étudiant # Récupération de l'étudiant
etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine) etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
@ -108,38 +117,36 @@ def etudiant_formsemestres(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 :
[ [
{ {
"titre": "master machine info", "date_fin": "31/08/2022",
"gestion_semestrielle": false, "resp_can_edit": false,
"date_debut": "01/09/2021", "dept_id": 1,
"bul_bgcolor": null, "etat": true,
"date_fin": "15/12/2022", "resp_can_change_ens": true,
"resp_can_edit": false, "id": 1,
"dept_id": 1, "modalite": "FI",
"etat": true, "ens_can_edit_eval": false,
"resp_can_change_ens": false, "formation_id": 1,
"id": 1, "gestion_compensation": false,
"modalite": "FI", "elt_sem_apo": null,
"ens_can_edit_eval": false, "semestre_id": 1,
"formation_id": 1, "bul_hide_xml": false,
"gestion_compensation": false, "elt_annee_apo": null,
"elt_sem_apo": null, "titre": "Semestre test",
"semestre_id": 1, "block_moyennes": false,
"bul_hide_xml": false, "scodoc7_id": null,
"elt_annee_apo": null, "date_debut": "01/09/2021",
"block_moyennes": false, "gestion_semestrielle": false,
"formsemestre_id": 1, "bul_bgcolor": "white",
"titre_num": "master machine info semestre 1", "formsemestre_id": 1,
"date_debut_iso": "2021-09-01", "titre_num": "Semestre test semestre 1",
"date_fin_iso": "2022-12-15", "date_debut_iso": "2021-09-01",
"responsables": [ "date_fin_iso": "2022-08-31",
3, "responsables": []
2 },
] ...
}, ]
...
]
""" """
# Récupération de l'étudiant # Récupération de l'étudiant
etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine) etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)

View File

@ -62,27 +62,27 @@ def evaluation_notes(evaluation_id: int):
evaluation_id : l'id d'une évaluation evaluation_id : l'id d'une évaluation
Exemple de résultat : Exemple de résultat :
{ {
"1": { "1": {
"id": 1, "id": 1,
"etudid": 10, "etudid": 10,
"evaluation_id": 1, "evaluation_id": 1,
"value": 15.0, "value": 15.0,
"comment": "", "comment": "",
"date": "Wed, 20 Apr 2022 06:49:05 GMT", "date": "Wed, 20 Apr 2022 06:49:05 GMT",
"uid": 2 "uid": 2
}, },
"2": { "2": {
"id": 2, "id": 2,
"etudid": 1, "etudid": 1,
"evaluation_id": 1, "evaluation_id": 1,
"value": 12.0, "value": 12.0,
"comment": "", "comment": "",
"date": "Wed, 20 Apr 2022 06:49:06 GMT", "date": "Wed, 20 Apr 2022 06:49:06 GMT",
"uid": 2 "uid": 2
}, },
... ...
} }
""" """
# Fonction utilisée : app.scodoc.sco_evaluation_db.do_evaluation_get_all_notes() # Fonction utilisée : app.scodoc.sco_evaluation_db.do_evaluation_get_all_notes()

View File

@ -32,7 +32,6 @@ def formations():
}, },
... ...
] ]
""" """
# Récupération de toutes les formations # Récupération de toutes les formations
list_formations = models.Formation.query.all() list_formations = models.Formation.query.all()
@ -171,13 +170,12 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False):
}, },
] ]
} }
""" """
# Fonction utilité : app.scodoc.sco_formations.formation_export() # Fonction utilité : app.scodoc.sco_formations.formation_export()
try: try:
# Utilisation de la fonction formation_export # Utilisation de la fonction formation_export
data = formation_export(formation_id) data = formation_export(formation_id, export_ids)
except ValueError: except ValueError:
return error_response( return error_response(
409, 409,
@ -190,17 +188,47 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False):
@bp.route("/formations/moduleimpl/<int:moduleimpl_id>", methods=["GET"]) @bp.route("/formations/moduleimpl/<int:moduleimpl_id>", methods=["GET"])
@token_permission_required(Permission.APIView) @token_permission_required(Permission.APIView)
def moduleimpls(moduleimpl_id: int): def moduleimpl(moduleimpl_id: int):
""" """
Retourne la liste des moduleimpl Retourne un module moduleimpl en fonction de son id
moduleimpl_id : l'id d'un moduleimpl moduleimpl_id : l'id d'un moduleimpl
Exemple de résultat :
{
"id": 1,
"formsemestre_id": 1,
"computation_expr": null,
"module_id": 1,
"responsable_id": 2,
"moduleimpl_id": 1,
"ens": [],
"module": {
"heures_tp": 0,
"code_apogee": "",
"titre": "Initiation aux réseaux informatiques",
"coefficient": 1,
"module_type": 2,
"id": 1,
"ects": null,
"abbrev": "Init aux réseaux informatiques",
"ue_id": 1,
"code": "R101",
"formation_id": 1,
"heures_cours": 0,
"matiere_id": 1,
"heures_td": 0,
"semestre_id": 1,
"numero": 10,
"module_id": 1
}
}
""" """
# Récupération des tous les moduleimpl # Récupération des tous les moduleimpl
list_moduleimpls = models.ModuleImpl.query.filter_by(id=moduleimpl_id) moduleimpl = models.ModuleImpl.query.filter_by(id=moduleimpl_id).first_or_404()
# Mise en forme des données # Mise en forme des données
data = [moduleimpl.to_dict() for moduleimpl in list_moduleimpls] data = moduleimpl.to_dict()
return jsonify(data) return jsonify(data)
@ -208,7 +236,7 @@ def moduleimpls(moduleimpl_id: int):
@bp.route( @bp.route(
"/formations/moduleimpl/formsemestre/<int:formsemestre_id>/liste", "/formations/moduleimpl/formsemestre/<int:formsemestre_id>/liste",
methods=["GET"], methods=["GET"],
) # XXX TODO penser à changer la route sur la doc )
@token_permission_required(Permission.APIView) @token_permission_required(Permission.APIView)
def moduleimpls_sem(formsemestre_id: int): def moduleimpls_sem(formsemestre_id: int):
""" """

View File

@ -68,6 +68,35 @@ def formsemestre_apo(etape_apo: str):
Retourne les informations sur les formsemestres Retourne les informations sur les formsemestres
etape_apo : l'id d'une étape apogée etape_apo : l'id d'une étape apogée
Exemple de résultat :
{
"date_fin": "31/08/2022",
"resp_can_edit": false,
"dept_id": 1,
"etat": true,
"resp_can_change_ens": true,
"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,
"titre": "Semestre test",
"block_moyennes": false,
"scodoc7_id": null,
"date_debut": "01/09/2021",
"gestion_semestrielle": false,
"bul_bgcolor": "white",
"formsemestre_id": 1,
"titre_num": "Semestre test semestre 1",
"date_debut_iso": "2021-09-01",
"date_fin_iso": "2022-08-31",
"responsables": []
}
""" """
formsemestres = FormSemestre.query.filter( formsemestres = FormSemestre.query.filter(
FormSemestreEtape.etape_apo == etape_apo, FormSemestreEtape.etape_apo == etape_apo,
@ -78,21 +107,20 @@ def formsemestre_apo(etape_apo: str):
@bp.route( @bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/etudid/<int:etudid>/bulletin", "/formsemestre/<int:formsemestre_id>/etudiant/etudid/<int:etudid>/bulletin",
methods=["GET"], methods=["GET"],
) )
@bp.route( @bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/nip/<int:nip>/bulletin", "/formsemestre/<int:formsemestre_id>/etudiant/nip/<int:nip>/bulletin",
methods=["GET"], methods=["GET"],
) )
@bp.route( @bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/ine/<int:ine>/bulletin", "/formsemestre/<int:formsemestre_id>/etudiant/ine/<int:ine>/bulletin",
methods=["GET"], methods=["GET"],
) )
@token_permission_required(Permission.APIView) @token_permission_required(Permission.APIView)
def etudiant_bulletin( def etudiant_bulletin(
formsemestre_id, formsemestre_id,
dept,
etudid: int = None, etudid: int = None,
nip: int = None, nip: int = None,
ine: int = None, ine: int = None,
@ -212,7 +240,15 @@ def etudiant_bulletin(
# Fonction utilisée : app.scodoc.sco_bulletins_json.make_json_formsemestre_bulletinetud() # Fonction utilisée : app.scodoc.sco_bulletins_json.make_json_formsemestre_bulletinetud()
try: try:
app.set_sco_dept(dept) formsemestre = models.FormSemestre.query.filter_by(
id=formsemestre_id
).first_or_404()
dept = models.Departement.query.filter_by(
id=formsemestre.dept_id
).first_or_404()
app.set_sco_dept(dept.acronym)
except: except:
return error_response( return error_response(
409, 409,
@ -470,3 +506,115 @@ def jury(formsemestre_id: int):
# ) # )
return jsonify(data) return jsonify(data)
@bp.route(
"/formsemestre/<int:formsemestre_id>/programme",
methods=["GET"],
)
@token_permission_required(Permission.APIView)
def semestre_index(formsemestre_id: int):
"""
Retourne la liste des Ues, ressources et SAE d'un semestre
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
},
...
]
}
"""
formsemestre = models.FormSemestre.query.filter_by(
id=formsemestre_id
).first_or_404()
ues = formsemestre.query_ues()
ues_dict = []
ressources = []
saes = []
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

View File

@ -121,13 +121,13 @@ def etud_in_group(group_id: int, etat=None):
@bp.route( @bp.route(
"/partitions/set_groups?partition_id=<int:partition_id>&groups_lists=<int:groups_lists>&" "/partitions/set_groups/partition/<int:partition_id>/groups/<string:groups_id>/delete/<string:groups_to_delete>"
"groups_to_create=<int:groups_to_create>&groups_to_delete=<int:groups_to_delete>", "/create/<string:groups_to_create>",
methods=["POST"], methods=["POST"],
) )
@token_permission_required(Permission.APIEtudChangeGroups) @token_permission_required(Permission.APIEtudChangeGroups)
def set_groups( def set_groups(
partition_id: int, groups_lists: int, groups_to_delete: int, groups_to_create: int partition_id: int, groups_lists: str, groups_to_delete: str, groups_to_create: str
): ):
""" """
Set les groups Set les groups

View File

@ -946,7 +946,7 @@ class BonusStBrieuc(BonusSportAdditif):
name = "bonus_iut_stbrieuc" name = "bonus_iut_stbrieuc"
displayed_name = "IUT de Saint-Brieuc" displayed_name = "IUT de Saint-Brieuc"
proportion_point = 1 / 20.0 proportion_point = 1 / 20.0
classic_use_bonus_ues = True classic_use_bonus_ues = False
def compute_bonus(self, sem_modimpl_moys_inscrits, modimpl_coefs_etuds_no_nan): def compute_bonus(self, sem_modimpl_moys_inscrits, modimpl_coefs_etuds_no_nan):
"""calcul du bonus""" """calcul du bonus"""

View File

@ -141,7 +141,18 @@ class Identite(db.Model):
"Le mail associé à la première adrese de l'étudiant, ou None" "Le mail associé à la première adrese de l'étudiant, ou None"
return getattr(self.adresses[0], field) if self.adresses.count() > 0 else None return getattr(self.adresses[0], field) if self.adresses.count() > 0 else None
def to_dict_scodoc7(self): def to_dict_short(self) -> dict:
"""Les champs essentiels"""
return {
"id": self.id,
"nip": self.code_nip,
"nom": self.nom,
"nom_usuel": self.nom_usuel,
"prenom": self.prenom,
"civilite": self.civilite,
}
def to_dict_scodoc7(self) -> dict:
"""Représentation dictionnaire, """Représentation dictionnaire,
compatible ScoDoc7 mais sans infos admission compatible ScoDoc7 mais sans infos admission
""" """

View File

@ -210,10 +210,17 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
) # la plus RECENTE en tête ) # la plus RECENTE en tête
# #
caneditevals = sco_permissions_check.can_edit_notes( sem_locked = not sem["etat"]
current_user, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"] can_edit_evals = (
sco_permissions_check.can_edit_notes(
current_user, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"]
)
and not sem_locked
)
can_edit_notes = (
sco_permissions_check.can_edit_notes(current_user, moduleimpl_id)
and not sem_locked
) )
caneditnotes = sco_permissions_check.can_edit_notes(current_user, moduleimpl_id)
arrow_up, arrow_down, arrow_none = sco_groups.get_arrow_icons_tags() arrow_up, arrow_down, arrow_none = sco_groups.get_arrow_icons_tags()
# #
module_resp = User.query.get(M["responsable_id"]) module_resp = User.query.get(M["responsable_id"])
@ -264,7 +271,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
H.append("""Semestre: </td><td>%s""" % sem["semestre_id"]) H.append("""Semestre: </td><td>%s""" % sem["semestre_id"])
else: else:
H.append("""</td><td>""") H.append("""</td><td>""")
if not sem["etat"]: if sem_locked:
H.append(scu.icontag("lock32_img", title="verrouillé")) H.append(scu.icontag("lock32_img", title="verrouillé"))
H.append("""</td><td class="fichetitre2">""") H.append("""</td><td class="fichetitre2">""")
if modimpl.module.is_apc(): if modimpl.module.is_apc():
@ -385,13 +392,15 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
# -------- Tableau des evaluations # -------- Tableau des evaluations
top_table_links = "" top_table_links = ""
if sem["etat"]: # non verrouillé if can_edit_evals:
top_table_links = ( top_table_links = f"""<a class="stdlink" href="{
"""<a class="stdlink" href="evaluation_create?moduleimpl_id=%(moduleimpl_id)s">Créer nouvelle évaluation</a> url_for("notes.evaluation_create", scodoc_dept=g.scodoc_dept, moduleimpl_id=M['moduleimpl_id'])
<a class="stdlink" style="margin-left:2em;" href="module_evaluation_renumber?moduleimpl_id=%(moduleimpl_id)s&redirect=1">Trier par date</a> }">Créer nouvelle évaluation</a>
""" <a class="stdlink" style="margin-left:2em;" href="{
% M url_for("notes.module_evaluation_renumber", scodoc_dept=g.scodoc_dept, moduleimpl_id=M['moduleimpl_id'],
) redirect=1)
}">Trier par date</a>
"""
if mod_evals: if mod_evals:
H.append( H.append(
'<div class="moduleimpl_evaluations_top_links">' '<div class="moduleimpl_evaluations_top_links">'
@ -451,14 +460,14 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
) )
# Fleches: # Fleches:
H.append('<span class="eval_arrows_chld">') H.append('<span class="eval_arrows_chld">')
if eval_index != (len(mod_evals) - 1) and caneditevals: if eval_index != (len(mod_evals) - 1) and can_edit_evals:
H.append( H.append(
'<a href="module_evaluation_move?evaluation_id=%s&after=0" class="aud">%s</a>' '<a href="module_evaluation_move?evaluation_id=%s&after=0" class="aud">%s</a>'
% (eval["evaluation_id"], arrow_up) % (eval["evaluation_id"], arrow_up)
) )
else: else:
H.append(arrow_none) H.append(arrow_none)
if (eval_index > 0) and caneditevals: if (eval_index > 0) and can_edit_evals:
H.append( H.append(
'<a href="module_evaluation_move?evaluation_id=%s&after=1" class="aud">%s</a>' '<a href="module_evaluation_move?evaluation_id=%s&after=1" class="aud">%s</a>'
% (eval["evaluation_id"], arrow_down) % (eval["evaluation_id"], arrow_down)
@ -487,7 +496,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
etat_descr = "il manque des notes" etat_descr = "il manque des notes"
else: else:
etat_txt = "" etat_txt = ""
if caneditevals and etat_txt: if can_edit_evals and etat_txt:
etat_txt = ( etat_txt = (
'<a href="evaluation_edit?evaluation_id=%s" title="%s">%s</a>' '<a href="evaluation_edit?evaluation_id=%s" title="%s">%s</a>'
% (eval["evaluation_id"], etat_descr, etat_txt) % (eval["evaluation_id"], etat_descr, etat_txt)
@ -496,7 +505,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
H.append("""</th></tr>""") H.append("""</th></tr>""")
H.append("""<tr class="%s"><td class="mievr">""" % tr_class) H.append("""<tr class="%s"><td class="mievr">""" % tr_class)
if caneditevals: if can_edit_evals:
H.append( H.append(
"""<a class="smallbutton" href="evaluation_edit?evaluation_id=%s">%s</a>""" """<a class="smallbutton" href="evaluation_edit?evaluation_id=%s">%s</a>"""
% ( % (
@ -506,7 +515,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
), ),
) )
) )
if caneditnotes: if can_edit_notes:
H.append( H.append(
"""<a class="smallbutton" href="saisie_notes?evaluation_id=%s">%s</a>""" """<a class="smallbutton" href="saisie_notes?evaluation_id=%s">%s</a>"""
% ( % (
@ -517,13 +526,13 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
) )
) )
if etat["nb_notes"] == 0: if etat["nb_notes"] == 0:
if caneditevals: if can_edit_evals:
H.append( H.append(
"""<a class="smallbutton" href="evaluation_delete?evaluation_id=%(evaluation_id)s">""" """<a class="smallbutton" href="evaluation_delete?evaluation_id=%(evaluation_id)s">"""
% eval % eval
) )
H.append(scu.icontag("delete_img", alt="supprimer", title="Supprimer")) H.append(scu.icontag("delete_img", alt="supprimer", title="Supprimer"))
if caneditevals: if can_edit_evals:
H.append("""</a>""") H.append("""</a>""")
elif etat["evalcomplete"]: elif etat["evalcomplete"]:
H.append( H.append(
@ -561,7 +570,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
else: else:
H.append("&nbsp;") H.append("&nbsp;")
H.append('</td><td class="mievr_menu">') H.append('</td><td class="mievr_menu">')
if caneditnotes: if can_edit_notes:
H.append( H.append(
moduleimpl_evaluation_menu( moduleimpl_evaluation_menu(
eval["evaluation_id"], eval["evaluation_id"],
@ -644,7 +653,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
H.append(""")""") H.append(""")""")
if gr_moyenne["group_id"] in etat["gr_incomplets"]: if gr_moyenne["group_id"] in etat["gr_incomplets"]:
H.append("""[<font color="red">""") H.append("""[<font color="red">""")
if caneditnotes: if can_edit_notes:
H.append( H.append(
"""<a class="redlink" href="saisie_notes?evaluation_id=%s&group_ids:list=%s">incomplet</a></font>]""" """<a class="redlink" href="saisie_notes?evaluation_id=%s&group_ids:list=%s">incomplet</a></font>]"""
% (eval["evaluation_id"], gr_moyenne["group_id"]) % (eval["evaluation_id"], gr_moyenne["group_id"])
@ -653,25 +662,25 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None):
H.append("""incomplet</font>]""") H.append("""incomplet</font>]""")
else: else:
H.append("""<span class="redboldtext">&nbsp; """) H.append("""<span class="redboldtext">&nbsp; """)
if caneditnotes: if can_edit_notes:
H.append( H.append(
"""<a class="redlink" href="saisie_notes?evaluation_id=%s&group_ids:list=%s">""" """<a class="redlink" href="saisie_notes?evaluation_id=%s&group_ids:list=%s">"""
% (eval["evaluation_id"], gr_moyenne["group_id"]) % (eval["evaluation_id"], gr_moyenne["group_id"])
) )
H.append("pas de notes") H.append("pas de notes")
if caneditnotes: if can_edit_notes:
H.append("""</a>""") H.append("""</a>""")
H.append("</span>") H.append("</span>")
H.append("""</td></tr>""") H.append("""</td></tr>""")
first_eval = False first_eval = False
# #
if caneditevals or not sem["etat"]:
H.append("""<tr><td colspan="8">""") H.append("""<tr><td colspan="8">""")
if not sem["etat"]: if sem_locked:
H.append("""%s semestre verrouillé""" % scu.icontag("lock32_img")) H.append(f"""{scu.icontag("lock32_img")} semestre verrouillé""")
else: elif can_edit_evals:
H.append(top_table_links) H.append(top_table_links)
H.append( H.append(
"""</td></tr> """</td></tr>

View File

@ -871,7 +871,10 @@ def EtatAbsencesGr(
) )
nbjustifs_noabs = len( nbjustifs_noabs = len(
sco_abs.list_abs_justifs( sco_abs.list_abs_justifs(
etudid=etud["etudid"], datedebut=datedebut, only_no_abs=True etudid=etud["etudid"],
datedebut=datedebut,
datefin=datefin,
only_no_abs=True,
) )
) )
# retrouve sem dans etud['sems'] # retrouve sem dans etud['sems']
@ -894,7 +897,7 @@ def EtatAbsencesGr(
"nbjustifs_noabs": nbjustifs_noabs, "nbjustifs_noabs": nbjustifs_noabs,
"_nomprenom_target": "CalAbs?etudid=%s" % etud["etudid"], "_nomprenom_target": "CalAbs?etudid=%s" % etud["etudid"],
"_nomprenom_td_attrs": 'id="%s" class="etudinfo"' % etud["etudid"], "_nomprenom_td_attrs": 'id="%s" class="etudinfo"' % etud["etudid"],
"boursier": etud["boursier"], "boursier": "oui" if etud["boursier"] else "non",
} }
) )
if s["ins"]["etat"] == "D": if s["ins"]["etat"] == "D":
@ -922,9 +925,36 @@ def EtatAbsencesGr(
h = groups_infos.groups_titles h = groups_infos.groups_titles
gr_tit = p + h gr_tit = p + h
title = "État des absences %s" % gr_tit title = f"État des absences {gr_tit}"
if format == "xls" or format == "xml" or format == "json": if format == "xls" or format == "xml" or format == "json":
columns_ids = ["etudid"] + columns_ids columns_ids = ["etudid"] + columns_ids
# --- Formulaire choix dates début / fin
form_date = (
f"""
<form action="{groups_infos.base_url}" method="get">
<input type="hidden" name="group_ids" value="{group_ids}">
<span style="font-size: 120%"><b>Période du
<input type="text" name="debut" size="10" value="{debut}" class="datepicker"
onchange="validate_date(this);">
&nbsp;au&nbsp;
<input type="text" name="fin" size="10" value="{fin}" class="datepicker"
onchange="validate_date(this);">
</b></span>
&nbsp;
(nombre de <em>demi-journées</em>)
</form>"""
+ """
<script>
function validate_date(el) {
const regex = /^[0-3]?[0-9]\/[0-9]{1,2}\/[0-9]{1,4}$/;
if (regex.test(el.value)) {
return el.form.submit();
}
return false;
}
</script>
"""
)
tab = GenTable( tab = GenTable(
columns_ids=columns_ids, columns_ids=columns_ids,
rows=T, rows=T,
@ -945,8 +975,9 @@ def EtatAbsencesGr(
init_qtip=True, init_qtip=True,
javascripts=["js/etud_info.js"], javascripts=["js/etud_info.js"],
), ),
html_title=html_sco_header.html_sem_header("%s" % title, with_page_header=False) html_title=html_sco_header.html_sem_header(title, with_page_header=False)
+ "<p>Période du %s au %s (nombre de <b>demi-journées</b>)<br/>" % (debut, fin), + form_date,
# "<p>Période du %s au %s (nombre de <b>demi-journées</b>)<br/>" % (debut, fin),
base_url="%s&formsemestre_id=%s&debut=%s&fin=%s" base_url="%s&formsemestre_id=%s&debut=%s&fin=%s"
% (groups_infos.base_url, formsemestre_id, debut, fin), % (groups_infos.base_url, formsemestre_id, debut, fin),
filename="etat_abs_" filename="etat_abs_"

View File

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

View File

@ -20,10 +20,18 @@ Utilisation :
import requests import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# departements # departements
def test_departements(): #XXX TODO pour Seb def test_departements():
fields = [
"id",
"acronym",
"description",
"visible",
"date_creation",
]
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements", SCODOC_URL + "/ScoDoc/api/departements",
headers=HEADERS, headers=HEADERS,
@ -32,134 +40,122 @@ def test_departements(): #XXX TODO pour Seb
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 1 assert len(r.json()) == 1
dept = r.json()[0]
fields_OK = verify_fields(dept, fields)
assert fields_OK is True
# liste_etudiants # liste_etudiants
def test_liste_etudiants(): #XXX TODO pour Seb def test_liste_etudiants():
fields = [
"civilite",
"code_ine",
"code_nip",
"date_naissance",
"email",
"emailperso",
"etudid",
"nom",
"prenom",
"nomprenom",
"lieu_naissance",
"dept_naissance",
"nationalite",
"boursier",
"id",
"codepostaldomicile",
"paysdomicile",
"telephonemobile",
"typeadresse",
"domicile",
"villedomicile",
"telephone",
"fax",
"description",
]
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste", SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
etu = r.json()[0]
fields_OK = verify_fields(etu, fields)
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 16 assert len(r.json()) == 16
assert fields_OK is True
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste/1", SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste/1",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
etu = r.json()[0]
fields_OK = verify_fields(etu, fields)
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 16 assert len(r.json()) == 16
assert fields_OK is True
# liste_semestres_courant # liste_semestres_courant
def test_semestres_courant(): #XXX TODO pour Seb def test_semestres_courant():
fields = [
"titre",
"gestion_semestrielle",
"scodoc7_id",
"date_debut",
"bul_bgcolor",
"date_fin",
"resp_can_edit",
"dept_id",
"etat",
"resp_can_change_ens",
"id",
"modalite",
"ens_can_edit_eval",
"formation_id",
"gestion_compensation",
"elt_sem_apo",
"semestre_id",
"bul_hide_xml",
"elt_annee_apo",
"block_moyennes",
"formsemestre_id",
"titre_num",
"date_debut_iso",
"date_fin_iso",
"responsables",
]
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements/TAPI/semestres_courants", SCODOC_URL + "/ScoDoc/api/departements/TAPI/semestres_courants",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
sem = r.json()[0]
fields_OK = verify_fields(sem, fields)
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 1 assert len(r.json()) == 1
assert fields_OK is True
# referenciel_competences # referenciel_competences
def test_referenciel_competences(): def test_referenciel_competences():
r = requests.get( r = requests.get(
SCODOC_URL SCODOC_URL
+ "/ScoDoc/api/departements/TAPI/formations/1/referentiel_competences", + "/ScoDoc/api/departements/TAPI/formations/1/referentiel_competences",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
assert r.status_code == 200 or 204 assert r.status_code == 200 or 204
# semestre_index
def test_semestre_index(): #XXX TODO pour Seb
ue_fields = [
"semestre_idx",
"type",
"formation_id",
"ue_code",
"id",
"ects",
"acronyme",
"is_external",
"numero",
"code_apogee",
"titre",
"coefficient",
"color",
"ue_id",
]
ressource_fields = [
"heures_tp",
"code_apogee",
"titre",
"coefficient",
"module_type",
"id",
"ects",
"abbrev",
"ue_id",
"code",
"formation_id",
"heures_cours",
"matiere_id",
"heures_td",
"semestre_id",
"numero",
"module_id",
]
sae_fields = [
"heures_tp",
"code_apogee",
"titre",
"coefficient",
"module_type",
"id",
"ects",
"abbrev",
"ue_id",
"code",
"formation_id",
"heures_cours",
"matiere_id",
"heures_td",
"semestre_id",
"numero",
"module_id",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
assert len(r.json()) == 3
ue = r.json()["ues"][0]
ressource = r.json()["ressources"][0]
sae = r.json()["saes"][0]
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in ue:
if field not in ue_fields:
fields_OK = False
for field in ressource:
if field not in ressource_fields:
fields_OK = False
for field in sae:
if field not in sae_fields:
fields_OK = False
assert fields_OK is True

View File

@ -21,63 +21,38 @@ from random import randint
import requests import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# # etudiants
# def test_etudiants():
#
# fields = [
# "civilite",
# "code_ine",
# "code_nip",
# "date_naissance",
# "email",
# "emailperso",
# "etudid",
# "nom",
# "prenom",
# "nomprenom",
# "lieu_naissance",
# "dept_naissance",
# "nationalite",
# "boursier",
# "id",
# "domicile",
# "villedomicile",
# "telephone",
# "fax",
# "description",
# "codepostaldomicile",
# "paysdomicile",
# "telephonemobile",
# "typeadresse",
# ]
#
# r = requests.get(
# SCODOC_URL + "/ScoDoc/api/etudiants",
# headers=HEADERS,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
# assert len(r.json()) == 16
#
# # Choisis aléatoirement un étudiant dans la liste des étudiants
# etu = r.json()[randint(0, len(r.json())) - 1]
#
# fields_OK = True
#
# # Vérifie si tous les champs sont bien présents
# for field in etu:
# if field not in fields:
# fields_OK = False
#
# assert fields_OK is True
# etudiants_courant # etudiants_courant
def test_etudiants_courant(): # XXX TODO pour Seb def test_etudiants_courant():
fields = [ fields = [
"id",
"nip",
"nom",
"nom_usuel",
"prenom",
"civilite",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/etudiants/courant",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
assert len(r.json()) == 16
# Choisis aléatoirement un étudiant dans la liste des étudiants
etu = r.json()[randint(0, len(r.json())) - 1]
fields_OK = verify_fields(etu, fields)
assert fields_OK is True
########## Version long################
fields_long = [
"civilite", "civilite",
"code_ine", "code_ine",
"code_nip", "code_nip",
@ -93,19 +68,19 @@ def test_etudiants_courant(): # XXX TODO pour Seb
"nationalite", "nationalite",
"boursier", "boursier",
"id", "id",
"codepostaldomicile",
"paysdomicile",
"telephonemobile",
"typeadresse",
"domicile", "domicile",
"villedomicile", "villedomicile",
"telephone", "telephone",
"fax", "fax",
"description", "description",
"codepostaldomicile",
"paysdomicile",
"telephonemobile",
"typeadresse",
] ]
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/etudiants/courant", SCODOC_URL + "/ScoDoc/api/etudiants/courant/long",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
@ -115,18 +90,13 @@ def test_etudiants_courant(): # XXX TODO pour Seb
# Choisis aléatoirement un étudiant dans la liste des étudiants # Choisis aléatoirement un étudiant dans la liste des étudiants
etu = r.json()[randint(0, len(r.json())) - 1] etu = r.json()[randint(0, len(r.json())) - 1]
fields_OK = True fields_OK = verify_fields(etu, fields_long)
# Vérifie si tous les champs sont bien présents
for field in etu:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True
# etudiant # etudiant
def test_etudiant(): # XXX TODO pour Seb def test_etudiant():
fields = [ fields = [
"civilite", "civilite",
@ -167,12 +137,7 @@ def test_etudiant(): # XXX TODO pour Seb
etu = r.json() etu = r.json()
fields_OK = True fields_OK = verify_fields(etu, fields)
# Vérifie si tous les champs sont bien présents
for field in etu:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True
@ -188,12 +153,7 @@ def test_etudiant(): # XXX TODO pour Seb
etu = r.json() etu = r.json()
fields_OK = True fields_OK = verify_fields(etu, fields)
# Vérifie si tous les champs sont bien présents
for field in etu:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True
@ -209,18 +169,13 @@ def test_etudiant(): # XXX TODO pour Seb
etu = r.json() etu = r.json()
fields_OK = True fields_OK = verify_fields(etu, fields)
# Vérifie si tous les champs sont bien présents
for field in etu:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True
# etudiant_formsemestres # etudiant_formsemestres
def test_etudiant_formsemestres(): # XXX TODO pour Seb def test_etudiant_formsemestres():
fields = [ fields = [
"date_fin", "date_fin",
@ -262,12 +217,7 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
formsemestre = r.json()[0] formsemestre = r.json()[0]
fields_OK = True fields_OK = verify_fields(formsemestre, fields)
# Vérifie si tous les champs sont bien présents
for field in formsemestre:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True
@ -283,12 +233,7 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
formsemestre = r.json()[0] formsemestre = r.json()[0]
fields_OK = True fields_OK = verify_fields(formsemestre, fields)
# Vérifie si tous les champs sont bien présents
for field in formsemestre:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True
@ -304,12 +249,7 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
formsemestre = r.json()[0] formsemestre = r.json()[0]
fields_OK = True fields_OK = verify_fields(formsemestre, fields)
# Vérifie si tous les champs sont bien présents
for field in formsemestre:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True
@ -317,24 +257,6 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
# etudiant_bulletin_semestre # etudiant_bulletin_semestre
def test_etudiant_bulletin_semestre(): def test_etudiant_bulletin_semestre():
# fields = [
# "etudid",
# "formsemestre_id",
# "date",
# "publie",
# "etapes",
# "etudiant",
# "note",
# "rang",
# "rang_group",
# "note_max",
# "bonus_sport_culture",
# "ue",
# "ue_capitalisee",
# "absences",
# "appreciation",
# ]
######### Test etudid ######### ######### Test etudid #########
r = requests.get( r = requests.get(
@ -345,17 +267,6 @@ def test_etudiant_bulletin_semestre():
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 13 assert len(r.json()) == 13
# bulletin = r.json()
#
# fields_OK = True
#
# # Vérifie si tous les champs sont bien présents
# for field in bulletin:
# if field not in fields:
# fields_OK = False
#
# assert fields_OK is True
######### Test code nip ######### ######### Test code nip #########
r = requests.get( r = requests.get(
@ -366,17 +277,6 @@ def test_etudiant_bulletin_semestre():
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 13 assert len(r.json()) == 13
# bulletin = r.json()
#
# fields_OK = True
#
# # Vérifie si tous les champs sont bien présents
# for field in bulletin:
# if field not in fields:
# fields_OK = False
#
# assert fields_OK is True
######### Test code ine ######### ######### Test code ine #########
r = requests.get( r = requests.get(
@ -387,17 +287,6 @@ def test_etudiant_bulletin_semestre():
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 13 assert len(r.json()) == 13
# bulletin = r.json()
#
# fields_OK = True
#
# # Vérifie si tous les champs sont bien présents
# for field in bulletin:
# if field not in fields:
# fields_OK = False
#
# assert fields_OK is True
# etudiant_groups # etudiant_groups
def test_etudiant_groups(): def test_etudiant_groups():
@ -426,12 +315,7 @@ def test_etudiant_groups():
groups = r.json()[0] groups = r.json()[0]
fields_OK = True fields_OK = verify_fields(groups, fields)
# Vérifie si tous les champs sont bien présents
for field in groups:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True
@ -447,12 +331,7 @@ def test_etudiant_groups():
groups = r.json()[0] groups = r.json()[0]
fields_OK = True fields_OK = verify_fields(groups, fields)
# Vérifie si tous les champs sont bien présents
for field in groups:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True
@ -468,11 +347,6 @@ def test_etudiant_groups():
groups = r.json()[0] groups = r.json()[0]
fields_OK = True fields_OK = verify_fields(groups, fields)
# Vérifie si tous les champs sont bien présents
for field in groups:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True

View File

@ -20,63 +20,162 @@ Utilisation :
import requests import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# formations # formations
def test_formations(): def test_formations():
fields = [
"id",
"acronyme",
"titre_officiel",
"formation_code",
"code_specialite",
"dept_id",
"titre",
"version",
"type_parcours",
"referentiel_competence_id",
"formation_id",
]
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations", SCODOC_URL + "/ScoDoc/api/formations",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
formation = r.json()[0]
fields_OK = verify_fields(formation, fields)
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 1
assert fields_OK is True
# formations_by_id # formations_by_id
def test_formations_by_id(): def test_formations_by_id():
fields = [
"id",
"acronyme",
"titre_officiel",
"formation_code",
"code_specialite",
"dept_id",
"titre",
"version",
"type_parcours",
"referentiel_competence_id",
"formation_id",
]
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/1", SCODOC_URL + "/ScoDoc/api/formations/1",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
formation = r.json()
fields_OK = verify_fields(formation, fields)
assert r.status_code == 200 assert r.status_code == 200
assert fields_OK is True
# formation_export_by_formation_id # formation_export_by_formation_id
def test_formation_export_by_formation_id(): def test_formation_export_by_formation_id():
fields = [
"id",
"acronyme",
"titre_officiel",
"formation_code",
"code_specialite",
"dept_id",
"titre",
"version",
"type_parcours",
"referentiel_competence_id",
"formation_id",
"ue",
]
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/formation_export/1", SCODOC_URL + "/ScoDoc/api/formations/formation_export/1",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
export_formation = r.json()
fields_OK = verify_fields(export_formation, fields)
assert r.status_code == 200 assert r.status_code == 200
assert fields_OK is True
# formsemestre_apo # formsemestre_apo
def test_formsemestre_apo(): # def test_formsemestre_apo():
# r = requests.get(
# SCODOC_URL + "/ScoDoc/api/formations/apo/<string:etape_apo>",
# headers=HEADERS,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
# moduleimpl
def test_moduleimpl():
fields = [
"id",
"formsemestre_id",
"computation_expr",
"module_id",
"responsable_id",
"moduleimpl_id",
"ens",
"module",
]
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/apo/<string:etape_apo>", SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/1",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
assert r.status_code == 200
moduleimpl = r.json()
fields_OK = verify_fields(moduleimpl, fields)
# moduleimpls
def test_moduleimpls():
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/<int:moduleimpl_id>",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200 assert r.status_code == 200
assert fields_OK is True
# moduleimpls_sem # moduleimpls_sem
def test_moduleimpls_sem(): def test_moduleimpls_sem():
fields = [
"id",
"formsemestre_id",
"computation_expr",
"module_id",
"responsable_id",
"moduleimpl_id",
"ens",
"module",
"moduleimpl_id",
"ens",
]
r = requests.get( r = requests.get(
SCODOC_URL SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/formsemestre/1/liste",
+ "/ScoDoc/api/formations/moduleimpl/formsemestre/1/liste",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
moduleimpl = r.json()[0]
fields_OK = verify_fields(moduleimpl, fields)
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 21
assert fields_OK is True

View File

@ -20,6 +20,7 @@ Utilisation :
import requests import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# formsemestre # formsemestre
def test_formsemestre(): def test_formsemestre():
@ -60,37 +61,29 @@ def test_formsemestre():
"responsables", "responsables",
] ]
fields_OK = True fields_OK = verify_fields(formsemestre, fields)
# Vérifie si tous les champs sont bien présents
for field in formsemestre:
if field not in fields:
fields_OK = False
assert fields_OK is True assert fields_OK is True
# etudiant_bulletin # etudiant_bulletin
def test_etudiant_bulletin(): #XXX TODO pour Seb def test_etudiant_bulletin():
r = requests.get( r = requests.get(
SCODOC_URL SCODOC_URL + "/ScoDoc/api/formsemestre/1/etudiant/etudid/1/bulletin",
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/etudid/1/bulletin",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
assert r.status_code == 200 assert r.status_code == 200
r = requests.get( r = requests.get(
SCODOC_URL SCODOC_URL + "/ScoDoc/api/formsemestre/1/etudiant/nip/1/bulletin",
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/nip/1/bulletin",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
assert r.status_code == 200 assert r.status_code == 200
r = requests.get( r = requests.get(
SCODOC_URL SCODOC_URL + "/ScoDoc/api/formsemestre/1/etudiant/ine/1/bulletin",
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/ine/1/bulletin",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
@ -115,3 +108,83 @@ def test_bulletins():
# verify=CHECK_CERTIFICATE, # verify=CHECK_CERTIFICATE,
# ) # )
# assert r.status_code == 200 # assert r.status_code == 200
# semestre_index
def test_semestre_index():
ue_fields = [
"semestre_idx",
"type",
"formation_id",
"ue_code",
"id",
"ects",
"acronyme",
"is_external",
"numero",
"code_apogee",
"titre",
"coefficient",
"color",
"ue_id",
]
ressource_fields = [
"heures_tp",
"code_apogee",
"titre",
"coefficient",
"module_type",
"id",
"ects",
"abbrev",
"ue_id",
"code",
"formation_id",
"heures_cours",
"matiere_id",
"heures_td",
"semestre_id",
"numero",
"module_id",
]
sae_fields = [
"heures_tp",
"code_apogee",
"titre",
"coefficient",
"module_type",
"id",
"ects",
"abbrev",
"ue_id",
"code",
"formation_id",
"heures_cours",
"matiere_id",
"heures_td",
"semestre_id",
"numero",
"module_id",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formsemestre/1/programme",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
assert len(r.json()) == 3
ue = r.json()["ues"][0]
ressource = r.json()["ressources"][0]
sae = r.json()["saes"][0]
fields_ue_OK = verify_fields(ue, ue_fields)
fields_ressource_OK = verify_fields(ressource, ressource_fields)
fields_sae_OK = verify_fields(sae, sae_fields)
assert fields_ue_OK is True
assert fields_ressource_OK is True
assert fields_sae_OK is True

View File

@ -20,40 +20,105 @@ Utilisation :
import requests import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# partition # partition
def test_partition(): def test_partition():
fields = [
"partition_id",
"id",
"formsemestre_id",
"partition_name",
"numero",
"bul_show_rank",
"show_in_lists",
]
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/partitions/1", SCODOC_URL + "/ScoDoc/api/partitions/1",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
partition = r.json()[0]
fields_OK = verify_fields(partition, fields)
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 2
assert fields_OK is True
# etud_in_group # etud_in_group
def test_etud_in_group(): def test_etud_in_group():
fields = [
"etudid",
"id",
"dept_id",
"nom",
"prenom",
"nom_usuel",
"civilite",
"date_naissance",
"lieu_naissance",
"dept_naissance",
"nationalite",
"statut",
"boursier",
"photo_filename",
"code_nip",
"code_ine",
"scodoc7_id",
"email",
"emailperso",
"domicile",
"codepostaldomicile",
"villedomicile",
"paysdomicile",
"telephone",
"telephonemobile",
"fax",
"typeadresse",
"description",
"group_id",
"etat",
"civilite_str",
"nom_disp",
"nomprenom",
"ne",
"email_default",
]
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/partitions/groups/1", SCODOC_URL + "/ScoDoc/api/partitions/groups/1",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
etu = r.json()[0]
fields_OK = verify_fields(etu, fields)
assert r.status_code == 200 assert r.status_code == 200
r = requests.get( assert len(r.json()) == 16
SCODOC_URL + "/ScoDoc/api/partitions/groups/<int:group_id>/etat/<string:etat>", assert fields_OK is True
headers=HEADERS, # r = requests.get(
verify=CHECK_CERTIFICATE, # SCODOC_URL + "/ScoDoc/api/partitions/groups/1/etat/<string:etat>",
) # headers=HEADERS,
assert r.status_code == 200 # verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
# set_groups # # set_groups
def test_set_groups(): # def test_set_groups():
r = requests.get( # r = requests.get(
SCODOC_URL # SCODOC_URL
+ "/ScoDoc/api/partitions/set_groups?partition_id=<int:partition_id>&groups_lists=<int:groups_lists>&" # + "/partitions/set_groups/partition/<int:partition_id>/groups/<string:groups_id>"
"groups_to_create=<int:groups_to_create>&groups_to_delete=<int:groups_to_delete>", # "/delete/<string:groups_to_delete>/create/<string:groups_to_create>",
headers=HEADERS, # headers=HEADERS,
verify=CHECK_CERTIFICATE, # verify=CHECK_CERTIFICATE,
) # )
assert r.status_code == 200 # assert r.status_code == 200

View File

@ -0,0 +1,13 @@
def verify_fields(json_response, fields):
"""
Vérifie si les champs de la réponse json sont corrects
json_response : la réponse de la requête
fields : une liste avec l'ensemble des champs à vérifier
Retourne True ou False
"""
for field in json_response:
if field not in fields:
return False
return True