2022-07-19 22:17:10 +02:00
|
|
|
##############################################################################
|
|
|
|
# ScoDoc
|
2023-01-02 13:16:27 +01:00
|
|
|
# Copyright (c) 1999 - 2023 Emmanuel Viennet. All rights reserved.
|
2022-07-19 22:17:10 +02:00
|
|
|
# See LICENSE
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""
|
|
|
|
ScoDoc 9 API : accès aux évaluations
|
|
|
|
"""
|
|
|
|
|
2022-07-27 16:03:14 +02:00
|
|
|
from flask import g, jsonify
|
|
|
|
from flask_login import login_required
|
2022-03-02 16:45:47 +01:00
|
|
|
|
2022-04-26 15:26:20 +02:00
|
|
|
import app
|
|
|
|
|
2022-07-27 16:03:14 +02:00
|
|
|
from app.api import api_bp as bp, api_web_bp
|
|
|
|
from app.decorators import scodoc, permission_required
|
2022-08-07 19:56:25 +02:00
|
|
|
from app.scodoc.sco_utils import json_error
|
2022-07-27 16:03:14 +02:00
|
|
|
from app.models import Evaluation, ModuleImpl, FormSemestre
|
2022-08-03 16:05:01 +02:00
|
|
|
from app.scodoc import sco_evaluation_db
|
2022-03-04 17:16:08 +01:00
|
|
|
from app.scodoc.sco_permissions import Permission
|
2022-08-03 16:05:01 +02:00
|
|
|
import app.scodoc.sco_utils as scu
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
2022-11-01 11:19:28 +01:00
|
|
|
@bp.route("/evaluation/<int:evaluation_id>")
|
|
|
|
@api_web_bp.route("/evaluation/<int:evaluation_id>")
|
|
|
|
@login_required
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def evaluation(evaluation_id: int):
|
|
|
|
"""Description d'une évaluation.
|
|
|
|
|
|
|
|
{
|
|
|
|
'coefficient': 1.0,
|
|
|
|
'date_debut': '2016-01-04T08:30:00',
|
|
|
|
'date_fin': '2016-01-04T12:30:00',
|
|
|
|
'description': 'TP NI9219 Température',
|
|
|
|
'evaluation_type': 0,
|
|
|
|
'id': 15797,
|
|
|
|
'moduleimpl_id': 1234,
|
|
|
|
'note_max': 20.0,
|
|
|
|
'numero': 3,
|
|
|
|
'poids': {
|
|
|
|
'UE1.1': 1.0,
|
|
|
|
'UE1.2': 1.0,
|
|
|
|
'UE1.3': 1.0
|
|
|
|
},
|
|
|
|
'publish_incomplete': False,
|
|
|
|
'visi_bulletin': True
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
query = Evaluation.query.filter_by(id=evaluation_id)
|
|
|
|
if g.scodoc_dept:
|
|
|
|
query = (
|
|
|
|
query.join(ModuleImpl)
|
|
|
|
.join(FormSemestre)
|
|
|
|
.filter_by(dept_id=g.scodoc_dept_id)
|
|
|
|
)
|
|
|
|
e = query.first_or_404()
|
|
|
|
return jsonify(e.to_dict_api())
|
|
|
|
|
|
|
|
|
2022-07-30 08:23:22 +02:00
|
|
|
@bp.route("/moduleimpl/<int:moduleimpl_id>/evaluations")
|
|
|
|
@api_web_bp.route("/moduleimpl/<int:moduleimpl_id>/evaluations")
|
2022-07-27 16:03:14 +02:00
|
|
|
@login_required
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
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
|
|
|
|
2022-11-01 11:19:28 +01:00
|
|
|
Exemple de résultat : voir /evaluation
|
2022-03-02 16:45:47 +01:00
|
|
|
"""
|
2022-11-01 11:19:28 +01:00
|
|
|
query = Evaluation.query.filter_by(moduleimpl_id=moduleimpl_id)
|
2022-07-27 16:03:14 +02:00
|
|
|
if g.scodoc_dept:
|
|
|
|
query = (
|
|
|
|
query.join(ModuleImpl)
|
|
|
|
.join(FormSemestre)
|
|
|
|
.filter_by(dept_id=g.scodoc_dept_id)
|
|
|
|
)
|
2022-11-01 11:19:28 +01:00
|
|
|
return jsonify([e.to_dict_api() for e in query])
|
2022-03-02 16:45:47 +01:00
|
|
|
|
|
|
|
|
2022-07-27 16:03:14 +02:00
|
|
|
@bp.route("/evaluation/<int:evaluation_id>/notes")
|
|
|
|
@api_web_bp.route("/evaluation/<int:evaluation_id>/notes")
|
|
|
|
@login_required
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
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-07-27 16:03:14 +02:00
|
|
|
query = Evaluation.query.filter_by(id=evaluation_id)
|
|
|
|
if g.scodoc_dept:
|
|
|
|
query = (
|
|
|
|
query.join(ModuleImpl)
|
|
|
|
.join(FormSemestre)
|
|
|
|
.filter_by(dept_id=g.scodoc_dept_id)
|
|
|
|
)
|
|
|
|
|
|
|
|
evaluation = query.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-08-03 16:05:01 +02:00
|
|
|
notes = sco_evaluation_db.do_evaluation_get_all_notes(evaluation_id)
|
|
|
|
for etudid in notes:
|
|
|
|
# "ABS", "EXC", etc mais laisse les notes sur le barème de l'éval.
|
|
|
|
note = notes[etudid]
|
|
|
|
note["value"] = scu.fmt_note(note["value"], keep_numeric=True)
|
|
|
|
note["note_max"] = evaluation.note_max
|
|
|
|
del note["id"]
|
2022-03-02 16:45:47 +01:00
|
|
|
|
2022-08-03 16:05:01 +02:00
|
|
|
return jsonify(notes)
|