2021-11-12 22:17:46 +01:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2023-12-31 23:04:06 +01:00
|
|
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
2021-11-12 22:17:46 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# Emmanuel Viennet emmanuel.viennet@gmail.com
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Formulaire ajout/édition d'une évaluation
|
|
|
|
"""
|
2023-08-25 17:58:57 +02:00
|
|
|
import datetime
|
2021-11-12 22:17:46 +01:00
|
|
|
import time
|
|
|
|
|
|
|
|
import flask
|
2024-02-26 17:20:36 +01:00
|
|
|
from flask import g, render_template, request, url_for
|
2021-11-12 22:17:46 +01:00
|
|
|
from flask_login import current_user
|
|
|
|
|
|
|
|
from app import db
|
2024-02-04 12:00:26 +01:00
|
|
|
from app.models import Evaluation, Module, ModuleImpl
|
2024-02-26 17:20:36 +01:00
|
|
|
from app.models.evaluations import heure_to_time, check_and_convert_evaluation_args
|
2023-07-11 06:57:38 +02:00
|
|
|
|
2021-11-12 22:17:46 +01:00
|
|
|
import app.scodoc.sco_utils as scu
|
|
|
|
from app.scodoc.sco_utils import ModuleType
|
2022-10-02 20:15:56 +02:00
|
|
|
from app.scodoc.sco_exceptions import ScoValueError
|
2021-11-12 22:17:46 +01:00
|
|
|
from app.scodoc.TrivialFormulator import TrivialFormulator
|
2023-11-14 22:48:28 +01:00
|
|
|
from app.scodoc import sco_cache
|
2021-11-12 22:17:46 +01:00
|
|
|
from app.scodoc import sco_evaluations
|
2022-10-02 20:15:56 +02:00
|
|
|
from app.scodoc import sco_preferences
|
2021-11-12 22:17:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
def evaluation_create_form(
|
|
|
|
moduleimpl_id=None,
|
|
|
|
evaluation_id=None,
|
|
|
|
edit=False,
|
|
|
|
page_title="Évaluation",
|
|
|
|
):
|
|
|
|
"Formulaire création/édition d'une évaluation (pas de ses notes)"
|
2024-02-04 12:00:26 +01:00
|
|
|
evaluation: Evaluation
|
2021-11-12 22:17:46 +01:00
|
|
|
if evaluation_id is not None:
|
2024-02-04 12:00:26 +01:00
|
|
|
evaluation = db.session.get(Evaluation, evaluation_id)
|
2022-08-25 12:47:57 +02:00
|
|
|
if evaluation is None:
|
|
|
|
raise ScoValueError("Cette évaluation n'existe pas ou plus !")
|
2021-11-12 22:17:46 +01:00
|
|
|
moduleimpl_id = evaluation.moduleimpl_id
|
|
|
|
#
|
2024-02-04 12:00:26 +01:00
|
|
|
modimpl = ModuleImpl.get_modimpl(moduleimpl_id)
|
|
|
|
formsemestre_id = modimpl.formsemestre_id
|
2023-03-20 11:17:38 +01:00
|
|
|
formsemestre = modimpl.formsemestre
|
2024-02-04 12:00:26 +01:00
|
|
|
module: Module = modimpl.module
|
2023-04-03 17:46:31 +02:00
|
|
|
sem_ues = formsemestre.get_ues(with_sport=False)
|
2024-02-04 12:00:26 +01:00
|
|
|
is_malus = module.module_type == ModuleType.MALUS
|
|
|
|
is_apc = module.module_type in (ModuleType.RESSOURCE, ModuleType.SAE)
|
2022-10-02 20:15:56 +02:00
|
|
|
preferences = sco_preferences.SemPreferences(formsemestre.id)
|
|
|
|
can_edit_poids = not preferences["but_disable_edit_poids_evaluations"]
|
2021-11-12 22:17:46 +01:00
|
|
|
min_note_max = scu.NOTES_PRECISION # le plus petit bareme possible
|
|
|
|
#
|
2023-08-22 17:02:00 +02:00
|
|
|
if not modimpl.can_edit_evaluation(current_user):
|
2024-08-24 18:26:51 +02:00
|
|
|
return render_template(
|
|
|
|
"sco_page.j2",
|
|
|
|
title="Opération non autorisée",
|
|
|
|
content=f"""
|
2022-10-02 20:15:56 +02:00
|
|
|
<h2>Opération non autorisée</h2>
|
|
|
|
<p>Modification évaluation impossible pour {current_user.get_nomplogin()}</p>
|
2023-11-14 22:48:28 +01:00
|
|
|
<p><a href="{url_for('notes.moduleimpl_status',
|
2022-10-02 20:15:56 +02:00
|
|
|
scodoc_dept=g.scodoc_dept, moduleimpl_id=moduleimpl_id)
|
|
|
|
}" class="stdlink">Revenir</a>
|
|
|
|
</p>
|
2024-08-24 18:26:51 +02:00
|
|
|
""",
|
|
|
|
)
|
2021-11-12 22:17:46 +01:00
|
|
|
if not edit:
|
2021-12-04 22:41:06 +01:00
|
|
|
# création nouvel
|
2021-11-12 22:17:46 +01:00
|
|
|
if moduleimpl_id is None:
|
|
|
|
raise ValueError("missing moduleimpl_id parameter")
|
2024-02-05 08:46:21 +01:00
|
|
|
numeros = [(e.numero or 0) for e in modimpl.evaluations]
|
2021-11-12 22:17:46 +01:00
|
|
|
initvalues = {
|
2024-04-02 23:37:23 +02:00
|
|
|
"jour": time.strftime(scu.DATE_FMT, time.localtime()),
|
2024-02-04 12:00:26 +01:00
|
|
|
"note_max": 20,
|
2024-02-05 08:46:21 +01:00
|
|
|
"numero": (max(numeros) + 1) if numeros else 0,
|
2021-11-12 22:17:46 +01:00
|
|
|
"publish_incomplete": is_malus,
|
2023-10-18 14:49:57 +02:00
|
|
|
"visibulletin": 1,
|
2021-11-12 22:17:46 +01:00
|
|
|
}
|
|
|
|
submitlabel = "Créer cette évaluation"
|
|
|
|
action = "Création d'une évaluation"
|
|
|
|
link = ""
|
|
|
|
else:
|
|
|
|
# édition données existantes
|
|
|
|
# setup form init values
|
|
|
|
if evaluation_id is None:
|
|
|
|
raise ValueError("missing evaluation_id parameter")
|
|
|
|
initvalues = evaluation.to_dict()
|
|
|
|
moduleimpl_id = initvalues["moduleimpl_id"]
|
2024-02-25 16:58:59 +01:00
|
|
|
submitlabel = "Modifier l'évaluation"
|
2021-11-12 22:17:46 +01:00
|
|
|
action = "Modification d'une évaluation"
|
|
|
|
link = ""
|
|
|
|
# Note maximale actuelle dans cette éval ?
|
|
|
|
etat = sco_evaluations.do_evaluation_etat(evaluation_id)
|
|
|
|
if etat["maxi_num"] is not None:
|
|
|
|
min_note_max = max(scu.NOTES_PRECISION, etat["maxi_num"])
|
|
|
|
else:
|
|
|
|
min_note_max = scu.NOTES_PRECISION
|
|
|
|
#
|
|
|
|
if min_note_max > scu.NOTES_PRECISION:
|
|
|
|
min_note_max_str = scu.fmt_note(min_note_max)
|
|
|
|
else:
|
|
|
|
min_note_max_str = "0"
|
|
|
|
|
2022-02-10 21:09:45 +01:00
|
|
|
initvalues["coefficient"] = initvalues.get("coefficient", 1.0)
|
2021-11-12 22:17:46 +01:00
|
|
|
vals = scu.get_request_args()
|
|
|
|
#
|
2022-10-05 10:31:25 +02:00
|
|
|
ue_coef_dict = modimpl.module.get_ue_coef_dict()
|
2021-11-12 22:17:46 +01:00
|
|
|
if is_apc: # BUT: poids vers les UE
|
2022-10-05 10:31:25 +02:00
|
|
|
if edit:
|
|
|
|
if evaluation.set_default_poids():
|
|
|
|
db.session.commit()
|
|
|
|
ue_poids_dict = evaluation.get_ue_poids_dict()
|
|
|
|
for ue in sem_ues:
|
|
|
|
initvalues[f"poids_{ue.id}"] = ue_poids_dict[ue.id]
|
|
|
|
else:
|
|
|
|
for ue in sem_ues:
|
2021-12-08 23:42:19 +01:00
|
|
|
coef_ue = ue_coef_dict.get(ue.id, 0.0) or 0.0
|
|
|
|
if coef_ue > 0:
|
2022-02-10 21:09:45 +01:00
|
|
|
poids = 1.0 # par défaut au départ
|
2021-12-08 23:42:19 +01:00
|
|
|
else:
|
|
|
|
poids = 0.0
|
2022-10-05 10:31:25 +02:00
|
|
|
initvalues[f"poids_{ue.id}"] = poids
|
2024-02-25 16:58:59 +01:00
|
|
|
# Blocage
|
|
|
|
if edit:
|
|
|
|
initvalues["blocked"] = evaluation.is_blocked()
|
|
|
|
initvalues["blocked_until"] = (
|
2024-04-02 23:37:23 +02:00
|
|
|
evaluation.blocked_until.strftime(scu.DATE_FMT)
|
2024-02-25 16:58:59 +01:00
|
|
|
if evaluation.blocked_until
|
|
|
|
and evaluation.blocked_until < Evaluation.BLOCKED_FOREVER
|
|
|
|
else ""
|
|
|
|
)
|
2021-11-12 22:17:46 +01:00
|
|
|
#
|
|
|
|
form = [
|
|
|
|
("evaluation_id", {"default": evaluation_id, "input_type": "hidden"}),
|
|
|
|
("formsemestre_id", {"default": formsemestre_id, "input_type": "hidden"}),
|
|
|
|
("moduleimpl_id", {"default": moduleimpl_id, "input_type": "hidden"}),
|
2024-02-04 12:00:26 +01:00
|
|
|
("numero", {"default": initvalues["numero"], "input_type": "hidden"}),
|
2021-11-12 22:17:46 +01:00
|
|
|
(
|
|
|
|
"jour",
|
|
|
|
{
|
2022-01-10 12:00:02 +01:00
|
|
|
"input_type": "datedmy",
|
2021-11-12 22:17:46 +01:00
|
|
|
"title": "Date",
|
|
|
|
"size": 12,
|
|
|
|
"explanation": "date de l'examen, devoir ou contrôle",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"heure_debut",
|
|
|
|
{
|
|
|
|
"title": "Heure de début",
|
|
|
|
"explanation": "heure du début de l'épreuve",
|
2024-01-16 12:36:20 +01:00
|
|
|
"input_type": "time",
|
2021-11-12 22:17:46 +01:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"heure_fin",
|
|
|
|
{
|
|
|
|
"title": "Heure de fin",
|
|
|
|
"explanation": "heure de fin de l'épreuve",
|
2024-01-16 12:36:20 +01:00
|
|
|
"input_type": "time",
|
2021-11-12 22:17:46 +01:00
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
if is_malus: # pas de coefficient
|
|
|
|
form.append(("coefficient", {"input_type": "hidden", "default": "1."}))
|
|
|
|
elif not is_apc: # modules standard hors BUT
|
|
|
|
form.append(
|
|
|
|
(
|
|
|
|
"coefficient",
|
|
|
|
{
|
|
|
|
"size": 6,
|
2022-08-29 15:23:44 +02:00
|
|
|
"type": "float", # peut être négatif (!)
|
2024-02-24 16:49:41 +01:00
|
|
|
"explanation": """coef. dans le module (choisi librement par
|
|
|
|
l'enseignant, non utilisé pour rattrapage, 2ème session et bonus)""",
|
2021-11-12 22:17:46 +01:00
|
|
|
"allow_null": False,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
form += [
|
|
|
|
(
|
|
|
|
"note_max",
|
|
|
|
{
|
|
|
|
"size": 4,
|
|
|
|
"type": "float",
|
|
|
|
"title": "Notes de 0 à",
|
2024-02-24 16:49:41 +01:00
|
|
|
"explanation": f"""barème (note max actuelle: {min_note_max_str}).""",
|
2021-11-12 22:17:46 +01:00
|
|
|
"allow_null": False,
|
|
|
|
"max_value": scu.NOTES_MAX,
|
|
|
|
"min_value": min_note_max,
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"description",
|
|
|
|
{
|
|
|
|
"size": 36,
|
|
|
|
"type": "text",
|
2024-02-24 16:49:41 +01:00
|
|
|
"explanation": """type d'évaluation, apparait sur le bulletins longs.
|
|
|
|
Exemples: "contrôle court", "examen de TP", "examen final".""",
|
2021-11-12 22:17:46 +01:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
2023-08-25 17:58:57 +02:00
|
|
|
"visibulletin",
|
2021-11-12 22:17:46 +01:00
|
|
|
{
|
2023-08-25 17:58:57 +02:00
|
|
|
"input_type": "boolcheckbox",
|
2021-11-12 22:17:46 +01:00
|
|
|
"title": "Visible sur bulletins",
|
2023-10-18 14:49:57 +02:00
|
|
|
"explanation": "(pour les bulletins en version intermédiaire/passerelle)",
|
2021-11-12 22:17:46 +01:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"publish_incomplete",
|
|
|
|
{
|
|
|
|
"input_type": "boolcheckbox",
|
|
|
|
"title": "Prise en compte immédiate",
|
2024-03-29 16:36:05 +01:00
|
|
|
"explanation": """notes utilisées même si incomplètes (dangereux,
|
|
|
|
à n'utiliser que dans des cas particuliers
|
|
|
|
<a target="_blank" rel="noopener noreferrer"
|
|
|
|
href="https://scodoc.org/Evaluation/#pourquoi-eviter-dutiliser-prise-en-compte-immediate"
|
|
|
|
>voir la documentation</a>
|
|
|
|
)
|
|
|
|
""",
|
2021-11-12 22:17:46 +01:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"evaluation_type",
|
|
|
|
{
|
|
|
|
"input_type": "menu",
|
|
|
|
"title": "Modalité",
|
2024-02-24 16:49:41 +01:00
|
|
|
"allowed_values": Evaluation.VALID_EVALUATION_TYPES,
|
2021-11-12 22:17:46 +01:00
|
|
|
"type": "int",
|
|
|
|
"labels": (
|
|
|
|
"Normale",
|
|
|
|
"Rattrapage (remplace si meilleure note)",
|
|
|
|
"Deuxième session (remplace toujours)",
|
2024-02-24 16:49:41 +01:00
|
|
|
(
|
|
|
|
"Bonus "
|
|
|
|
+ (
|
|
|
|
"(pondéré par poids et ajouté aux moyennes de ce module)"
|
|
|
|
if is_apc
|
2024-06-24 16:48:13 +02:00
|
|
|
else "(ajouté à la moyenne de ce module, différent du bonus sport !)"
|
2024-02-24 16:49:41 +01:00
|
|
|
)
|
|
|
|
),
|
2021-11-12 22:17:46 +01:00
|
|
|
),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
if is_apc: # ressources et SAÉs
|
|
|
|
form += [
|
|
|
|
(
|
|
|
|
"coefficient",
|
|
|
|
{
|
|
|
|
"size": 6,
|
|
|
|
"type": "float",
|
2024-02-24 16:49:41 +01:00
|
|
|
"explanation": """importance de l'évaluation (multiplie les poids ci-dessous).
|
|
|
|
Non utilisé pour les bonus.""",
|
2021-11-12 22:17:46 +01:00
|
|
|
"allow_null": False,
|
2024-02-25 16:58:59 +01:00
|
|
|
"dom_id": "evaluation-edit-coef",
|
2021-11-12 22:17:46 +01:00
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
# Liste des UE utilisées dans des modules de ce semestre:
|
2023-01-04 00:11:01 +01:00
|
|
|
if sem_ues and not can_edit_poids:
|
|
|
|
form.append(
|
|
|
|
(
|
|
|
|
"sep_poids",
|
|
|
|
{
|
|
|
|
"input_type": "separator",
|
|
|
|
"title": """
|
|
|
|
<div class="warning-light">les poids ne sont pas modifiables (voir réglage paramétrage)
|
|
|
|
</div>""",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
2021-11-12 22:17:46 +01:00
|
|
|
for ue in sem_ues:
|
2022-02-10 21:09:45 +01:00
|
|
|
coef_ue = ue_coef_dict.get(ue.id, 0.0)
|
2021-11-12 22:17:46 +01:00
|
|
|
form.append(
|
|
|
|
(
|
|
|
|
f"poids_{ue.id}",
|
|
|
|
{
|
|
|
|
"title": f"Poids {ue.acronyme}",
|
|
|
|
"size": 2,
|
|
|
|
"type": "float",
|
2022-01-20 13:00:25 +01:00
|
|
|
"explanation": f"""
|
2022-10-02 20:15:56 +02:00
|
|
|
<span class="eval_coef_ue" title="coef. du module dans cette UE">({
|
2023-11-14 22:48:28 +01:00
|
|
|
"coef. mod.:" +str(coef_ue) if coef_ue
|
2022-10-02 20:15:56 +02:00
|
|
|
else "ce module n'a pas de coef. dans cette UE"
|
|
|
|
})</span>
|
2024-02-13 13:55:16 +01:00
|
|
|
<span class="eval_coef_ue_titre">{ue.titre or ''}</span>
|
2022-01-20 13:00:25 +01:00
|
|
|
""",
|
2021-11-12 22:17:46 +01:00
|
|
|
"allow_null": False,
|
2022-02-10 21:09:45 +01:00
|
|
|
# ok si poids nul ou coef vers l'UE nul:
|
|
|
|
"validator": lambda val, field: (not val)
|
|
|
|
or ue_coef_dict.get(int(field[len("poids_") :]), 0.0) != 0,
|
2022-10-02 20:15:56 +02:00
|
|
|
"enabled": (coef_ue != 0 or initvalues[f"poids_{ue.id}"] != 0.0)
|
|
|
|
and can_edit_poids,
|
2021-11-12 22:17:46 +01:00
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
2024-02-25 16:58:59 +01:00
|
|
|
# Bloquage / date prise en compte
|
|
|
|
form += [
|
|
|
|
(
|
|
|
|
"blocked",
|
|
|
|
{
|
|
|
|
"input_type": "boolcheckbox",
|
|
|
|
"title": "Bloquer la prise en compte",
|
|
|
|
"explanation": """empêche la prise en compte
|
|
|
|
(ne sera pas visible sur les bulletins ni dans les tableaux)""",
|
|
|
|
"dom_id": "evaluation-edit-blocked",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"blocked_until",
|
|
|
|
{
|
|
|
|
"input_type": "datedmy",
|
|
|
|
"title": "Date déblocage",
|
|
|
|
"size": 12,
|
|
|
|
"explanation": "sera débloquée à partir de cette date",
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]
|
2021-11-12 22:17:46 +01:00
|
|
|
tf = TrivialFormulator(
|
|
|
|
request.base_url,
|
|
|
|
vals,
|
|
|
|
form,
|
|
|
|
cancelbutton="Annuler",
|
|
|
|
submitlabel=submitlabel,
|
|
|
|
initvalues=initvalues,
|
|
|
|
readonly=False,
|
|
|
|
)
|
|
|
|
|
2022-10-05 10:31:25 +02:00
|
|
|
dest_url = url_for(
|
|
|
|
"notes.moduleimpl_status", scodoc_dept=g.scodoc_dept, moduleimpl_id=modimpl.id
|
|
|
|
)
|
2024-02-04 12:00:26 +01:00
|
|
|
H = [
|
|
|
|
f"""<h3>{action} en
|
|
|
|
{scu.MODULE_TYPE_NAMES[module.module_type]} <a class="stdlink" href="{
|
|
|
|
url_for("notes.moduleimpl_status",
|
|
|
|
scodoc_dept=g.scodoc_dept, moduleimpl_id=moduleimpl_id)
|
|
|
|
}">{module.code or "module sans code"} {
|
|
|
|
module.titre or module.abbrev or "(sans titre)"
|
|
|
|
}</a> {link}</h3>
|
|
|
|
"""
|
|
|
|
]
|
2021-11-12 22:17:46 +01:00
|
|
|
if tf[0] == 0:
|
2024-08-24 18:26:51 +02:00
|
|
|
return render_template(
|
|
|
|
"sco_page.j2",
|
|
|
|
title=page_title,
|
|
|
|
content=(
|
|
|
|
"\n".join(H)
|
|
|
|
+ "\n"
|
|
|
|
+ tf[1]
|
|
|
|
+ render_template(
|
|
|
|
"scodoc/forms/evaluation_edit.j2",
|
|
|
|
)
|
|
|
|
+ render_template(
|
|
|
|
"scodoc/help/evaluations.j2", is_apc=is_apc, modimpl=modimpl
|
|
|
|
)
|
|
|
|
+ render_template("sco_timepicker.j2")
|
|
|
|
),
|
2021-11-12 22:17:46 +01:00
|
|
|
)
|
|
|
|
elif tf[0] == -1:
|
|
|
|
return flask.redirect(dest_url)
|
|
|
|
else:
|
|
|
|
# form submission
|
2023-08-25 17:58:57 +02:00
|
|
|
args = tf[2]
|
|
|
|
# modifie le codage des dates
|
|
|
|
# (nb: ce formulaire ne permet de créer que des évaluation sur la même journée)
|
2024-03-24 09:17:01 +01:00
|
|
|
date_debut = scu.convert_fr_date(args["jour"]) if args.get("jour") else None
|
2024-02-26 17:20:36 +01:00
|
|
|
args["date_debut"] = date_debut
|
|
|
|
args["date_fin"] = date_debut # même jour
|
2023-08-25 17:58:57 +02:00
|
|
|
args.pop("jour", None)
|
2023-08-28 12:03:55 +02:00
|
|
|
if date_debut and args.get("heure_debut"):
|
2023-08-25 17:58:57 +02:00
|
|
|
try:
|
|
|
|
heure_debut = heure_to_time(args["heure_debut"])
|
|
|
|
except ValueError as exc:
|
|
|
|
raise ScoValueError("Heure début invalide") from exc
|
|
|
|
args["date_debut"] = datetime.datetime.combine(date_debut, heure_debut)
|
|
|
|
args.pop("heure_debut", None)
|
2024-02-25 16:58:59 +01:00
|
|
|
# note: ce formulaire ne permet de créer que des évaluations
|
|
|
|
# avec debut et fin sur le même jour.
|
2023-08-28 12:03:55 +02:00
|
|
|
if date_debut and args.get("heure_fin"):
|
2023-08-25 17:58:57 +02:00
|
|
|
try:
|
|
|
|
heure_fin = heure_to_time(args["heure_fin"])
|
|
|
|
except ValueError as exc:
|
|
|
|
raise ScoValueError("Heure fin invalide") from exc
|
|
|
|
args["date_fin"] = datetime.datetime.combine(date_debut, heure_fin)
|
|
|
|
args.pop("heure_fin", None)
|
2024-02-25 16:58:59 +01:00
|
|
|
# Blocage:
|
|
|
|
if args.get("blocked"):
|
|
|
|
if args.get("blocked_until"):
|
|
|
|
try:
|
|
|
|
args["blocked_until"] = datetime.datetime.strptime(
|
2024-04-02 23:37:23 +02:00
|
|
|
args["blocked_until"], scu.DATE_FMT
|
2024-02-25 16:58:59 +01:00
|
|
|
)
|
|
|
|
except ValueError as exc:
|
|
|
|
raise ScoValueError("Date déblocage (j/m/a) invalide") from exc
|
|
|
|
else: # bloquage coché sans date
|
|
|
|
args["blocked_until"] = Evaluation.BLOCKED_FOREVER
|
|
|
|
else: # si pas coché, efface date déblocage
|
|
|
|
args["blocked_until"] = None
|
2023-08-25 17:58:57 +02:00
|
|
|
#
|
2021-11-12 22:17:46 +01:00
|
|
|
if edit:
|
2024-02-26 17:20:36 +01:00
|
|
|
check_and_convert_evaluation_args(args, modimpl)
|
2023-08-25 17:58:57 +02:00
|
|
|
evaluation.from_dict(args)
|
2021-11-12 22:17:46 +01:00
|
|
|
else:
|
2023-08-22 17:02:00 +02:00
|
|
|
# création d'une evaluation
|
2023-08-25 17:58:57 +02:00
|
|
|
evaluation = Evaluation.create(moduleimpl=modimpl, **args)
|
2023-08-22 17:02:00 +02:00
|
|
|
db.session.add(evaluation)
|
|
|
|
db.session.commit()
|
|
|
|
evaluation_id = evaluation.id
|
2021-11-18 23:54:50 +01:00
|
|
|
if is_apc:
|
|
|
|
# Set poids
|
2023-07-11 06:57:38 +02:00
|
|
|
evaluation = db.session.get(Evaluation, evaluation_id)
|
2021-11-18 23:54:50 +01:00
|
|
|
for ue in sem_ues:
|
|
|
|
evaluation.set_ue_poids(ue, tf[2][f"poids_{ue.id}"])
|
2023-08-25 17:58:57 +02:00
|
|
|
db.session.add(evaluation)
|
|
|
|
db.session.commit()
|
2023-11-14 22:48:28 +01:00
|
|
|
sco_cache.invalidate_formsemestre(evaluation.moduleimpl.formsemestre.id)
|
2021-11-12 22:17:46 +01:00
|
|
|
return flask.redirect(dest_url)
|