forked from ScoDoc/ScoDoc
API: evaluations, dept_acronym des étudiants, tests associés.
This commit is contained in:
parent
54d65c01ae
commit
457928522b
@ -4,6 +4,7 @@ from flask import jsonify
|
|||||||
import app
|
import app
|
||||||
|
|
||||||
from app import models
|
from app import models
|
||||||
|
from app.models import Evaluation
|
||||||
from app.api import bp
|
from app.api import bp
|
||||||
from app.api.auth import token_auth, token_permission_required
|
from app.api.auth import token_auth, token_permission_required
|
||||||
from app.api.errors import error_response
|
from app.api.errors import error_response
|
||||||
@ -46,7 +47,7 @@ def evaluations(moduleimpl_id: int):
|
|||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
# Récupération de toutes les évaluations
|
# Récupération de toutes les évaluations
|
||||||
evals = models.Evaluation.query.filter_by(id=moduleimpl_id)
|
evals = Evaluation.query.filter_by(id=moduleimpl_id)
|
||||||
|
|
||||||
# Mise en forme des données
|
# Mise en forme des données
|
||||||
data = [d.to_dict() for d in evals]
|
data = [d.to_dict() for d in evals]
|
||||||
|
@ -179,6 +179,7 @@ class Identite(db.Model):
|
|||||||
if self.date_naissance
|
if self.date_naissance
|
||||||
else "",
|
else "",
|
||||||
"dept_id": self.dept_id,
|
"dept_id": self.dept_id,
|
||||||
|
"dept_acronym": self.departement.acronym,
|
||||||
"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,
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from app import db
|
from app import db
|
||||||
from app.models import formsemestre
|
|
||||||
from app.models.formsemestre import FormSemestre
|
|
||||||
from app.models.moduleimpls import ModuleImpl
|
from app.models.moduleimpls import ModuleImpl
|
||||||
from app.models.ues import UniteEns
|
from app.models.ues import UniteEns
|
||||||
|
|
||||||
@ -54,7 +52,12 @@ class Evaluation(db.Model):
|
|||||||
# ScoDoc7 output_formators
|
# ScoDoc7 output_formators
|
||||||
e["evaluation_id"] = self.id
|
e["evaluation_id"] = self.id
|
||||||
e["jour"] = ndb.DateISOtoDMY(e["jour"])
|
e["jour"] = ndb.DateISOtoDMY(e["jour"])
|
||||||
|
e["date_debut"] = datetime.datetime.combine(
|
||||||
|
self.jour, self.heure_debut
|
||||||
|
).isoformat()
|
||||||
|
e["date_fin"] = datetime.datetime.combine(self.jour, self.heure_fin).isoformat()
|
||||||
e["numero"] = ndb.int_null_is_zero(e["numero"])
|
e["numero"] = ndb.int_null_is_zero(e["numero"])
|
||||||
|
e["poids"] = self.get_ue_poids_dict() # { ue_id : poids }
|
||||||
return evaluation_enrich_dict(e)
|
return evaluation_enrich_dict(e)
|
||||||
|
|
||||||
def from_dict(self, data):
|
def from_dict(self, data):
|
||||||
@ -153,7 +156,7 @@ class EvaluationUEPoids(db.Model):
|
|||||||
|
|
||||||
# Fonction héritée de ScoDoc7 à refactorer
|
# Fonction héritée de ScoDoc7 à refactorer
|
||||||
def evaluation_enrich_dict(e):
|
def evaluation_enrich_dict(e):
|
||||||
"""add or convert some fileds in an evaluation dict"""
|
"""add or convert some fields in an evaluation dict"""
|
||||||
# For ScoDoc7 compat
|
# For ScoDoc7 compat
|
||||||
heure_debut_dt = e["heure_debut"] or datetime.time(
|
heure_debut_dt = e["heure_debut"] or datetime.time(
|
||||||
8, 00
|
8, 00
|
||||||
|
@ -32,7 +32,7 @@ import time
|
|||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
|
|
||||||
from flask import g, request
|
from flask import g, request
|
||||||
from flask import url_for
|
from flask import abort, url_for
|
||||||
|
|
||||||
from app import log
|
from app import log
|
||||||
from app.but import bulletin_but
|
from app.but import bulletin_but
|
||||||
@ -83,6 +83,8 @@ def formsemestre_recapcomplet(
|
|||||||
force_publishing: publie les xml et json même si bulletins non publiés
|
force_publishing: publie les xml et json même si bulletins non publiés
|
||||||
selected_etudid: etudid sélectionné (pour scroller au bon endroit)
|
selected_etudid: etudid sélectionné (pour scroller au bon endroit)
|
||||||
"""
|
"""
|
||||||
|
if not isinstance(formsemestre_id, int):
|
||||||
|
abort(404)
|
||||||
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||||
file_formats = {"csv", "json", "xls", "xlsx", "xlsall", "xml"}
|
file_formats = {"csv", "json", "xls", "xlsx", "xlsall", "xml"}
|
||||||
supported_formats = file_formats | {"html", "evals"}
|
supported_formats = file_formats | {"html", "evals"}
|
||||||
|
@ -292,7 +292,7 @@ def formsemestre_bulletinetud(
|
|||||||
format = format or "html"
|
format = format or "html"
|
||||||
|
|
||||||
if not isinstance(formsemestre_id, int):
|
if not isinstance(formsemestre_id, int):
|
||||||
raise ValueError("formsemestre_id must be an integer !")
|
abort(404, description="formsemestre_id must be an integer !")
|
||||||
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||||
if etudid:
|
if etudid:
|
||||||
etud = models.Identite.query.get_or_404(etudid)
|
etud = models.Identite.query.get_or_404(etudid)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# -*- mode: python -*-
|
# -*- mode: python -*-
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
SCOVERSION = "9.2.20"
|
SCOVERSION = "9.2.21"
|
||||||
|
|
||||||
SCONAME = "ScoDoc"
|
SCONAME = "ScoDoc"
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ except NameError:
|
|||||||
|
|
||||||
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"] or "http://localhost:5000"
|
||||||
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_PASSWORD"]
|
SCODOC_PASSWORD = os.environ["SCODOC_PASSWORD"]
|
||||||
@ -110,6 +110,8 @@ print("\n".join([s["titre_num"] for s in sems]))
|
|||||||
sems = GET(f"/etudiant/nip/{code_nip}/formsemestres")
|
sems = GET(f"/etudiant/nip/{code_nip}/formsemestres")
|
||||||
print("\n".join([s["titre_num"] for s in sems]))
|
print("\n".join([s["titre_num"] for s in sems]))
|
||||||
|
|
||||||
|
# Evaluation
|
||||||
|
evals = GET("/evaluations/1")
|
||||||
|
|
||||||
# # --- 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 !")
|
||||||
|
@ -25,6 +25,7 @@ SCODOC_URL = os.environ["SCODOC_URL"]
|
|||||||
API_URL = SCODOC_URL + "/ScoDoc/api"
|
API_URL = SCODOC_URL + "/ScoDoc/api"
|
||||||
API_USER = os.environ.get("API_USER", "test")
|
API_USER = os.environ.get("API_USER", "test")
|
||||||
API_PASSWORD = os.environ.get("API_PASSWD", "test")
|
API_PASSWORD = os.environ.get("API_PASSWD", "test")
|
||||||
|
DEPT_ACRONYM = "TAPI"
|
||||||
print(f"SCODOC_URL={SCODOC_URL}")
|
print(f"SCODOC_URL={SCODOC_URL}")
|
||||||
print(f"API URL={API_URL}")
|
print(f"API URL={API_URL}")
|
||||||
|
|
||||||
|
@ -19,7 +19,12 @@ Utilisation :
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
|
from tests.api.setup_test_api import (
|
||||||
|
API_URL,
|
||||||
|
CHECK_CERTIFICATE,
|
||||||
|
DEPT_ACRONYM,
|
||||||
|
api_headers,
|
||||||
|
)
|
||||||
from tests.api.tools_test_api import verify_fields
|
from tests.api.tools_test_api import verify_fields
|
||||||
|
|
||||||
DEPARTEMENT_FIELDS = [
|
DEPARTEMENT_FIELDS = [
|
||||||
@ -86,7 +91,7 @@ def test_list_etudiants(api_headers):
|
|||||||
fields = {"id", "nip", "ine", "nom", "nom_usuel", "prenom", "civilite"}
|
fields = {"id", "nip", "ine", "nom", "nom_usuel", "prenom", "civilite"}
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
API_URL + "/departement/TAPI/etudiants",
|
f"{API_URL}/departement/{DEPT_ACRONYM}/etudiants",
|
||||||
headers=api_headers,
|
headers=api_headers,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
|
@ -19,7 +19,12 @@ Utilisation :
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
|
from tests.api.setup_test_api import (
|
||||||
|
API_URL,
|
||||||
|
CHECK_CERTIFICATE,
|
||||||
|
DEPT_ACRONYM,
|
||||||
|
api_headers,
|
||||||
|
)
|
||||||
from tests.api.tools_test_api import verify_fields
|
from tests.api.tools_test_api import verify_fields
|
||||||
from tests.api.tools_test_api import ETUD_FIELDS, FSEM_FIELDS
|
from tests.api.tools_test_api import ETUD_FIELDS, FSEM_FIELDS
|
||||||
|
|
||||||
@ -83,7 +88,7 @@ def test_etudiant(api_headers):
|
|||||||
etud = r.json()
|
etud = r.json()
|
||||||
fields_ok = verify_fields(etud, ETUD_FIELDS)
|
fields_ok = verify_fields(etud, ETUD_FIELDS)
|
||||||
assert fields_ok is True
|
assert fields_ok is True
|
||||||
|
assert etud["dept_acronym"] == DEPT_ACRONYM
|
||||||
######### Test code ine #########
|
######### Test code ine #########
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
|
@ -21,6 +21,8 @@ ETUD_FIELDS = {
|
|||||||
"code_nip",
|
"code_nip",
|
||||||
"codepostaldomicile",
|
"codepostaldomicile",
|
||||||
"date_naissance",
|
"date_naissance",
|
||||||
|
"dept_acronym",
|
||||||
|
"dept_id",
|
||||||
"dept_naissance",
|
"dept_naissance",
|
||||||
"description",
|
"description",
|
||||||
"domicile",
|
"domicile",
|
||||||
|
Loading…
Reference in New Issue
Block a user