orga / pages /competence.py
Lenylvt's picture
Upload 12 files
826d110 verified
import streamlit as st
from collections import defaultdict
def app(client):
st.title('🟢 Compétences')
# Dropdown to select the period
selected_period = st.selectbox("🧷 Sélectionner la période", ["Trimestre 1", "Trimestre 2", "Trimestre 3", "Année"])
# Filter periods based on the selection
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]
# Create a list of subjects for tabs
# Assuming evaluations have a subject attribute
tab_labels = sorted({evaluation.subject.name for period in periods_to_display for evaluation in period.evaluations})
# Create tabs for each subject
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) # Fallback to the original level if it doesn't match known levels
for tab, subject in zip(tabs, tab_labels):
with tab:
# Display competencies for all selected periods
for period in periods_to_display:
# Organize evaluations by subject
evaluations_by_subject = defaultdict(list)
for evaluation in period.evaluations:
evaluations_by_subject[evaluation.subject.name].append(evaluation)
# Display competencies for the current tab's subject
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:
# Use the function here to prepend the emoji to the level description
st.write(f"{level_to_emoji(acquisition.level)}")
with acq_col3:
st.write(f"Coefficient: {acquisition.coefficient}")