Spaces:
Sleeping
Sleeping
Delete app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256import streamlit as stimport jsonimport os
# ββ Page config ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββst.set_page_config( page_title="Ole Miss Degree Planner", page_icon="π", layout="wide", initial_sidebar_state="collapsed",)
# ββ CSS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββst.markdown("""<style> @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap'); html, body, [class*="css"] { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; } .stApp { background: #f0f0f5; } #MainMenu, footer, header { visibility: hidden; } .block-container { padding: 2rem 2rem 4rem 2rem; max-width: 1100px; }
.hero { background: linear-gradient(135deg, #1d1d1f 0%, #3a3a3c 100%); border-radius: 20px; padding: 2rem 2.5rem; margin-bottom: 2rem; box-shadow: 0 4px 24px rgba(0,0,0,0.22); display: flex; align-items: center; gap: 1.6rem; } .hero-text h1 { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.5px; margin: 0 0 0.25rem 0; color: #f5f5f7; } .hero-text p { font-size: 1rem; color: #aeaeb2; margin: 0; }
.card { background: #ffffff; border-radius: 16px; padding: 1.6rem 1.8rem; box-shadow: 0 2px 12px rgba(0,0,0,0.09); margin-bottom: 1.2rem; } .card-header { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: #CE2128; margin-bottom: 0.8rem; }
.stat-row { display: flex; gap: 0.8rem; flex-wrap: wrap; margin: 1rem 0 0.3rem; } .stat-chip { background: #1d1d1f; border-radius: 14px; padding: 0.75rem 1rem; text-align: center; flex: 1; min-width: 80px; } .stat-chip .val { font-size: 1.9rem; font-weight: 700; color: #ffffff; line-height: 1; } .stat-chip .lbl { font-size: 0.68rem; color: #aeaeb2; margin-top: 0.25rem; text-transform: uppercase; letter-spacing: 0.05em; }
.pill-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; } .pill { border-radius: 20px; padding: 0.35rem 0.9rem; font-size: 0.82rem; font-weight: 600; white-space: nowrap; } .pill-done { background: #1a5c1a; color: #e6fae6; } .pill-remaining { background: #CE2128; color: #ffffff; }
.gpa-display { font-size: 4rem; font-weight: 700; color: #1d1d1f; letter-spacing: -2px; line-height: 1; text-align: center; } .gpa-sub { font-size: 0.8rem; color: #6e6e73; text-align: center; margin-top: 0.3rem; } .gpa-bar-bg { background: #e5e5ea; border-radius: 8px; height: 10px; width: 100%; margin: 1rem 0 0.5rem; } .gpa-bar-fill { height: 10px; border-radius: 8px; transition: width 0.4s ease; }
.prog-bar-bg { background: #d1d1d6; border-radius: 8px; height: 10px; width: 100%; margin: 0.5rem 0 0.3rem; } .prog-bar-fill { height: 10px; border-radius: 8px; background: linear-gradient(90deg, #CE2128, #ff6b6e); } .prog-label { font-size: 0.8rem; color: #3a3a3c; font-weight: 500; display: flex; justify-content: space-between; }
.stMultiSelect span[data-baseweb="tag"] { background: #CE2128 !important; color: white !important; border-radius: 8px !important; } .stSelectbox > div > div { border-radius: 12px !important; border-color: #c7c7cc !important; } .stMultiSelect > div > div { border-radius: 12px !important; border-color: #c7c7cc !important; }
.empty-state { background: #ffffff; border-radius: 16px; padding: 3rem 2rem; text-align: center; box-shadow: 0 2px 12px rgba(0,0,0,0.09); } .empty-state .icon { font-size: 3.5rem; margin-bottom: 1rem; } .empty-state .title { font-size: 1.15rem; font-weight: 600; color: #1d1d1f; margin-bottom: 0.4rem; } .empty-state .sub { font-size: 0.9rem; color: #6e6e73; } .footer { text-align: center; color: #8e8e93; font-size: 0.75rem; margin-top: 2rem; line-height: 1.6; }</style>""", unsafe_allow_html=True)
# ββ Load data βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ@st.cache_datadef load_majors(): data_path = os.path.join(os.path.dirname(__file__), "majors_data.json") with open(data_path) as f: return json.load(f)
majors_data = load_majors()sorted_majors = sorted(majors_data.keys())
GRADE_POINTS = { "A": 4.0, "A-": 3.7, "B+": 3.3, "B": 3.0, "B-": 2.7, "C+": 2.3, "C": 2.0, "C-": 1.7, "D+": 1.3, "D": 1.0, "D-": 0.7, "F": 0.0,}GRADE_OPTIONS = ["β", "A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "F"]
if "grades" not in st.session_state: st.session_state.grades = {}
# ββ Hero ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββst.markdown("""<div class="hero"> <div> <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Ole_Miss_Rebels_wordmark.svg/320px-Ole_Miss_Rebels_wordmark.svg.png" style="height:60px;width:auto;display:block;filter:brightness(0) invert(1);" alt="Ole Miss" /> </div> <div class="hero-text"> <h1>Degree Planner</h1> <p>Select your major, mark completed courses, and track your path to graduation.</p> </div></div>""", unsafe_allow_html=True)
left, right = st.columns([1.1, 1], gap="large")
with left: st.markdown('<div class="card">', unsafe_allow_html=True) st.markdown('<div class="card-header">Step 1 β Choose Your Major</div>', unsafe_allow_html=True) selected_major = st.selectbox("Major", options=["β Select a major β"] + sorted_majors, label_visibility="collapsed") st.markdown('</div>', unsafe_allow_html=True)
if selected_major and selected_major != "β Select a major β": all_courses = majors_data[selected_major]
st.markdown('<div class="card">', unsafe_allow_html=True) st.markdown('<div class="card-header">Step 2 β Mark Completed Courses</div>', unsafe_allow_html=True) st.caption("Select every course from this major's requirements that you have already passed.") completed = st.multiselect( "Completed courses", options=all_courses, default=[c for c in st.session_state.grades.keys() if c in all_courses], label_visibility="collapsed", key=f"completed_{selected_major}", ) for k in [k for k in st.session_state.grades if k not in completed]: del st.session_state.grades[k] st.markdown('</div>', unsafe_allow_html=True)
if completed: st.markdown('<div class="card">', unsafe_allow_html=True) st.markdown('<div class="card-header">Step 3 β Enter Your Grades</div>', unsafe_allow_html=True) st.caption("Select a letter grade for each completed course to calculate your GPA.") h1, h2 = st.columns([3, 1]) h1.markdown("**Course**") h2.markdown("**Grade**") for course in sorted(completed): c1, c2 = st.columns([3, 1]) c1.markdown(f"<span style='font-size:0.88rem;font-weight:500;color:#1d1d1f'>{course}</span>", unsafe_allow_html=True) current = st.session_state.grades.get(course, "β") new_grade = c2.selectbox(f"g_{course}", options=GRADE_OPTIONS, index=GRADE_OPTIONS.index(current) if current in GRADE_OPTIONS else 0, label_visibility="collapsed", key=f"gs_{course}") st.session_state.grades[course] = new_grade st.markdown('</div>', unsafe_allow_html=True)
remaining = [c for c in all_courses if c not in completed] total = len(all_courses) done = len(completed) pct = int(done / total * 100) if total else 0 graded = [(c, g) for c, g in st.session_state.grades.items() if g in GRADE_POINTS and c in completed] gpa = sum(GRADE_POINTS[g] for _, g in graded) / len(graded) if graded else None gpa_display = f"{gpa:.2f}" if gpa is not None else "β"
st.markdown('<div class="card">', unsafe_allow_html=True) st.markdown('<div class="card-header">Your Progress</div>', unsafe_allow_html=True) st.markdown(f""" <div class="prog-label"><span>{done} of {total} courses completed</span><span style="color:#CE2128;font-weight:700">{pct}%</span></div> <div class="prog-bar-bg"><div class="prog-bar-fill" style="width:{pct}%"></div></div> <div class="stat-row"> <div class="stat-chip"><div class="val">{done}</div><div class="lbl">Done</div></div> <div class="stat-chip"><div class="val">{len(remaining)}</div><div class="lbl">Left</div></div> <div class="stat-chip"><div class="val">{total}</div><div class="lbl">Total</div></div> <div class="stat-chip"><div class="val">{gpa_display}</div><div class="lbl">GPA</div></div> </div> """, unsafe_allow_html=True) st.markdown('</div>', unsafe_allow_html=True)
with right: if selected_major and selected_major != "β Select a major β": all_courses = majors_data[selected_major] completed_list = st.session_state.get(f"completed_{selected_major}", []) or [] remaining = [c for c in all_courses if c not in completed_list] graded = [(c, g) for c, g in st.session_state.grades.items() if g in GRADE_POINTS and c in completed_list] gpa = sum(GRADE_POINTS[g] for _, g in graded) / len(graded) if graded else None
st.markdown('<div class="card">', unsafe_allow_html=True) st.markdown('<div class="card-header">GPA Calculator</div>', unsafe_allow_html=True) gpa_val = f"{gpa:.2f}" if gpa is not None else "β" gpa_w = int(gpa / 4.0 * 100) if gpa is not None else 0 if gpa is None: bar_color = "#d1d1d6" elif gpa >= 3.5: bar_color = "#34c759" elif gpa >= 3.0: bar_color = "#007aff" elif gpa >= 2.0: bar_color = "#ff9f0a" else: bar_color = "#CE2128" gpa_sub = f"out of 4.0 Β· {len(graded)} graded course(s)" if gpa is not None else "Enter grades in Step 3 to calculate your GPA" st.markdown(f""" <div class="gpa-display">{gpa_val}</div> <div class="gpa-sub">{gpa_sub}</div> <div class="gpa-bar-bg"><div class="gpa-bar-fill" style="width:{gpa_w}%;background:{bar_color};"></div></div> """, unsafe_allow_html=True) if gpa is not None: if gpa >= 3.5: st.success("π Dean's List range β excellent work!") elif gpa >= 3.0: st.info("π Good standing β keep it up!") elif gpa >= 2.0: st.warning("β οΈ Above minimum β aim higher for more opportunities.") else: st.error("π¨ Below 2.0 β academic probation risk. Seek advising soon.") st.markdown('</div>', unsafe_allow_html=True)
st.markdown('<div class="card">', unsafe_allow_html=True) st.markdown('<div class="card-header">Courses Still Needed</div>', unsafe_allow_html=True) if not remaining: st.success("π You've completed all listed courses for this major!") else: st.caption(f"{len(remaining)} course(s) remaining to finish your degree requirements.") pills = "".join(f'<span class="pill pill-remaining">{c}</span>' for c in sorted(remaining)) st.markdown(f'<div class="pill-grid">{pills}</div>', unsafe_allow_html=True) st.markdown('</div>', unsafe_allow_html=True)
if completed_list: st.markdown('<div class="card">', unsafe_allow_html=True) st.markdown('<div class="card-header">Completed Courses</div>', unsafe_allow_html=True) pills = "".join(f'<span class="pill pill-done">{c}</span>' for c in sorted(completed_list)) st.markdown(f'<div class="pill-grid">{pills}</div>', unsafe_allow_html=True) st.markdown('</div>', unsafe_allow_html=True) else: st.markdown(""" <div class="empty-state"> <div class="icon">π</div> <div class="title">Select a major to get started</div> <div class="sub">Your remaining courses, progress, and GPA will appear here.</div> </div> """, unsafe_allow_html=True)
st.markdown("""<div class="footer"> University of Mississippi Β· Degree Planner Β· 2025β2026 Academic Year<br> Course data sourced from official Ole Miss program sheets. Always verify requirements with your academic advisor.</div>""", unsafe_allow_html=True)app.pyDeleted-256