Visualisation ref. comp.: ajoute table avec niveaux par parcours et année

This commit is contained in:
Emmanuel Viennet 2023-03-28 21:59:09 +02:00 committed by iziram
parent 39466bf9b5
commit 63603463f1
6 changed files with 131 additions and 7 deletions

View File

@ -208,6 +208,25 @@ class ApcReferentielCompetences(db.Model, XMLModel):
key=lambda c: c.numero or 0,
)
def table_niveaux_parcours(self) -> dict:
"""Une table avec les parcours:années BUT et les niveaux
{ parcour_id : { 1 : { competence_id : ordre }}}
"""
parcours_info = {}
for parcour in self.parcours:
print(f"# Parcours {parcour.code}")
descr_parcour = {}
parcours_info[parcour.id] = descr_parcour
for annee in (1, 2, 3):
descr_parcour[annee] = {
niveau.competence.id: niveau.ordre
for niveau in ApcNiveau.niveaux_annee_de_parcours(
parcour, annee, self
)
}
return parcours_info
class ApcCompetence(db.Model, XMLModel):
"Compétence"

View File

@ -5,7 +5,9 @@
padding: 12px 32px;
color: #FFF;
max-width: 1000px;
margin: auto;
margin-left: 12px;
margin-top: 12px;
border-radius: 8px;
}
h1 {

View File

@ -0,0 +1,71 @@
div.table_niveaux_parcours {
margin-left: 12px;
margin-top: 12px;
background: rgb(14, 5, 73);
color: #eee;
border-radius: 8px;
width: fit-content;
padding: 8px;
}
div.table_niveaux_parcours .titre {
font-size: 110%;
margin-bottom: 12px;
}
table.table_niveaux_parcours tr th:first-child {
opacity: 0;
}
table.table_niveaux_parcours th {
text-align: center;
color: white;
}
table.table_niveaux_parcours tr.parcours_but {
color: white;
}
table.table_niveaux_parcours tr.parcours_but td {
padding-top: 8px;
}
table.table_niveaux_parcours tr.annee_but {
text-align: center;
}
table.table_niveaux_parcours tr td:not(:first-child) {
width: 120px;
}
table.table_niveaux_parcours tr.annee_but td:first-child {
width: 92px;
font-weight: bold;
color: #ddd;
}
.comp-c1 {
background: #a44
}
.comp-c2 {
background: #84a
}
.comp-c3 {
background: #a84
}
.comp-c4 {
background: #8a4
}
.comp-c5 {
background: #4a8
}
.comp-c6 {
background: #48a
}

View File

@ -0,0 +1,27 @@
<div class="table_niveaux_parcours">
<div class="titre">Niveaux de compétences des parcours</div>
<table class="table_niveaux_parcours">
<thead>
<tr>
<th></th>
{% for comp in ref.competences %}
<th class="comp-c{{1 + loop.index0 % 6}}">{{comp.titre}}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% set nb_cols = ref.competences.count() + 1 %}
{% for parcour in ref.parcours %}
<tr class="parcours_but"><td colspan="{{nb_cols}}">Parcours {{parcour.code}} <i>{{parcour.libelle}}</i></td></tr>
{% for annee in [ 1, 2, 3] %}
<tr class="annee_but">
<td>BUT{{annee}}</td>
{% for comp in ref.competences %}
<td class="comp-c{{1 + loop.index0 % 6}}">{{ table_niveaux_parcours[parcour.id][annee][comp.id] }}</td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>

View File

@ -1,21 +1,23 @@
{# -*- mode: jinja-html -*- #}
{% extends "sco_page.j2" %}
{% block styles %}
{{super()}}
{{super()}}
<link href="{{sco.scu.STATIC_DIR}}/css/refcomp_parcours_niveaux.css" rel="stylesheet" type="text/css" />
{% endblock %}
{% block app_content %}
<h2>Référentiel de compétences {{ref.type_titre}} {{ref.specialite_long}}</h2>
<div class="help">
Référentiel chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M") if ref.scodoc_date_loaded else ""}} à
partir du fichier <tt>{{ref.scodoc_orig_filename or "(inconnu)"}}</tt>.
</div>
<ref-competences></ref-competences>
<script src="{{sco.scu.STATIC_DIR}}/js/ref_competences.js"></script>
<div class="help">
Référentiel chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M") if ref.scodoc_date_loaded else ""}} à
partir du fichier <tt>{{ref.scodoc_orig_filename or "(inconnu)"}}</tt>.
</div>
{% include "but/refcomp_parcours_niveaux.j2" %}
<div class="part2">

View File

@ -35,7 +35,9 @@ from app.views import ScoData
@permission_required(Permission.ScoView)
def refcomp(refcomp_id):
"""Le référentiel de compétences, en JSON."""
ref = ApcReferentielCompetences.query.get_or_404(refcomp_id)
ref: ApcReferentielCompetences = ApcReferentielCompetences.query.get_or_404(
refcomp_id
)
return jsonify(ref.to_dict())
@ -55,6 +57,7 @@ def refcomp_show(refcomp_id):
refcomp_id=refcomp_id,
),
sco=ScoData(),
table_niveaux_parcours=referentiel_competence.table_niveaux_parcours(),
)