2021-11-17 10:28:51 +01:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# ScoDoc
|
|
|
|
#
|
2023-01-02 13:16:27 +01:00
|
|
|
# Copyright (c) 1999 - 2023 Emmanuel Viennet. All rights reserved.
|
2021-11-17 10:28:51 +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@viennet.net
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""Édition formation APC (BUT)
|
|
|
|
"""
|
2022-10-31 09:38:39 +01:00
|
|
|
|
2021-12-10 00:54:57 +01:00
|
|
|
from flask.templating import render_template
|
2021-11-17 10:28:51 +01:00
|
|
|
|
2021-12-10 00:54:57 +01:00
|
|
|
from app import db
|
2022-07-09 12:55:23 +02:00
|
|
|
from app.but import apc_edit_ue
|
2022-10-31 09:38:39 +01:00
|
|
|
from app.models import UniteEns, Matiere, Module, FormSemestre, ModuleImpl
|
2022-02-06 16:09:17 +01:00
|
|
|
from app.models.validations import ScolarFormSemestreValidation
|
2023-04-10 11:25:46 +02:00
|
|
|
from app.scodoc import codes_cursus
|
2021-11-17 10:28:51 +01:00
|
|
|
import app.scodoc.sco_utils as scu
|
|
|
|
from app.scodoc import sco_groups
|
|
|
|
from app.scodoc.sco_utils import ModuleType
|
|
|
|
|
|
|
|
|
|
|
|
def html_edit_formation_apc(
|
|
|
|
formation,
|
2021-11-18 00:24:56 +01:00
|
|
|
semestre_idx=None,
|
2021-11-17 10:28:51 +01:00
|
|
|
editable=True,
|
|
|
|
tag_editable=True,
|
|
|
|
):
|
|
|
|
"""Formulaire html pour visualisation ou édition d'une formation APC.
|
|
|
|
- Les UEs
|
|
|
|
- Les ressources
|
|
|
|
- Les SAÉs
|
|
|
|
"""
|
2023-02-12 13:36:47 +01:00
|
|
|
cursus = formation.get_cursus()
|
|
|
|
assert cursus.APC_SAE
|
2022-03-01 23:25:42 +01:00
|
|
|
|
2021-11-18 00:24:56 +01:00
|
|
|
ressources = formation.modules.filter_by(module_type=ModuleType.RESSOURCE).order_by(
|
2021-12-09 11:52:46 +01:00
|
|
|
Module.semestre_id, Module.numero, Module.code
|
2021-11-18 00:24:56 +01:00
|
|
|
)
|
2021-12-02 12:08:03 +01:00
|
|
|
saes = formation.modules.filter_by(module_type=ModuleType.SAE).order_by(
|
2021-12-09 11:52:46 +01:00
|
|
|
Module.semestre_id, Module.numero, Module.code
|
2021-12-02 12:08:03 +01:00
|
|
|
)
|
2021-11-18 00:24:56 +01:00
|
|
|
if semestre_idx is None:
|
2023-02-12 13:36:47 +01:00
|
|
|
semestre_ids = range(1, cursus.NB_SEM + 1)
|
2021-11-18 00:24:56 +01:00
|
|
|
else:
|
|
|
|
semestre_ids = [semestre_idx]
|
2021-11-17 10:28:51 +01:00
|
|
|
other_modules = formation.modules.filter(
|
2022-01-08 14:01:16 +01:00
|
|
|
Module.module_type.is_distinct_from(ModuleType.SAE),
|
|
|
|
Module.module_type.is_distinct_from(ModuleType.RESSOURCE),
|
2021-12-09 11:56:10 +01:00
|
|
|
).order_by(
|
|
|
|
Module.semestre_id, Module.module_type.desc(), Module.numero, Module.code
|
|
|
|
)
|
2022-03-01 23:25:42 +01:00
|
|
|
|
|
|
|
ues_by_sem = {}
|
|
|
|
ects_by_sem = {}
|
|
|
|
for semestre_idx in semestre_ids:
|
|
|
|
ues_by_sem[semestre_idx] = formation.ues.filter_by(
|
|
|
|
semestre_idx=semestre_idx
|
|
|
|
).order_by(UniteEns.semestre_idx, UniteEns.numero, UniteEns.acronyme)
|
2023-04-10 11:25:46 +02:00
|
|
|
ects = [
|
|
|
|
ue.ects
|
|
|
|
for ue in ues_by_sem[semestre_idx]
|
|
|
|
if ue.type != codes_cursus.UE_SPORT
|
|
|
|
]
|
2022-03-01 23:25:42 +01:00
|
|
|
if None in ects:
|
|
|
|
ects_by_sem[semestre_idx] = '<span class="missing_ue_ects">manquant</span>'
|
|
|
|
else:
|
|
|
|
ects_by_sem[semestre_idx] = sum(ects)
|
|
|
|
|
2021-11-17 10:28:51 +01:00
|
|
|
arrow_up, arrow_down, arrow_none = sco_groups.get_arrow_icons_tags()
|
2021-11-18 00:24:56 +01:00
|
|
|
|
|
|
|
icons = {
|
|
|
|
"arrow_up": arrow_up,
|
|
|
|
"arrow_down": arrow_down,
|
|
|
|
"arrow_none": arrow_none,
|
|
|
|
"delete": scu.icontag(
|
|
|
|
"delete_small_img",
|
|
|
|
title="Supprimer (module inutilisé)",
|
|
|
|
alt="supprimer",
|
2021-11-17 10:28:51 +01:00
|
|
|
),
|
2021-11-18 00:24:56 +01:00
|
|
|
"delete_disabled": scu.icontag(
|
2022-01-04 17:33:02 +01:00
|
|
|
"delete_small_dis_img",
|
|
|
|
title="Suppression impossible (utilisé dans des semestres)",
|
2021-11-17 10:28:51 +01:00
|
|
|
),
|
2021-11-18 00:24:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
H = [
|
2021-11-17 10:28:51 +01:00
|
|
|
render_template(
|
2023-01-25 15:17:52 +01:00
|
|
|
"pn/form_ues.j2",
|
2021-11-17 10:28:51 +01:00
|
|
|
formation=formation,
|
2021-11-18 00:24:56 +01:00
|
|
|
semestre_ids=semestre_ids,
|
2021-11-17 10:28:51 +01:00
|
|
|
editable=editable,
|
2021-11-18 00:24:56 +01:00
|
|
|
tag_editable=tag_editable,
|
|
|
|
icons=icons,
|
2022-03-01 23:25:42 +01:00
|
|
|
ues_by_sem=ues_by_sem,
|
|
|
|
ects_by_sem=ects_by_sem,
|
2023-04-03 17:46:31 +02:00
|
|
|
form_ue_choix_parcours_niveau=apc_edit_ue.form_ue_choix_parcours_niveau,
|
2023-04-10 11:25:46 +02:00
|
|
|
scu=scu,
|
|
|
|
codes_cursus=codes_cursus,
|
2021-11-17 10:28:51 +01:00
|
|
|
),
|
|
|
|
]
|
2021-11-18 00:24:56 +01:00
|
|
|
for semestre_idx in semestre_ids:
|
|
|
|
ressources_in_sem = ressources.filter_by(semestre_id=semestre_idx)
|
|
|
|
saes_in_sem = saes.filter_by(semestre_id=semestre_idx)
|
|
|
|
other_modules_in_sem = other_modules.filter_by(semestre_id=semestre_idx)
|
2022-01-30 11:56:55 +01:00
|
|
|
matiere_parent = Matiere.query.filter(
|
|
|
|
Matiere.ue_id == UniteEns.id,
|
|
|
|
UniteEns.formation_id == formation.id,
|
|
|
|
UniteEns.semestre_idx == semestre_idx,
|
2023-04-10 11:25:46 +02:00
|
|
|
UniteEns.type != codes_cursus.UE_SPORT,
|
2022-01-30 11:56:55 +01:00
|
|
|
).first()
|
2021-11-18 00:24:56 +01:00
|
|
|
H += [
|
|
|
|
render_template(
|
2023-01-25 15:17:52 +01:00
|
|
|
"pn/form_mods.j2",
|
2021-11-18 00:24:56 +01:00
|
|
|
formation=formation,
|
|
|
|
titre=f"Ressources du S{semestre_idx}",
|
|
|
|
create_element_msg="créer une nouvelle ressource",
|
2022-05-02 14:39:06 +02:00
|
|
|
# matiere_parent=matiere_parent,
|
2021-11-18 00:24:56 +01:00
|
|
|
modules=ressources_in_sem,
|
|
|
|
module_type=ModuleType.RESSOURCE,
|
|
|
|
editable=editable,
|
|
|
|
tag_editable=tag_editable,
|
|
|
|
icons=icons,
|
|
|
|
scu=scu,
|
2022-05-01 23:58:41 +02:00
|
|
|
semestre_id=semestre_idx,
|
|
|
|
)
|
|
|
|
if ues_by_sem[semestre_idx].count() > 0
|
|
|
|
else "",
|
2021-11-18 00:24:56 +01:00
|
|
|
render_template(
|
2023-01-25 15:17:52 +01:00
|
|
|
"pn/form_mods.j2",
|
2021-11-18 00:24:56 +01:00
|
|
|
formation=formation,
|
|
|
|
titre=f"Situations d'Apprentissage et d'Évaluation (SAÉs) S{semestre_idx}",
|
|
|
|
create_element_msg="créer une nouvelle SAÉ",
|
2022-05-02 14:39:06 +02:00
|
|
|
# matiere_parent=matiere_parent,
|
2021-11-18 00:24:56 +01:00
|
|
|
modules=saes_in_sem,
|
|
|
|
module_type=ModuleType.SAE,
|
|
|
|
editable=editable,
|
|
|
|
tag_editable=tag_editable,
|
|
|
|
icons=icons,
|
|
|
|
scu=scu,
|
2022-05-01 23:58:41 +02:00
|
|
|
semestre_id=semestre_idx,
|
|
|
|
)
|
|
|
|
if ues_by_sem[semestre_idx].count() > 0
|
|
|
|
else "",
|
2021-11-18 00:24:56 +01:00
|
|
|
render_template(
|
2023-01-25 15:17:52 +01:00
|
|
|
"pn/form_mods.j2",
|
2021-11-18 00:24:56 +01:00
|
|
|
formation=formation,
|
|
|
|
titre=f"Autres modules (non BUT) du S{semestre_idx}",
|
|
|
|
create_element_msg="créer un nouveau module",
|
|
|
|
modules=other_modules_in_sem,
|
|
|
|
module_type=ModuleType.STANDARD,
|
|
|
|
editable=editable,
|
|
|
|
tag_editable=tag_editable,
|
|
|
|
icons=icons,
|
|
|
|
scu=scu,
|
2022-05-01 23:58:41 +02:00
|
|
|
semestre_id=semestre_idx,
|
|
|
|
)
|
|
|
|
if ues_by_sem[semestre_idx].count() > 0
|
|
|
|
else """<span class="fontred">créer une UE pour pouvoir ajouter des modules</span>""",
|
2021-11-18 00:24:56 +01:00
|
|
|
]
|
2021-11-17 10:28:51 +01:00
|
|
|
|
|
|
|
return "\n".join(H)
|
2021-12-10 00:54:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
def html_ue_infos(ue):
|
2022-03-14 10:56:25 +01:00
|
|
|
"""Page d'information sur une UE"""
|
2021-12-10 00:54:57 +01:00
|
|
|
from app.views import ScoData
|
|
|
|
|
|
|
|
formsemestres = (
|
|
|
|
db.session.query(FormSemestre)
|
|
|
|
.filter(
|
|
|
|
ue.id == Module.ue_id,
|
|
|
|
Module.id == ModuleImpl.module_id,
|
|
|
|
FormSemestre.id == ModuleImpl.formsemestre_id,
|
|
|
|
)
|
|
|
|
.all()
|
|
|
|
)
|
2021-12-20 20:38:21 +01:00
|
|
|
nb_etuds_valid_ue = ScolarFormSemestreValidation.query.filter_by(
|
2021-12-10 00:54:57 +01:00
|
|
|
ue_id=ue.id
|
|
|
|
).count()
|
|
|
|
can_safely_be_suppressed = (
|
|
|
|
(nb_etuds_valid_ue == 0)
|
|
|
|
and (len(formsemestres) == 0)
|
|
|
|
and ue.modules.count() == 0
|
|
|
|
and ue.matieres.count() == 0
|
|
|
|
)
|
|
|
|
return render_template(
|
2023-01-25 15:17:52 +01:00
|
|
|
"pn/ue_infos.j2",
|
2021-12-10 00:54:57 +01:00
|
|
|
titre=f"UE {ue.acronyme} {ue.titre}",
|
|
|
|
ue=ue,
|
|
|
|
formsemestres=formsemestres,
|
|
|
|
nb_etuds_valid_ue=nb_etuds_valid_ue,
|
|
|
|
can_safely_be_suppressed=can_safely_be_suppressed,
|
|
|
|
sco=ScoData(),
|
|
|
|
)
|