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|
subjects_set = set(subjects)
|
| 4 |
|
|
@@ -23,4 +350,19 @@
|
|
| 23 |
st.session_state.recommendations.append("Business Programs")
|
| 24 |
|
| 25 |
if len(st.session_state.recommendations) == 0:
|
| 26 |
-
st.session_state.recommendations.append("Liberal Arts")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from streamlit_extras.colored_header import colored_header
|
| 3 |
+
|
| 4 |
+
# --- Configuration ---
|
| 5 |
+
st.set_page_config(
|
| 6 |
+
page_title="Edusphere",
|
| 7 |
+
page_icon="🎓",
|
| 8 |
+
layout="centered",
|
| 9 |
+
initial_sidebar_state="collapsed"
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
# --- Color Theme ---
|
| 13 |
+
THEME = {
|
| 14 |
+
"primary": "#4B8BBE",
|
| 15 |
+
"secondary": "#306998",
|
| 16 |
+
"accent": "#FFD43B",
|
| 17 |
+
"bg": "#F5F5F5",
|
| 18 |
+
"text": "#333333"
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
# --- Education System Data ---
|
| 22 |
+
PRE_UNIVERSITY = {
|
| 23 |
+
"Matric/SSC": {
|
| 24 |
+
"Science": ["Physics", "Chemistry", "Biology", "Mathematics", "Computer Science"],
|
| 25 |
+
"Arts": ["Economics", "Statistics", "Islamic Studies"]
|
| 26 |
+
},
|
| 27 |
+
"O-Level": {
|
| 28 |
+
"Science": ["Physics", "Chemistry", "Biology", "Mathematics", "Computer Science"],
|
| 29 |
+
"Commerce": ["Business Studies", "Accounting", "Economics"]
|
| 30 |
+
},
|
| 31 |
+
"Intermediate/HSSC": {
|
| 32 |
+
"Pre-Medical": {
|
| 33 |
+
"core": ["Biology", "Chemistry", "Physics", "English"],
|
| 34 |
+
"optional": ["Islamic Studies", "Pakistan Studies", "Mathematics"]
|
| 35 |
+
},
|
| 36 |
+
"Pre-Engineering": {
|
| 37 |
+
"core": ["Mathematics", "Physics", "Chemistry", "English"],
|
| 38 |
+
"optional": ["Computer Science", "Islamic Studies"]
|
| 39 |
+
},
|
| 40 |
+
"ICS": {
|
| 41 |
+
"core": ["Computer Science", "Mathematics", "English"],
|
| 42 |
+
"optional": ["Statistics", "Physics", "Economics"]
|
| 43 |
+
},
|
| 44 |
+
"Commerce": {
|
| 45 |
+
"core": ["Principles of Accounting", "Principles of Economics", "Business Mathematics", "English"],
|
| 46 |
+
"optional": ["Commercial Geography", "Computer Studies", "Statistics"]
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"A-Level": {
|
| 50 |
+
"Science": ["Mathematics", "Physics", "Chemistry", "Biology"],
|
| 51 |
+
"Commerce": ["Business", "Accounting", "Economics"]
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
PATHWAYS = {
|
| 56 |
+
# School to College
|
| 57 |
+
"Pre-Medical": {
|
| 58 |
+
"min_marks": 65,
|
| 59 |
+
"description": "Gateway to medical professions",
|
| 60 |
+
"careers": ["MBBS", "BDS", "Pharmacy"],
|
| 61 |
+
"color": "#FF6B6B",
|
| 62 |
+
"icon": "🩺",
|
| 63 |
+
"level": "Intermediate"
|
| 64 |
+
},
|
| 65 |
+
"Pre-Engineering": {
|
| 66 |
+
"min_marks": 60,
|
| 67 |
+
"description": "Pathway to engineering fields",
|
| 68 |
+
"careers": ["Engineering", "Architecture", "Aviation"],
|
| 69 |
+
"color": "#4CC9F0",
|
| 70 |
+
"icon": "⚙️",
|
| 71 |
+
"level": "Intermediate"
|
| 72 |
+
},
|
| 73 |
+
"ICS": {
|
| 74 |
+
"min_marks": 55,
|
| 75 |
+
"description": "Computer science foundation",
|
| 76 |
+
"careers": ["Software Engineering", "IT Degrees"],
|
| 77 |
+
"color": "#F8961E",
|
| 78 |
+
"icon": "💻",
|
| 79 |
+
"level": "Intermediate"
|
| 80 |
+
},
|
| 81 |
+
"Commerce": {
|
| 82 |
+
"min_marks": 50,
|
| 83 |
+
"description": "Business and finance foundation",
|
| 84 |
+
"careers": ["CA", "ACCA", "Business Administration"],
|
| 85 |
+
"color": "#90BE6D",
|
| 86 |
+
"icon": "💰",
|
| 87 |
+
"level": "Intermediate"
|
| 88 |
+
},
|
| 89 |
+
"General Arts": {
|
| 90 |
+
"min_marks": 40,
|
| 91 |
+
"description": "Flexible arts and humanities pathway",
|
| 92 |
+
"careers": ["Journalism", "Education", "Social Sciences"],
|
| 93 |
+
"color": "#B5179E",
|
| 94 |
+
"icon": "🎨",
|
| 95 |
+
"level": "Intermediate"
|
| 96 |
+
},
|
| 97 |
+
|
| 98 |
+
# College to University
|
| 99 |
+
"Medical Programs": {
|
| 100 |
+
"prerequisites": ["Pre-Medical"],
|
| 101 |
+
"min_marks": 70,
|
| 102 |
+
"description": "Medical degree programs",
|
| 103 |
+
"careers": ["MBBS (5 years)", "BDS (4 years)", "Doctor of Physiotherapy (5 years)"],
|
| 104 |
+
"color": "#EF476F",
|
| 105 |
+
"icon": "🏥",
|
| 106 |
+
"level": "University"
|
| 107 |
+
},
|
| 108 |
+
"Engineering Programs": {
|
| 109 |
+
"prerequisites": ["Pre-Engineering"],
|
| 110 |
+
"min_marks": 65,
|
| 111 |
+
"description": "Engineering degree programs",
|
| 112 |
+
"careers": ["BS Mechanical Engineering", "BS Electrical Engineering"],
|
| 113 |
+
"color": "#118AB2",
|
| 114 |
+
"icon": "🏗️",
|
| 115 |
+
"level": "University"
|
| 116 |
+
},
|
| 117 |
+
"Computer Science Programs": {
|
| 118 |
+
"prerequisites": ["ICS"],
|
| 119 |
+
"min_marks": 55,
|
| 120 |
+
"description": "Technology degree programs",
|
| 121 |
+
"careers": ["BS Computer Science", "BS Software Engineering"],
|
| 122 |
+
"color": "#FFD166",
|
| 123 |
+
"icon": "🤖",
|
| 124 |
+
"level": "University"
|
| 125 |
+
},
|
| 126 |
+
"Business Programs": {
|
| 127 |
+
"prerequisites": ["Commerce"],
|
| 128 |
+
"min_marks": 50,
|
| 129 |
+
"description": "Business degree programs",
|
| 130 |
+
"careers": ["BBA", "BS Accounting & Finance"],
|
| 131 |
+
"color": "#06D6A0",
|
| 132 |
+
"icon": "📈",
|
| 133 |
+
"level": "University"
|
| 134 |
+
},
|
| 135 |
+
"Liberal Arts": {
|
| 136 |
+
"min_marks": 45,
|
| 137 |
+
"description": "General degree programs",
|
| 138 |
+
"careers": ["BA English", "BS Social Sciences", "BFA Arts"],
|
| 139 |
+
"color": "#7209B7",
|
| 140 |
+
"icon": "📚",
|
| 141 |
+
"level": "University"
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
def apply_theme():
|
| 146 |
+
st.markdown(f"""
|
| 147 |
+
<style>
|
| 148 |
+
.pathway-card {{
|
| 149 |
+
border-radius: 15px;
|
| 150 |
+
padding: 20px;
|
| 151 |
+
margin: 15px 0;
|
| 152 |
+
background: white;
|
| 153 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
| 154 |
+
border-left: 5px solid var(--color);
|
| 155 |
+
}}
|
| 156 |
+
.header-text {{
|
| 157 |
+
color: {THEME['primary']};
|
| 158 |
+
font-size: 2.5rem;
|
| 159 |
+
}}
|
| 160 |
+
.subject-pill {{
|
| 161 |
+
display: inline-block;
|
| 162 |
+
padding: 0.2em 0.6em;
|
| 163 |
+
margin: 0.2em;
|
| 164 |
+
border-radius: 15px;
|
| 165 |
+
background-color: {THEME['secondary']};
|
| 166 |
+
color: white;
|
| 167 |
+
font-size: 0.9em;
|
| 168 |
+
}}
|
| 169 |
+
.core-subject {{
|
| 170 |
+
font-weight: bold;
|
| 171 |
+
color: {THEME['primary']};
|
| 172 |
+
}}
|
| 173 |
+
.subject-selector {{
|
| 174 |
+
margin-top: 10px;
|
| 175 |
+
border: 1px solid {THEME['secondary']};
|
| 176 |
+
border-radius: 5px;
|
| 177 |
+
padding: 10px;
|
| 178 |
+
}}
|
| 179 |
+
</style>
|
| 180 |
+
""", unsafe_allow_html=True)
|
| 181 |
+
|
| 182 |
+
def show_recommendations():
|
| 183 |
+
st.title(f"🌟 Your Academic Pathway")
|
| 184 |
+
st.markdown(f"<h4 style='color:{THEME['secondary']}'>Based on {st.session_state.marks}% marks in {st.session_state.education_level}</h4>",
|
| 185 |
+
unsafe_allow_html=True)
|
| 186 |
+
|
| 187 |
+
for pathway in st.session_state.recommendations:
|
| 188 |
+
if pathway not in PATHWAYS:
|
| 189 |
+
continue # Skip invalid pathways
|
| 190 |
+
|
| 191 |
+
details = PATHWAYS[pathway]
|
| 192 |
+
|
| 193 |
+
st.markdown(f"""
|
| 194 |
+
<div class="pathway-card" style="--color: {details['color']}">
|
| 195 |
+
<h3>{details['icon']} {pathway}</h3>
|
| 196 |
+
<p><strong>Level:</strong> {details['level']}</p>
|
| 197 |
+
<p><strong>Description:</strong> {details['description']}</p>
|
| 198 |
+
<p><strong>Your Marks:</strong> <span style="color:{THEME['primary']}">
|
| 199 |
+
{st.session_state.marks}%</span> (Minimum required: {details['min_marks']}%)</p>
|
| 200 |
+
<p><strong>Career Options:</strong></p>
|
| 201 |
+
<ul>
|
| 202 |
+
{''.join([f'<li>{career}</li>' for career in details['careers']])}
|
| 203 |
+
</ul>
|
| 204 |
+
</div>
|
| 205 |
+
""", unsafe_allow_html=True)
|
| 206 |
+
|
| 207 |
+
st.balloons()
|
| 208 |
+
|
| 209 |
+
def main():
|
| 210 |
+
apply_theme()
|
| 211 |
+
|
| 212 |
+
# Welcome Page
|
| 213 |
+
if "student_name" not in st.session_state:
|
| 214 |
+
st.markdown('<h1 class="header-text">🎓 Edusphere</h1>', unsafe_allow_html=True)
|
| 215 |
+
st.markdown("### Your Complete Educational Pathway Advisor")
|
| 216 |
+
|
| 217 |
+
name = st.text_input("Enter your name:")
|
| 218 |
+
if st.button("Begin Journey", type="primary"):
|
| 219 |
+
if name.strip():
|
| 220 |
+
st.session_state.student_name = name.title()
|
| 221 |
+
st.rerun()
|
| 222 |
+
else:
|
| 223 |
+
st.warning("Please enter your name")
|
| 224 |
+
return
|
| 225 |
+
|
| 226 |
+
# Education Level Selection
|
| 227 |
+
if "education_level" not in st.session_state:
|
| 228 |
+
st.title(f"Welcome, {st.session_state.student_name}!")
|
| 229 |
+
st.markdown("### Select your current education level:")
|
| 230 |
+
|
| 231 |
+
col1, col2 = st.columns(2)
|
| 232 |
+
with col1:
|
| 233 |
+
if st.button("Matric/SSC/O-Level"):
|
| 234 |
+
st.session_state.education_level = "School"
|
| 235 |
+
st.session_state.next_step = "Intermediate"
|
| 236 |
+
st.rerun()
|
| 237 |
+
with col2:
|
| 238 |
+
if st.button("Intermediate/HSSC/A-Level"):
|
| 239 |
+
st.session_state.education_level = "College"
|
| 240 |
+
st.session_state.next_step = "University"
|
| 241 |
+
st.rerun()
|
| 242 |
+
return
|
| 243 |
+
|
| 244 |
+
# Main Form
|
| 245 |
+
if "recommendations" not in st.session_state:
|
| 246 |
+
st.title(f"Your {st.session_state.next_step} Pathway")
|
| 247 |
+
|
| 248 |
+
with st.form("academic_info"):
|
| 249 |
+
# Common fields
|
| 250 |
+
marks = st.number_input("Overall Percentage (%)",
|
| 251 |
+
min_value=0, max_value=100,
|
| 252 |
+
value=70)
|
| 253 |
+
st.session_state.marks = marks
|
| 254 |
+
|
| 255 |
+
# School-level specific
|
| 256 |
+
if st.session_state.education_level == "School":
|
| 257 |
+
education_type = st.selectbox("Education System",
|
| 258 |
+
["Matric/SSC", "O-Level"])
|
| 259 |
+
stream = st.selectbox("Stream",
|
| 260 |
+
["Science", "Arts", "Commerce"] if education_type == "O-Level"
|
| 261 |
+
else ["Science", "Arts"])
|
| 262 |
+
subjects = st.multiselect(
|
| 263 |
+
"Subjects Studied",
|
| 264 |
+
PRE_UNIVERSITY[education_type][stream],
|
| 265 |
+
default=PRE_UNIVERSITY[education_type][stream][:3]
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
# College-level specific
|
| 269 |
+
else:
|
| 270 |
+
program_type = st.selectbox("Program Type",
|
| 271 |
+
["Intermediate/HSSC", "A-Level"])
|
| 272 |
+
|
| 273 |
+
if program_type == "Intermediate/HSSC":
|
| 274 |
+
program = st.selectbox("Select Program",
|
| 275 |
+
["Pre-Medical", "Pre-Engineering", "ICS", "Commerce"])
|
| 276 |
+
|
| 277 |
+
# Display core subjects as selectable checkboxes
|
| 278 |
+
st.markdown("<p class='core-subject'>Core Subjects (Select All):</p>", unsafe_allow_html=True)
|
| 279 |
+
with st.container(border=True):
|
| 280 |
+
core_subjects = PRE_UNIVERSITY["Intermediate/HSSC"][program]["core"]
|
| 281 |
+
selected_core = []
|
| 282 |
+
cols = st.columns(4)
|
| 283 |
+
for i, sub in enumerate(core_subjects):
|
| 284 |
+
with cols[i%4]:
|
| 285 |
+
if st.checkbox(sub, value=True, key=f"core_{sub}"):
|
| 286 |
+
selected_core.append(sub)
|
| 287 |
+
|
| 288 |
+
# Optional subjects
|
| 289 |
+
if PRE_UNIVERSITY["Intermediate/HSSC"][program]["optional"]:
|
| 290 |
+
optional = st.multiselect(
|
| 291 |
+
"Additional Subjects (Optional)",
|
| 292 |
+
PRE_UNIVERSITY["Intermediate/HSSC"][program]["optional"]
|
| 293 |
+
)
|
| 294 |
+
subjects = selected_core + optional
|
| 295 |
+
else:
|
| 296 |
+
subjects = selected_core
|
| 297 |
+
else: # A-Level
|
| 298 |
+
program = st.selectbox("Select Stream", ["Science", "Commerce"])
|
| 299 |
+
subjects = st.multiselect(
|
| 300 |
+
"Select 3-4 Principal Subjects",
|
| 301 |
+
PRE_UNIVERSITY["A-Level"][program],
|
| 302 |
+
default=PRE_UNIVERSITY["A-Level"][program][:3]
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
+
career_interest = st.selectbox(
|
| 306 |
+
"Career Interest",
|
| 307 |
+
["Medical", "Engineering", "Computer Science", "Business", "Undecided"]
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
+
if st.form_submit_button("Generate Pathways", type="primary"):
|
| 311 |
+
st.session_state.recommendations = []
|
| 312 |
+
|
| 313 |
+
# School to Intermediate logic
|
| 314 |
+
if st.session_state.education_level == "School":
|
| 315 |
+
subjects_set = set(subjects)
|
| 316 |
+
|
| 317 |
+
if {"Biology", "Chemistry", "Physics"}.issubset(subjects_set) and marks >= 65:
|
| 318 |
+
if career_interest in ["Medical", "Undecided"]:
|
| 319 |
+
st.session_state.recommendations.append("Pre-Medical")
|
| 320 |
+
|
| 321 |
+
if {"Mathematics", "Physics", "Chemistry"}.issubset(subjects_set) and marks >= 60:
|
| 322 |
+
if career_interest in ["Engineering", "Undecided"]:
|
| 323 |
+
st.session_state.recommendations.append("Pre-Engineering")
|
| 324 |
+
|
| 325 |
+
if len(st.session_state.recommendations) == 0:
|
| 326 |
+
st.session_state.recommendations.append("General Arts")
|
| 327 |
+
|
| 328 |
+
# Intermediate to University logic
|
| 329 |
else:
|
| 330 |
subjects_set = set(subjects)
|
| 331 |
|
|
|
|
| 350 |
st.session_state.recommendations.append("Business Programs")
|
| 351 |
|
| 352 |
if len(st.session_state.recommendations) == 0:
|
| 353 |
+
st.session_state.recommendations.append("Liberal Arts")
|
| 354 |
+
|
| 355 |
+
st.rerun()
|
| 356 |
+
return
|
| 357 |
+
|
| 358 |
+
# Results Page
|
| 359 |
+
show_recommendations()
|
| 360 |
+
|
| 361 |
+
if st.button("Explore Another Pathway", type="primary"):
|
| 362 |
+
# Clear all session state and return to name entry
|
| 363 |
+
for key in list(st.session_state.keys()):
|
| 364 |
+
del st.session_state[key]
|
| 365 |
+
st.rerun()
|
| 366 |
+
|
| 367 |
+
if __name__ == "__main__":
|
| 368 |
+
main()
|