File size: 3,351 Bytes
3cc080f
 
 
 
 
 
26bd28b
556462f
e74c738
1d7a7d2
3cc080f
a1146b3
eac70a0
3cc080f
 
 
46f1978
3cc080f
 
 
 
 
 
 
 
 
 
 
 
840101a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3cc080f
 
 
 
 
 
46f1978
3cc080f
 
 
 
 
 
 
 
 
 
e74c738
3cc080f
 
 
 
 
 
 
840101a
 
 
 
 
 
 
3cc080f
556462f
3cc080f
26bd28b
 
556462f
 
e74c738
 
a1146b3
 
eac70a0
 
3cc080f
 
 
 
 
 
 
 
 
 
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import streamlit as st
from datetime import datetime

# Import our modules
from auth import show_login_page, handle_logout, is_authenticated
from views.week1 import show_week1_content
from views.week2 import show_week2_content
from views.week3 import show_week3_content
from views.week4 import show_week4_content

from views.resources import show_resources
from views.user_management import show_user_management
from views.instructor_notes import show_instructor_notes

# Page configuration
st.set_page_config(
    page_title="Cura Learning Debate Class",
    page_icon="🎭",
    layout="wide",
    initial_sidebar_state="expanded"
)

# Initialize session state
if 'authenticated' not in st.session_state:
    st.session_state.authenticated = False
if 'username' not in st.session_state:
    st.session_state.username = None
if 'name' not in st.session_state:
    st.session_state.name = None
if 'current_page' not in st.session_state:
    st.session_state.current_page = None

def clear_page_cache():
    """Clear any cached components when navigating to a new page"""
    # Clear any form data or cached components
    for key in list(st.session_state.keys()):
        if key.startswith('form_') or key.startswith('cached_'):
            del st.session_state[key]

def clear_all_page_components():
    """Clear all page-specific components to prevent leakage"""
    keys_to_keep = ['authenticated', 'username', 'name', 'current_page']
    keys_to_remove = []
    
    for key in st.session_state.keys():
        if key not in keys_to_keep:
            keys_to_remove.append(key)
    
    for key in keys_to_remove:
        del st.session_state[key]

def show_main_application():
    """Show the main application after successful login"""
    
    # Sidebar for navigation and user info
    with st.sidebar:
        st.title("🎭 Cura Learning Debate Class")
        st.markdown("---")
        
        # User info
        st.markdown(f"**Welcome, {st.session_state.name}!**")
        st.markdown(f"*{st.session_state.username}*")
        st.markdown("---")
        
        # Navigation
        page = st.selectbox(
            "Course Navigation",
            ["Week 1: Introduction to Debate", "Week 2: Research & Evidence", "Week 3: How to Do a Case", "Week 4: Traditional LD Framework", "User Management", "Instructor Notes"]
        )
        
        st.markdown("---")
        
        # Logout button
        handle_logout()
    
    # Check if page has changed and clear cache if needed
    if st.session_state.current_page != page:
        clear_all_page_components()
        st.session_state.current_page = page
        # Force a complete page refresh
        st.rerun()
    
    # Main content area
    if page == "Week 1: Introduction to Debate":
        show_week1_content()
    elif page == "Week 2: Research & Evidence":
        show_week2_content()
    elif page == "Week 3: How to Do a Case":
        show_week3_content()
    elif page == "Week 4: Traditional LD Framework":
        show_week4_content()
    elif page == "User Management":
        show_user_management()
    elif page == "Instructor Notes":
        show_instructor_notes()

def main():
    # Check if user is authenticated
    if not is_authenticated():
        show_login_page()
    else:
        show_main_application()

if __name__ == "__main__":
    main()