2022-07-19 22:17:10 +02:00
|
|
|
|
##############################################################################
|
|
|
|
|
# ScoDoc
|
|
|
|
|
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
|
|
|
|
|
# See LICENSE
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
ScoDoc 9 API : accès aux évaluations
|
|
|
|
|
"""
|
|
|
|
|
|
2022-03-02 16:45:47 +01:00
|
|
|
|
from flask import jsonify
|
|
|
|
|
|
2022-04-26 15:26:20 +02:00
|
|
|
|
import app
|
|
|
|
|
|
2022-03-02 16:45:47 +01:00
|
|
|
|
from app import models
|
|
|
|
|
from app.api import bp
|
2022-07-22 16:39:21 +02:00
|
|
|
|
from app.api.auth import permission_required_api
|
2022-03-02 16:45:47 +01:00
|
|
|
|
from app.api.errors import error_response
|
2022-05-16 16:00:24 +02:00
|
|
|
|
from app.models import Evaluation
|
2022-03-02 16:45:47 +01:00
|
|
|
|
from app.scodoc.sco_evaluation_db import do_evaluation_get_all_notes
|
2022-03-04 17:16:08 +01:00
|
|
|
|
from app.scodoc.sco_permissions import Permission
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/evaluations/<int:moduleimpl_id>", methods=["GET"])
|
2022-07-22 16:39:21 +02:00
|
|
|
|
@permission_required_api(Permission.ScoView, Permission.APIView)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
def evaluations(moduleimpl_id: int):
|
|
|
|
|
"""
|
2022-07-19 22:17:10 +02:00
|
|
|
|
Retourne la liste des évaluations d'un moduleimpl
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
|
moduleimpl_id : l'id d'un moduleimpl
|
2022-04-26 15:26:20 +02:00
|
|
|
|
|
|
|
|
|
Exemple de résultat :
|
2022-04-27 14:11:06 +02:00
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
"moduleimpl_id": 1,
|
|
|
|
|
"jour": "20/04/2022",
|
|
|
|
|
"heure_debut": "08h00",
|
|
|
|
|
"description": "eval1",
|
|
|
|
|
"coefficient": 1.0,
|
|
|
|
|
"publish_incomplete": false,
|
|
|
|
|
"numero": 0,
|
|
|
|
|
"id": 1,
|
|
|
|
|
"heure_fin": "09h00",
|
|
|
|
|
"note_max": 20.0,
|
|
|
|
|
"visibulletin": true,
|
|
|
|
|
"evaluation_type": 0,
|
|
|
|
|
"evaluation_id": 1,
|
|
|
|
|
"jouriso": "2022-04-20",
|
|
|
|
|
"duree": "1h",
|
2022-07-19 22:17:10 +02:00
|
|
|
|
"descrheure": " de 08h00 à 09h00",
|
2022-04-27 14:11:06 +02:00
|
|
|
|
"matin": 1,
|
|
|
|
|
"apresmidi": 0
|
|
|
|
|
},
|
|
|
|
|
...
|
|
|
|
|
]
|
2022-03-02 16:45:47 +01:00
|
|
|
|
"""
|
|
|
|
|
# Récupération de toutes les évaluations
|
2022-05-16 16:00:24 +02:00
|
|
|
|
evals = Evaluation.query.filter_by(id=moduleimpl_id)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
|
# Mise en forme des données
|
|
|
|
|
data = [d.to_dict() for d in evals]
|
|
|
|
|
|
|
|
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
|
@bp.route("/evaluation/eval_notes/<int:evaluation_id>", methods=["GET"])
|
2022-07-22 16:39:21 +02:00
|
|
|
|
@permission_required_api(Permission.ScoView, Permission.APIView)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
def evaluation_notes(evaluation_id: int):
|
|
|
|
|
"""
|
|
|
|
|
Retourne la liste des notes à partir de l'id d'une évaluation donnée
|
|
|
|
|
|
|
|
|
|
evaluation_id : l'id d'une évaluation
|
2022-04-26 15:26:20 +02:00
|
|
|
|
|
|
|
|
|
Exemple de résultat :
|
2022-04-28 16:12:15 +02:00
|
|
|
|
{
|
|
|
|
|
"1": {
|
|
|
|
|
"id": 1,
|
|
|
|
|
"etudid": 10,
|
|
|
|
|
"evaluation_id": 1,
|
|
|
|
|
"value": 15.0,
|
|
|
|
|
"comment": "",
|
|
|
|
|
"date": "Wed, 20 Apr 2022 06:49:05 GMT",
|
|
|
|
|
"uid": 2
|
|
|
|
|
},
|
|
|
|
|
"2": {
|
|
|
|
|
"id": 2,
|
|
|
|
|
"etudid": 1,
|
|
|
|
|
"evaluation_id": 1,
|
|
|
|
|
"value": 12.0,
|
|
|
|
|
"comment": "",
|
|
|
|
|
"date": "Wed, 20 Apr 2022 06:49:06 GMT",
|
|
|
|
|
"uid": 2
|
|
|
|
|
},
|
|
|
|
|
...
|
|
|
|
|
}
|
2022-03-02 16:45:47 +01:00
|
|
|
|
"""
|
2022-05-03 13:35:17 +02:00
|
|
|
|
evaluation = models.Evaluation.query.filter_by(id=evaluation_id).first_or_404()
|
2022-07-19 22:17:10 +02:00
|
|
|
|
dept = evaluation.moduleimpl.formsemestre.departement
|
2022-04-26 15:26:20 +02:00
|
|
|
|
app.set_sco_dept(dept.acronym)
|
|
|
|
|
|
2022-03-02 16:45:47 +01:00
|
|
|
|
try:
|
|
|
|
|
data = do_evaluation_get_all_notes(evaluation_id)
|
2022-05-03 13:35:17 +02:00
|
|
|
|
except AttributeError: # ???
|
2022-04-25 15:25:45 +02:00
|
|
|
|
return error_response(
|
2022-05-09 16:26:23 +02:00
|
|
|
|
404,
|
2022-05-03 13:35:17 +02:00
|
|
|
|
message="La requête ne peut être traitée en l’état actuel.",
|
2022-04-25 15:25:45 +02:00
|
|
|
|
)
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
|
return jsonify(data)
|