File size: 3,306 Bytes
3cf735a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
68
69
70
71
72
import streamlit as st
import pronotepy
from datetime import datetime, timedelta

# A simple mapping of subjects to emojis. Add more subjects and emojis as needed.
subject_emojis = {
    'ANGLAIS LV SECTION': '🇬🇧',
    'FRANCAIS': '🇫🇷',
    'EPS': '🏃‍♂️',
    'Sport': '🏃‍♂️',
    'Histoire/Géographie': '🌍',
    'HIST/GEO': '🌍',
    'Mathématiques': '🔢',
    'MATHS': '🔢',
    'PH-CHIMIE': '🧪',
    'Physique-Chimie': '🧪',
    'ANGLAIS LV1': '🇬🇧',
    'ESPAGNOL LV2': '🇪🇸',
    'SVT': '🌿',
    'Technologie': '🔧',
    'TECHNO': '🔧',
    'TECHNOLOGIE': '🔧',
    'Arts Plastiques': '🎨',
    'ARTS PLASTIQUES': '🎨',
    'Musique': '🎵',
    'MUSIQUE': '🎵',
    'ED MUSICALE': '🎵'
}

# A function to get emoji by subject
def get_emoji(subject_name):
    return subject_emojis.get(subject_name, '📚')  # Return a default book emoji if subject not found

def app(client):
    st.title("📅 Emploi du temps")

    # Sélection de la semaine
    selected_week = st.date_input("✨ Sélectionnez une semaine", value=datetime.today())
    start_of_week = selected_week - timedelta(days=selected_week.weekday())  # Adjust for selected week
    week_dates = [start_of_week + timedelta(days=i) for i in range(5)]  # List of dates for the selected workweek

    # Create tabs for each day of the week in French
    tabs = st.tabs(["1️⃣ Lundi", "2️⃣ Mardi", "3️⃣ Mercredi", "4️⃣ Jeudi", "5️⃣ Vendredi"])

    for i, tab in enumerate(tabs):
        with tab:
            date_for_pronote = datetime.combine(week_dates[i], datetime.min.time())

            # Récupération de l'emploi du temps pour la journée sélectionnée
            timetable = client.lessons(date_for_pronote, date_for_pronote + timedelta(days=1))

            # Tri des cours du plus tôt au plus tard
            sorted_timetable = sorted(timetable, key=lambda lesson: lesson.start)

            if sorted_timetable:
                # Affichage de l'emploi du temps avec emojis et bouton pour chaque leçon ayant un contenu
                for lesson in sorted_timetable:
                    emoji = get_emoji(lesson.subject.name)
                    with st.expander(f"{emoji} {lesson.status if lesson.status else ""} {lesson.subject.name} ({lesson.start.strftime('%H:%M')} - {lesson.end.strftime('%H:%M')})"):
                        st.write(f"🎭 **Salle :** {lesson.classroom}")
                        st.write(f"🧑‍🏫 **Professeur :** {lesson.teacher_name}")
                        if lesson.status:
                            st.write(f"🔦 **Statut :** {lesson.status}")
                        if lesson.content:
                            # Bouton pour afficher le contenu de la leçon dans une nouvelle page
                            if st.button(f"📜 Afficher le contenu pour {lesson.subject.name}", key=lesson.id):
                                # Utilisation du session state de Streamlit pour stocker l'objet contenu
                                st.session_state['selected_content'] = lesson.content
                                st.session_state.current_page = 'contenu'
                                st.rerun()
            else:
                st.write("🔴 Aucun cours pour cette journée.")