2023-04-07 17:10:17 +02:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# ScoDoc
|
|
|
|
#
|
2023-12-31 23:04:06 +01:00
|
|
|
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
|
2023-04-07 17:10:17 +02: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
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""
|
|
|
|
Vues sur les formations BUT
|
|
|
|
|
|
|
|
Emmanuel Viennet, 2023
|
|
|
|
"""
|
|
|
|
|
2023-04-11 13:48:57 +02:00
|
|
|
from flask import flash, g, redirect, render_template, request, url_for
|
2023-04-07 17:10:17 +02:00
|
|
|
|
2023-07-16 19:59:45 +02:00
|
|
|
from app import db
|
|
|
|
from app.but import cursus_but, validations_view
|
2023-04-07 17:10:17 +02:00
|
|
|
from app.decorators import (
|
|
|
|
scodoc,
|
|
|
|
permission_required,
|
|
|
|
)
|
|
|
|
|
2023-04-11 13:48:57 +02:00
|
|
|
from app.forms.formation.ue_parcours_ects import UEParcoursECTSForm
|
|
|
|
|
2023-04-07 17:10:17 +02:00
|
|
|
from app.models import (
|
|
|
|
ApcParcours,
|
|
|
|
ApcReferentielCompetences,
|
|
|
|
Formation,
|
2023-07-16 19:59:45 +02:00
|
|
|
FormSemestre,
|
|
|
|
Identite,
|
2023-04-11 13:48:57 +02:00
|
|
|
UniteEns,
|
2023-04-07 17:10:17 +02:00
|
|
|
)
|
2023-04-10 11:25:46 +02:00
|
|
|
from app.scodoc.codes_cursus import UE_STANDARD
|
2023-04-07 17:10:17 +02:00
|
|
|
from app.scodoc.sco_permissions import Permission
|
2023-07-16 19:59:45 +02:00
|
|
|
from app.scodoc.sco_exceptions import ScoPermissionDenied, ScoValueError
|
2023-04-07 17:10:17 +02:00
|
|
|
from app.views import notes_bp as bp
|
|
|
|
from app.views import ScoData
|
|
|
|
|
|
|
|
|
2023-04-10 11:25:46 +02:00
|
|
|
@bp.route("/parcour_formation/<int:formation_id>/<int:parcour_id>")
|
|
|
|
@bp.route("/parcour_formation/<int:formation_id>")
|
2023-04-07 17:10:17 +02:00
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
2023-04-10 11:25:46 +02:00
|
|
|
def parcour_formation(formation_id: int, parcour_id: int = None) -> str:
|
2023-04-07 17:10:17 +02:00
|
|
|
"""visu HTML d'un parcours dans une formation,
|
|
|
|
avec les compétences, niveaux et UEs associées."""
|
|
|
|
formation: Formation = Formation.query.filter_by(
|
|
|
|
id=formation_id, dept_id=g.scodoc_dept_id
|
|
|
|
).first_or_404()
|
|
|
|
ref_comp: ApcReferentielCompetences = formation.referentiel_competence
|
|
|
|
if ref_comp is None:
|
|
|
|
return "pas de référentiel de compétences"
|
2023-04-10 11:25:46 +02:00
|
|
|
if parcour_id is None:
|
|
|
|
parcour = None
|
|
|
|
else:
|
|
|
|
parcour: ApcParcours = ref_comp.parcours.filter_by(id=parcour_id).first()
|
|
|
|
if parcour is None:
|
|
|
|
raise ScoValueError("parcours invalide ou hors référentiel de formation")
|
2023-04-07 17:10:17 +02:00
|
|
|
|
2023-10-19 22:24:56 +02:00
|
|
|
competences_parcour, ects_parcours = (
|
2023-07-16 19:59:45 +02:00
|
|
|
cursus_but.parcour_formation_competences(parcour, formation)
|
|
|
|
if parcour
|
2023-10-19 22:24:56 +02:00
|
|
|
else (None, 0.0)
|
2023-04-10 11:25:46 +02:00
|
|
|
)
|
2023-04-07 17:10:17 +02:00
|
|
|
|
|
|
|
return render_template(
|
|
|
|
"but/parcour_formation.j2",
|
2023-10-19 22:24:56 +02:00
|
|
|
ects_parcours=ects_parcours,
|
2023-04-07 17:10:17 +02:00
|
|
|
formation=formation,
|
|
|
|
parcour=parcour,
|
|
|
|
competences_parcour=competences_parcour,
|
|
|
|
sco=ScoData(),
|
2023-04-10 11:25:46 +02:00
|
|
|
title=f"{formation.acronyme} - Niveaux et UEs",
|
2023-04-07 17:10:17 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-07-16 19:59:45 +02:00
|
|
|
@bp.route(
|
|
|
|
"/validation_rcues/<int:formsemestre_id>/<int:etudid>/edit",
|
|
|
|
defaults={"edit": True},
|
|
|
|
endpoint="validation_rcues_edit",
|
|
|
|
)
|
|
|
|
@bp.route("/validation_rcues/<int:formsemestre_id>/<int:etudid>")
|
|
|
|
@scodoc
|
|
|
|
@permission_required(Permission.ScoView)
|
|
|
|
def validation_rcues(
|
|
|
|
formsemestre_id: int, etudid: int = None, edit: bool = False
|
|
|
|
) -> str:
|
|
|
|
"""Visualisation des résultats UEs et RCUEs d'un étudiant
|
|
|
|
et saisie des validation de RCUE antérieures.
|
2023-04-07 17:10:17 +02:00
|
|
|
"""
|
2024-10-29 19:18:36 +01:00
|
|
|
etud: Identite = Identite.get_or_404(etudid)
|
|
|
|
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
2023-07-16 19:59:45 +02:00
|
|
|
if edit: # check permission
|
|
|
|
if not formsemestre.can_edit_jury():
|
|
|
|
raise ScoPermissionDenied(
|
|
|
|
dest_url=url_for(
|
|
|
|
"notes.formsemestre_status",
|
|
|
|
scodoc_dept=g.scodoc_dept,
|
|
|
|
formsemestre_id=formsemestre_id,
|
2023-04-13 09:58:38 +02:00
|
|
|
)
|
2023-07-16 19:59:45 +02:00
|
|
|
)
|
|
|
|
return validations_view.validation_rcues(etud, formsemestre, edit)
|
2023-04-11 13:48:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
@bp.route("/ue_parcours_ects/<int:ue_id>", methods=["GET", "POST"])
|
|
|
|
@scodoc
|
2023-09-29 21:17:31 +02:00
|
|
|
@permission_required(Permission.EditFormation)
|
2023-04-11 13:48:57 +02:00
|
|
|
def ue_parcours_ects(ue_id: int):
|
|
|
|
"""formulaire (div) pour associer des ECTS par parcours d'une UE"""
|
|
|
|
ue: UniteEns = (
|
|
|
|
UniteEns.query.filter_by(id=ue_id)
|
|
|
|
.join(Formation)
|
|
|
|
.filter_by(dept_id=g.scodoc_dept_id)
|
|
|
|
.first_or_404()
|
|
|
|
)
|
|
|
|
if ue.type != UE_STANDARD:
|
|
|
|
raise ScoValueError("Pas d'ECTS / Parcours pour ce type d'UE")
|
|
|
|
ref_comp = ue.formation.referentiel_competence
|
|
|
|
if ref_comp is None:
|
|
|
|
raise ScoValueError("Pas référentiel de compétence pour cette UE !")
|
|
|
|
form = UEParcoursECTSForm(ue)
|
|
|
|
|
|
|
|
edit_url = url_for("notes.ue_edit", scodoc_dept=g.scodoc_dept, ue_id=ue.id)
|
|
|
|
if request.method == "POST":
|
|
|
|
if request.form.get("submit"):
|
|
|
|
if form.validate():
|
|
|
|
for parcour in ue.formation.referentiel_competence.parcours:
|
|
|
|
field = getattr(form, f"ects_parcour_{parcour.id}")
|
|
|
|
if field:
|
|
|
|
ue.set_ects(field.data, parcour=parcour)
|
|
|
|
db.session.commit()
|
|
|
|
flash("ECTS enregistrés")
|
|
|
|
return redirect(edit_url)
|
|
|
|
elif request.form.get("cancel"):
|
|
|
|
return redirect(edit_url)
|
|
|
|
|
|
|
|
return render_template(
|
|
|
|
"formation/ue_assoc_parcours_ects.j2", form=form, sco=ScoData(), ue=ue
|
|
|
|
)
|