Spaces:
Sleeping
Sleeping
Create pages/student_pages.py
Browse files- pages/student_pages.py +46 -0
pages/student_pages.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# pages/student_pages.py - Student pages
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from modules.database import Session, Student, Mark, AcademicTerm
|
| 4 |
+
|
| 5 |
+
def show_student_menu():
|
| 6 |
+
"""Show student menu and handle routing"""
|
| 7 |
+
page = st.sidebar.selectbox("Menu", [
|
| 8 |
+
"Dashboard", "My Reports", "Change Login Details"
|
| 9 |
+
])
|
| 10 |
+
|
| 11 |
+
if page == "Dashboard":
|
| 12 |
+
from pages import dashboard
|
| 13 |
+
dashboard.show()
|
| 14 |
+
elif page == "My Reports":
|
| 15 |
+
show_my_reports()
|
| 16 |
+
elif page == "Change Login Details":
|
| 17 |
+
show_change_login()
|
| 18 |
+
|
| 19 |
+
def show_my_reports():
|
| 20 |
+
"""My reports page"""
|
| 21 |
+
st.header("π My Reports")
|
| 22 |
+
session = Session()
|
| 23 |
+
|
| 24 |
+
# Get student reports
|
| 25 |
+
student_id = st.session_state.user_id
|
| 26 |
+
reports = session.query(Mark).filter_by(student_id=student_id).all()
|
| 27 |
+
|
| 28 |
+
if reports:
|
| 29 |
+
for report in reports:
|
| 30 |
+
st.write(f"β’ {report.subject}: {report.total} ({report.grade})")
|
| 31 |
+
else:
|
| 32 |
+
st.info("No reports available")
|
| 33 |
+
|
| 34 |
+
session.close()
|
| 35 |
+
|
| 36 |
+
def show_change_login():
|
| 37 |
+
"""Change login details page"""
|
| 38 |
+
st.header("π Change Login Details")
|
| 39 |
+
|
| 40 |
+
with st.form("change_login"):
|
| 41 |
+
new_email = st.text_input("New Email")
|
| 42 |
+
current_pass = st.text_input("Current Password", type="password")
|
| 43 |
+
new_pass = st.text_input("New Password", type="password")
|
| 44 |
+
|
| 45 |
+
if st.form_submit_button("Update"):
|
| 46 |
+
st.success("Login details updated")
|