|
import streamlit as st |
|
from collections import defaultdict |
|
|
|
def app(client): |
|
st.title('🟢 Compétences') |
|
|
|
|
|
selected_period = st.selectbox("🧷 Sélectionner la période", ["Trimestre 1", "Trimestre 2", "Trimestre 3", "Année"]) |
|
|
|
|
|
if selected_period == "Année": |
|
periods_to_display = client.periods |
|
else: |
|
periods_to_display = [period for period in client.periods if period.name == selected_period] |
|
|
|
|
|
|
|
tab_labels = sorted({evaluation.subject.name for period in periods_to_display for evaluation in period.evaluations}) |
|
|
|
|
|
tabs = st.tabs(tab_labels) |
|
|
|
def level_to_emoji(level): |
|
mapping = { |
|
"Très bonne maîtrise": "⭐ Très bonne maîtrise", |
|
"Maîtrise satisfaisante": "🟢 Maîtrise satisfaisante", |
|
"Maîtrise fragile": "🟠 Maîtrise fragile", |
|
"Maîtrise insuffisante": "🔴 Maîtrise insuffisante" |
|
} |
|
return mapping.get(level, level) |
|
|
|
for tab, subject in zip(tabs, tab_labels): |
|
with tab: |
|
|
|
for period in periods_to_display: |
|
|
|
evaluations_by_subject = defaultdict(list) |
|
for evaluation in period.evaluations: |
|
evaluations_by_subject[evaluation.subject.name].append(evaluation) |
|
|
|
|
|
if subject in evaluations_by_subject: |
|
for evaluation in evaluations_by_subject[subject]: |
|
with st.expander(f"Évaluation: {evaluation.name} (📅 {evaluation.date.strftime('%d/%m/%Y')})"): |
|
st.markdown("### Information générale") |
|
col1, col2, col3 = st.columns(3) |
|
with col1: |
|
st.write(f"Nom") |
|
st.write(f"##### **{evaluation.name}**") |
|
with col2: |
|
st.metric(label="Date", value=evaluation.date.strftime("%d/%m/%Y")) |
|
with col3: |
|
st.metric(label="Coefficient", value=str(evaluation.coefficient)) |
|
|
|
st.markdown("---") |
|
|
|
st.markdown("### Compétences évaluées") |
|
for acquisition in evaluation.acquisitions: |
|
acq_col1, acq_col2, acq_col3 = st.columns([3, 2, 1]) |
|
with acq_col1: |
|
st.write(f"{acquisition.name}") |
|
with acq_col2: |
|
|
|
st.write(f"{level_to_emoji(acquisition.level)}") |
|
with acq_col3: |
|
st.write(f"Coefficient: {acquisition.coefficient}") |
|
|