orga / pages /vie_scolaire.py
Lenylvt's picture
Upload 10 files
a01c266 verified
raw
history blame
No virus
6.87 kB
import streamlit as st
from pronotepy import Client
import datetime
def afficher_details_periode(client: Client, nom_periode: str):
if nom_periode == "Année entière":
absences = [absence for periode in client.periods for absence in periode.absences]
retards = [retard for periode in client.periods for retard in periode.delays]
punitions = [punition for periode in client.periods for punition in periode.punishments]
else:
periode = next((p for p in client.periods if p.name == nom_periode), None)
if periode:
absences = periode.absences
retards = periode.delays
punitions = periode.punishments
rapports = [periode.report] if periode.report else []
else:
absences, retards, punitions, rapports = [], [], [], []
# Affichage des informations
afficher_absences(absences)
afficher_retards(retards)
afficher_punitions(punitions)
if rapports:
afficher_rapports(rapports)
else:
st.info("🔴 Aucun rapport disponible pour cette période.")
def afficher_absences(absences):
if absences:
for absence in absences:
with st.expander(f"🚫 Absence du {absence.from_date.strftime('%d/%m/%Y')} au {absence.to_date.strftime('%d/%m/%Y')}"):
st.write(f"🕒 Heures manquées: {absence.hours}")
st.write(f"📆 Jours manqués: {absence.days}")
st.write(f"✅ Justifiée: {'Oui' if absence.justified else 'Non'}")
st.write(f"📝 Raisons: {', '.join(absence.reasons)}")
else:
st.info("🔴 Aucune absence enregistrée pour cette période.")
def afficher_retards(retards):
if retards:
for retard in retards:
with st.expander(f"⏰ Retard le {retard.date.strftime('%d/%m/%Y')}"):
st.write(f"⏳ Minutes manquées: {retard.minutes}")
st.write(f"✅ Justifié: {'Oui' if retard.justified else 'Non'}")
st.write(f"📜 Justification: {retard.justification}")
st.write(f"📝 Raisons: {', '.join(retard.reasons)}")
else:
st.info("🔴 Aucun retard enregistré pour cette période.")
def afficher_punitions(punitions):
if punitions:
for punition in punitions:
with st.expander(f"🚨 Punition: {punition.nature} le {punition.given.strftime('%d/%m/%Y')}"):
st.write(f"🔹 Donnée par: {punition.giver}")
st.write(f"🔸 Raisons: {', '.join(punition.reasons)}")
else:
st.info("🔴 Aucune punition enregistrée pour cette période.")
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': '🎵'
}
def afficher_rapports(rapports):
if rapports:
for rapport in rapports:
if rapport.subjects:
for sujet in rapport.subjects:
with st.expander(f"{subject_emojis.get(sujet.name, '📚')} Matière: {sujet.name} ({', '.join(sujet.teachers) if sujet.teachers else ''})", expanded=False):
st.subheader("🧷 Information")
st.markdown(f"""
- 📋 **Moyenne de l'élève**: `{sujet.student_average if sujet.student_average else 'Pas visible'}`
- 📊 **Moyenne de la classe**: `{sujet.class_average if sujet.class_average else 'Bizarement invisible'}`
- 📈 **Moyenne minimale**: `{sujet.min_average if sujet.min_average else 'On ne sait pas'}`
- 📉 **Moyenne maximale**: `{sujet.max_average if sujet.max_average else 'Inconnu'}`
- 🧑‍🏫 **Enseignants**: `{', '.join(sujet.teachers) if sujet.teachers else 'Apparemment, il accun enseignants, étrange ?'}`""")
if sujet.comments:
st.subheader("📃 Commentaires")
for commentaire in sujet.comments:
st.write(f"- {commentaire}")
if rapport.comments:
st.subheader("📄 Commentaires globaux")
for commentaire in rapport.comments:
st.write(f"- {commentaire}")
else:
st.info("🔴 Aucun rapport disponible pour cette période.")
def app(client: Client):
st.title('📍 Vie Scolaire')
options_periode = ["Trimestre 1", "Trimestre 2", "Trimestre 3"]
nom_periode_selectionnee = st.selectbox("📅 Sélectionner la période", options_periode)
tabs = st.tabs(["Tout", "🚫 Absences", "⏰ Retards", "🚨 Punitions", "📊 Bulletin"])
if nom_periode_selectionnee:
with tabs[0]:
afficher_details_periode(client, nom_periode_selectionnee)
with tabs[1]:
afficher_absences([absence for periode in client.periods for absence in periode.absences] if nom_periode_selectionnee == "Année entière" else [absence for periode in client.periods if periode.name == nom_periode_selectionnee for absence in periode.absences])
with tabs[2]:
afficher_retards([retard for periode in client.periods for retard in periode.delays] if nom_periode_selectionnee == "Année entière" else [retard for periode in client.periods if periode.name == nom_periode_selectionnee for retard in periode.delays])
with tabs[3]:
afficher_punitions([punition for periode in client.periods for punition in periode.punishments] if nom_periode_selectionnee == "Année entière" else [punition for periode in client.periods if periode.name == nom_periode_selectionnee for punition in periode.punishments])
with tabs[4]:
if nom_periode_selectionnee == "Année entière":
rapports = [periode.report for periode in client.periods if periode.report]
if rapports:
afficher_rapports(rapports)
else:
st.info("🔴 Aucun rapport disponible pour cette période.")
else:
periode = next((p for p in client.periods if p.name == nom_periode_selectionnee), None)
if periode and periode.report:
afficher_rapports([periode.report])
else:
st.info("🔴 Aucun rapport disponible pour cette période.")
if __name__ == "__main__":
client = Client() # Assurez-vous d'initialiser correctement votre client ici
app(client)