1
0
forked from ScoDoc/ScoDoc

Améliore édition programme BUT: choix niveaux compétence / UE

This commit is contained in:
Emmanuel Viennet 2022-07-09 12:55:23 +02:00
parent 5bc4b47e1e
commit 1148bf59eb
8 changed files with 44 additions and 20 deletions

View File

@ -70,7 +70,9 @@ def form_ue_choix_niveau(formation: Formation, ue: UniteEns) -> str:
<div class="ue_choix_niveau">
<form id="form_ue_choix_niveau">
<b>Niveau de compétence associé:</b>
<select onchange="set_ue_niveau_competence();" data-setter="{
<select onchange="set_ue_niveau_competence(this);"
data-ue_id="{ue.id}"
data-setter="{
url_for( "notes.set_ue_niveau_competence", scodoc_dept=g.scodoc_dept)
}">
<option value="" {'selected' if ue.niveau_competence is None else ''}>aucun</option>
@ -83,7 +85,6 @@ def form_ue_choix_niveau(formation: Formation, ue: UniteEns) -> str:
def set_ue_niveau_competence(ue_id: int, niveau_id: int):
"""Associe le niveau et l'UE"""
log(f"set_ue_niveau_competence( {ue_id}, {niveau_id} )")
ue = UniteEns.query.get_or_404(ue_id)
autres_ues = ue.formation.ues.filter_by(semestre_idx=ue.semestre_idx)
@ -96,6 +97,7 @@ def set_ue_niveau_competence(ue_id: int, niveau_id: int):
)
return "", 409 # conflict
if niveau_id == "":
niveau = ""
# suppression de l'association
ue.niveau_competence = None
else:
@ -103,4 +105,6 @@ def set_ue_niveau_competence(ue_id: int, niveau_id: int):
ue.niveau_competence = niveau
db.session.add(ue)
db.session.commit()
log(f"set_ue_niveau_competence( {ue}, {niveau} )")
return "", 204

View File

@ -269,7 +269,7 @@ class ApcNiveau(db.Model, XMLModel):
ues = db.relationship("UniteEns", back_populates="niveau_competence")
def __repr__(self):
return f"""<{self.__class__.__name__} ordre={self.ordre!r} annee={
return f"""<{self.__class__.__name__} {self.id} ordre={self.ordre!r} annee={
self.annee!r} {self.competence!r}>"""
def to_dict(self):

View File

@ -31,6 +31,7 @@ from flask import g, request
from flask_login import current_user
from app import db
from app.but import apc_edit_ue
from app.models import Formation, UniteEns, Matiere, Module, FormSemestre, ModuleImpl
from app.models.validations import ScolarFormSemestreValidation
from app.scodoc.sco_codes_parcours import UE_SPORT
@ -109,6 +110,7 @@ def html_edit_formation_apc(
icons=icons,
ues_by_sem=ues_by_sem,
ects_by_sem=ects_by_sem,
form_ue_choix_niveau=apc_edit_ue.form_ue_choix_niveau,
),
]
for semestre_idx in semestre_ids:

View File

@ -466,7 +466,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No
+ ue_div
+ html_sco_header.sco_footer()
)
elif tf[2]:
elif tf[0] == 1:
if create:
if not tf[2]["ue_code"]:
del tf[2]["ue_code"]
@ -684,6 +684,7 @@ def ue_table(formation_id=None, semestre_idx=1, msg=""): # was ue_list
javascripts=[
"libjs/jinplace-1.2.1.min.js",
"js/ue_list.js",
"js/edit_ue.js",
"libjs/jQuery-tagEditor/jquery.tag-editor.min.js",
"libjs/jQuery-tagEditor/jquery.caret.min.js",
"js/module_tag_editor.js",

View File

@ -2210,6 +2210,7 @@ ul.notes_module_list {
list-style-type: none;
}
/*Choix niveau dans form edit UE */
div.ue_choix_niveau {
background-color: rgb(191, 242, 255);
border: 1px solid blue;
@ -2219,6 +2220,19 @@ div.ue_choix_niveau {
margin-right: 15px;
}
/* Choix niveau dans edition programme (ue_table) */
div.formation_list_ues div.ue_choix_niveau {
margin-left: 64px;
margin-right: 64px;
margin-top: 2px;
padding: 4px;
font-size: 14px;
}
div.formation_list_ues div.ue_choix_niveau b {
font-weight: normal;
}
div#ue_list_modules {
background-color: rgb(251, 225, 165);
border: 1px solid blue;

View File

@ -1,13 +1,16 @@
// Affiche et met a jour la liste des UE partageant le meme code
$().ready(function () {
update_ue_list();
$("#tf_ue_code").bind("keyup", update_ue_list);
if (document.querySelector("#tf_ue_id")) {
/* fonctions spécifiques pour edition UE */
update_ue_list();
$("#tf_ue_code").bind("keyup", update_ue_list);
$("select#tf_type").change(function () {
$("select#tf_type").change(function () {
update_bonus_description();
});
update_bonus_description();
});
update_bonus_description();
}
});
function update_bonus_description() {
@ -33,11 +36,10 @@ function update_ue_list() {
});
}
function set_ue_niveau_competence() {
let ue_id = document.querySelector("#tf_ue_id").value;
let select = document.querySelector("#form_ue_choix_niveau select");
let niveau_id = select.value;
let set_ue_niveau_competence_url = select.dataset.setter;
function set_ue_niveau_competence(elem) {
let ue_id = elem.dataset.ue_id;
let niveau_id = elem.value;
let set_ue_niveau_competence_url = elem.dataset.setter;
$.post(set_ue_niveau_competence_url,
{
ue_id: ue_id,

View File

@ -30,7 +30,7 @@
<span class="ue_type_{{ue.type}}">
<span class="ue_color_indicator" style="background:{{
ue.color if ue.color is not none else 'blue'}}"></span>
<b>{{ue.acronyme}}</b> <a class="discretelink" href="{{
<b>{{ue.acronyme}} <a class="discretelink" href="{{
url_for('notes.ue_infos', scodoc_dept=g.scodoc_dept, ue_id=ue.id)}}"
title="{{ue.acronyme}}: {{
('pas de compétence associée'
@ -40,6 +40,7 @@
else ''
}}"
>{{ue.titre}}</a>
</b>
{% set virg = joiner(", ") %}
<span class="ue_code">(
{%- if ue.ue_code -%}{{ virg() }}code {{ue.ue_code}} {%- endif -%}
@ -53,16 +54,16 @@
)
</span>
</span>
{% if (ue.niveau_competence is none) and ue.type == 0 %}
<span class="fontred">pas de compétence associée</span>
{% endif %}
{% if editable and not ue.is_locked() %}
<a class="stdlink" href="{{ url_for('notes.ue_edit',
scodoc_dept=g.scodoc_dept, ue_id=ue.id)
}}">modifier</a>
{% endif %}
{{ form_ue_choix_niveau(formation, ue)|safe }}
{% if ue.type == 1 and ue.modules.count() == 0 %}
<span class="warning" title="pas de module, donc pas de bonus calculé">aucun module rattaché !</span>
{% endif %}

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.3.17"
SCOVERSION = "9.3.18"
SCONAME = "ScoDoc"