File size: 3,299 Bytes
826d110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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}")