-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.py
More file actions
163 lines (140 loc) · 6.1 KB
/
testing.py
File metadata and controls
163 lines (140 loc) · 6.1 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import streamlit as st
# --- Page Config ---
st.set_page_config(
page_title="Smart Learning Path",
page_icon="🧠",
layout="centered",
initial_sidebar_state="collapsed"
)
# --- Title and Footer Hiding ---
st.title("📚 Smart Learning Path Generator")
st.markdown("#### Learn smarter with your personal AI guide 🚀")
# Hide Streamlit footer and menu
hide_footer = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_footer, unsafe_allow_html=True)
# --- Quiz Title ---
st.title("🎓 Personalized Learning Path Generator")
st.markdown("Take a short quiz to discover your learning style and get a custom learning path!")
# --- Quiz Questions ---
questions = [
{
"question": "When trying to remember a phone number, what do you do?",
"options": ["Visualize the number in your head", "Say the number aloud or in your head"]
},
{
"question": "What helps you learn new material best?",
"options": ["Watching videos or looking at diagrams", "Listening to podcasts or lectures"]
},
{
"question": "How do you prefer to study?",
"options": ["Using highlighters and charts", "Repeating things out loud or recording notes"]
}
]
# Initialize scores
visual_score = 0
auditory_score = 0
answers = []
# --- Quiz Form ---
with st.form("quiz_form"):
for idx, q in enumerate(questions):
answer = st.radio(f"**{q['question']}**", q["options"], key=idx)
answers.append(answer)
submitted = st.form_submit_button("Submit Quiz")
# --- Quiz Results ---
def new_func(style):
plan_text = generate_learning_plan_text(style)
return plan_text
if submitted:
for ans in answers:
if "Visual" in ans or "diagrams" in ans or "charts" in ans:
visual_score += 1
else:
auditory_score += 1
if visual_score > auditory_score:
style = "visual"
st.success("🧠 You are a **Visual Learner**")
elif auditory_score > visual_score:
style = "auditory"
st.success("🎧 You are an **Auditory Learner**")
else:
style = "balanced"
st.success("🌀 You are a **Balanced Learner**")
# --- Show Learning Path ---
def show_learning_path(style):
st.markdown("---")
st.header("📘 Your Personalized Learning Path")
paths = {
"visual": [
("Mastering Concepts Visually", "Use diagrams and infographics to grasp fundamentals.",
"https://www.youtube.com/watch?v=ZFDHcZZnBK4"),
("Video-Powered Learning", "Watch expert tutorials with visual aids.",
"https://www.youtube.com/watch?v=IN-_S_jj3gE"),
("Visual Note-Taking", "Summarize information using mind maps and charts.",
"https://www.youtube.com/watch?v=RVDfWfXJFxg")
],
"auditory": [
("Audio Lessons", "Start with narrated guides or lectures.",
"https://www.youtube.com/watch?v=wBqeZLgv2Cg"),
("Interactive Listening", "Participate in audio-based discussions.",
"https://www.youtube.com/watch?v=6zFvIwcGkO4"),
("Voice Note Practice", "Practice summarizing lessons by speaking them aloud.",
"https://www.youtube.com/watch?v=LMX2pTUS1m8")
],
"balanced": [
("Mixed Mode Learning", "Combine video and audio content to maximize retention.",
"https://www.youtube.com/watch?v=spUNpyF58BY"),
("Blended Study Tools", "Use both diagrams and voice recordings.",
"https://www.youtube.com/watch?v=ECcjHthLN2I"),
("Self-Test Toolkit", "Alternate between flashcards and verbal repetition.",
"https://www.youtube.com/watch?v=F1y0RS5Uv_M")
]
}
for i, (title, desc, video_url) in enumerate(paths[style], 1):
st.subheader(f"📘 Module {i}: {title}")
st.write(f"📝 {desc}")
st.video(video_url)
# Progress checkbox with session state handling
key = f"module_{i}_done"
# Initialize session state for each module if not already done
if key not in st.session_state:
st.session_state[key] = False
# Display and track the checkbox state
checkbox_state = st.checkbox(f"✅ Mark Module {i} as Done", value=st.session_state[key], key=key)
# Update the session state with the new checkbox state after user interaction
st.session_state[key] = checkbox_state
st.markdown("---")
# Call function to show the learning path
show_learning_path(style)
# --- Download Plan ---
st.markdown("### 🧾 Download Your Plan")
plan_text = new_func(style)
st.download_button("📥 Download Plan (TXT)", plan_text, file_name="learning_plan.txt")
# --- Generate Learning Plan Text ---
def generate_learning_plan_text(style):
plans = {
"visual": [
"1. Mastering Concepts Visually - Use diagrams and infographics.",
"2. Video-Powered Learning - Watch tutorials with visual aids.",
"3. Visual Note-Taking - Create mind maps and flowcharts."
],
"auditory": [
"1. Audio Lessons - Start with narrated guides.",
"2. Interactive Listening - Join audio-based discussions.",
"3. Voice Note Practice - Summarize lessons by speaking aloud."
],
"balanced": [
"1. Mixed Mode Learning - Combine video and audio formats.",
"2. Blended Study Tools - Use diagrams & voice recordings.",
"3. Self-Test Toolkit - Alternate flashcards & verbal recaps."
]
}
plan_lines = [
f"Personalized Learning Plan ({style.title()} Learner)\n",
"----------------------------------------\n"
] + plans[style]
return "\n".join(plan_lines)