Sabir55 commited on
Commit
d9cca9a
ยท
verified ยท
1 Parent(s): 2fc8f52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -236
app.py CHANGED
@@ -12,7 +12,7 @@ st.set_page_config(page_title="AI For Everyone", layout="wide")
12
  os.makedirs("audio", exist_ok=True)
13
 
14
  # -------------------------------
15
- # Analytics & Leaderboard
16
  # -------------------------------
17
  if "analytics" not in st.session_state:
18
  st.session_state.analytics = {}
@@ -22,13 +22,16 @@ if "started" not in st.session_state:
22
  st.session_state.started = False
23
 
24
  # -------------------------------
25
- # Clean Filename
26
  # -------------------------------
27
  def clean_filename(text):
28
  return re.sub(r"[^\w\s-]", "", text).replace(" ", "_")
29
 
 
 
 
30
  # -------------------------------
31
- # Certificate Generator (DigiSkills style)
32
  # -------------------------------
33
  def create_certificate(user, topic, score):
34
  pdf = FPDF(orientation="L", unit="mm", format="A4")
@@ -40,30 +43,30 @@ def create_certificate(user, topic, score):
40
  pdf.set_text_color(255, 255, 255)
41
  pdf.set_font("Arial", "B", 22)
42
  pdf.set_y(5)
43
- pdf.cell(0, 10, "FUTURE TECH LEADERS", ln=True, align="C")
44
 
45
  # Main content
46
  pdf.set_y(35)
47
  pdf.set_text_color(0, 0, 0)
48
  pdf.set_font("Arial", "B", 28)
49
- pdf.cell(0, 15, user.upper(), ln=True, align="C")
50
 
51
  pdf.set_font("Arial", "", 16)
52
- pdf.cell(0, 10, f"has completed the training in {topic.upper()} under", ln=True, align="C")
53
- pdf.cell(0, 10, "AI For Everyone โ€“ Digital Literacy Hub", ln=True, align="C")
54
 
55
  pdf.set_font("Arial", "I", 12)
56
- pdf.cell(0, 10, "Batch-01 | Jul 2025 - Sep 2025", ln=True, align="C")
57
 
58
  pdf.set_font("Arial", "", 14)
59
  pdf.ln(4)
60
- pdf.cell(0, 10, f"Score Achieved: {score}/5", ln=True, align="C")
61
 
62
  # Footer
63
  pdf.set_y(-35)
64
  pdf.set_font("Arial", "I", 11)
65
  pdf.cell(0, 10, f"Issue Date: {datetime.today().strftime('%d/%m/%Y')}", ln=True, align="C")
66
- pdf.cell(0, 10, "Issued by Future Tech Leaders", ln=True, align="C")
67
  cert_id = f"FTL-{datetime.now().strftime('%y%m%d%H%M%S')}"
68
  pdf.cell(0, 10, f"Certificate ID: {cert_id}", ln=True, align="C")
69
 
@@ -82,234 +85,40 @@ def generate_audio_if_missing(topic, text):
82
  return filename
83
 
84
  # -------------------------------
85
- # Insert 10 full AI modules here
86
- # Replace with your full topics from previous steps
87
- # Each topic should have: "intro": [...], "quiz": [{q, O, A}, ...]
88
  # -------------------------------
89
  modules = {
90
  "What is AI?": {
91
  "intro": [
92
- "Artificial Intelligence (AI) is the field of computer science that aims to create machines capable of intelligent behavior.",
93
- "It involves building systems that can learn from data, reason through logic, perceive their environment, and make decisions.",
94
- "AI is used in everyday applications like voice assistants, image recognition, and recommendation engines.",
95
- "It draws on statistics, data mining, and machine learning algorithms.",
96
- "AI can help automate repetitive tasks, saving time and reducing human error.",
97
- "It powers self-driving cars, fraud detection systems, and smart healthcare tools.",
98
- "There are different levelsโ€”such as narrow AI (task-specific) and general AI (multi-purpose).",
99
- "Narrow AI is what we have today; general AI remains a future goal.",
100
- "Understanding AI helps individuals adapt to the changing job market.",
101
- "Ethical AI usage ensures fairness, transparency, and privacy.",
102
- "Learning AI foundations enables you to innovate in various industries.",
103
- "As data becomes central to modern life, AI skills become more essential."
104
- ],
105
- "quiz": [
106
- {"q": "AI stands for?", "O": ["Automated Interface","Artificial Intelligence","Applied Informatics","Advanced Integration"], "A": "Artificial Intelligence"},
107
- {"q": "Narrow AI refers to systems that are?", "O": ["Task-specific","Human-like","Self-aware","Multilingual"], "A": "Task-specific"},
108
- {"q": "Which powers voice assistants?", "O": ["AI","Manual Input","Open Source","Wireless"], "A": "AI"},
109
- {"q": "General AI means?", "O": ["One task only","Human-level intelligence","Collecting data","Math only"], "A": "Human-level intelligence"},
110
- {"q": "AI systems learn from?", "O": ["Data","Magic","Sunlight","Noise"], "A": "Data"}
111
- ]
112
- },
113
- "How ChatGPT Works": {
114
- "intro": [
115
- "ChatGPT is a language model built by OpenAI using deep learning techniques.",
116
- "It was trained on a large dataset that includes books, articles, and websites.",
117
- "It uses a transformer neural network architecture to predict the next word in a sentence.",
118
- "By learning patterns of language, ChatGPT can generate fluent and coherent responses.",
119
- "It can answer questions, write essays, help with code, and even generate creative content.",
120
- "However, it does not truly understand meaningโ€”it relies on statistical patterns.",
121
- "ChatGPT works best when prompts are specific and clear.",
122
- "It's important to verify its output, especially for critical information.",
123
- "Developers can use API endpoints to integrate ChatGPT into other tools.",
124
- "AI creativity is impressiveโ€”but it may hallucinate if incorrectly prompted.",
125
- "Ethical guidelines inform its usage: no hate speech, personal data misuse, or harmful content.",
126
- "Understanding ChatGPT helps learners leverage AI responsibly."
127
  ],
128
  "quiz": [
129
- {"q": "ChatGPT is built by?", "O": ["Google","Meta","OpenAI","Amazon"], "A": "OpenAI"},
130
- {"q": "It uses which neural net?", "O": ["CNN","RNN","Transformer","KNN"], "A": "Transformer"},
131
- {"q": "ChatGPT generates text by predicting?", "O": ["Next word","Image pixels","Sound frequency","Encryption keys"], "A": "Next word"},
132
- {"q": "Model trained on?", "O": ["Videos","Text data","Audio only","No data"], "A": "Text data"},
133
- {"q": "Always verify its?", "O": ["Cooking skills","Factual output","Voice tone","Font size"], "A": "Factual output"}
134
  ]
135
  },
136
- "Types of AI": {
137
- "intro": [
138
- "AI can be categorized into Narrow AI, General AI, and Super AI.",
139
- "Narrow AI performs specific tasks like translation or gameplay.",
140
- "General AI would have human-like intelligence across domains - it's still a goal.",
141
- "Super AI would surpass human intelligence in every aspect - purely theoretical today.",
142
- "Narrow AI is abundant: speech recognition, spam filters, recommendation engines.",
143
- "General and Super AI are topics of research and science fiction.",
144
- "Ethical safeguards are crucial as AI capabilities grow.",
145
- "Understanding AI categories helps set realistic expectations.",
146
- "Todayโ€™s AI is powerful but limited by design.",
147
- "Progress toward general AI involves integrating reasoning, planning, and learning."
148
- ],
149
- "quiz": [
150
- {"q": "Narrow AI does?", "O": ["Everything","One task","No tasks","Future tasks"], "A": "One task"},
151
- {"q": "General AI equals?", "O": ["Calc machine","Human-like intelligence","Traffic light","Login system"], "A": "Human-like intelligence"},
152
- {"q": "Super AI is?", "O": ["Here now","Future concept","Manual machine","Simple code"], "A": "Future concept"},
153
- {"q": "Translation apps use?", "O": ["Narrow AI","Super AI","No AI","Magic"], "A": "Narrow AI"},
154
- {"q": "Spam filters are?", "O": ["General AI","Narrow AI","No AI","Super AI"], "A": "Narrow AI"}
155
- ]
156
- },
157
- "AI in Daily Life": {
158
- "intro": [
159
- "AI is present in our daily routines: face unlock, recommendations, search.",
160
- "Streaming platforms use AI to recommend songs and videos.",
161
- "Navigation apps use AI to optimize routes and avoid traffic.",
162
- "Banks use AI to detect fraud and assess loan risks.",
163
- "E-commerce uses AI to show personalized product suggestions.",
164
- "Smart homes use AI for voice control, thermostats, and lighting.",
165
- "Healthcare uses AI to aid in diagnosis and personalized treatments.",
166
- "Language translation apps use AI for real-time communication.",
167
- "Smart agriculture uses AI for irrigation, yield prediction, and pest control.",
168
- "Understanding these everyday uses helps appreciate AIโ€™s impact."
169
- ],
170
- "quiz": [
171
- {"q": "Face unlock uses?", "O": ["AI","Password","QR code","Manual"], "A": "AI"},
172
- {"q": "YouTube suggests videos based on?", "O": ["AI","Manual","Coin Toss","Ads"], "A": "AI"},
173
- {"q": "Navigation apps predict?", "O": ["Weather only","Traffic patterns","Random","Lyrics"], "A": "Traffic patterns"},
174
- {"q": "Banks use AI for?", "O": ["Fraud detection","Cooking","Car wash","Gaming"], "A": "Fraud detection"},
175
- {"q": "Smart homes can?", "O": ["AI control","Time travel","Teleportation","None"], "A": "AI control"}
176
- ]
177
- },
178
- "ML vs DL": {
179
- "intro": [
180
- "Machine Learning (ML) is a subset of AI focused on learning from data.",
181
- "Deep Learning (DL) is a specialized ML method using neural networks with multiple layers.",
182
- "ML algorithms include linear regression, decision trees, SVM.",
183
- "DL uses neural network architectures like CNNs and RNNs.",
184
- "DL is powerful for images, voice, and unstructured data.",
185
- "ML works well for smaller datasets and structured data.",
186
- "DL needs large datasets and computational resources.",
187
- "ML models are easier to interpret; DL models are often opaque.",
188
- "Use case guides choice: ML for tabular data, DL for media recognition.",
189
- "Knowing this helps choose the right approach for a project."
190
- ],
191
- "quiz": [
192
- {"q": "ML learns from?", "O": ["Data only","Magic","Nothing","Sunlight"], "A": "Data only"},
193
- {"q": "DL uses?", "O": ["Neural networks","Manual rules","Static code","Papers"], "A": "Neural networks"},
194
- {"q": "DL works best with?", "O": ["Lots of data","Little data","No data","Water"], "A": "Lots of data"},
195
- {"q": "ML models are?", "O": ["Interpretable","Invisible","Random","Imaginary"], "A": "Interpretable"},
196
- {"q": "Image recognition uses?", "O": ["DL","ML only","No AI","Analog"], "A": "DL"}
197
- ]
198
- },
199
- "Deepfakes & Misinformation": {
200
- "intro": [
201
- "Deepfakes are synthetic media created using AI.",
202
- "They can manipulate images, audio, and video to create false realities.",
203
- "These can spread misinformation and harm reputation.",
204
- "AI-generated fake content makes media trust more complex.",
205
- "Verifying authenticity is critical in news and social platforms.",
206
- "Deepfakes may target public figures or individuals.",
207
- "Tools exist to help detect fakes, but technology evolves quickly.",
208
- "Responsibly sharing media includes verifying before posting.",
209
- "Public awareness is the best defense against deepfake misuse.",
210
- "Learning this protects communities and democracy."
211
- ],
212
- "quiz": [
213
- {"q": "Deepfake means?", "O": ["Real video","Fake video","News article","Game"], "A": "Fake video"},
214
- {"q": "They use?", "O": ["AI","Coin toss","Weather","Manual"], "A": "AI"},
215
- {"q": "Effect of deepfakes?", "O": ["Trust erosion","Fun only","Health boost","Wealth"], "A": "Trust erosion"},
216
- {"q": "To prevent fake news you?", "O": ["Verify source","Trust all","Ignore everything","Respect rumors"], "A": "Verify source"},
217
- {"q": "Detection tools use?", "O": ["AI","Magic","Guess","No method"], "A": "AI"}
218
- ]
219
- },
220
- "Data Privacy Basics": {
221
- "intro": [
222
- "Data privacy is about keeping personal information safe.",
223
- "Personal data includes names, photos, location, health records.",
224
- "Many apps collect dataโ€”it's important to know which you allow.",
225
- "Strong passwords and 2FA protect online accounts.",
226
- "Data sharing can expose you to scams and identity theft.",
227
- "Privacy settings in apps empower users to choose control.",
228
- "GDPR and similar laws protect user data rights.",
229
- "Awareness helps prevent misuse by bad actors.",
230
- "Encrypted communication like HTTPS secures your data.",
231
- "Smart data handling builds trust and safety online."
232
- ],
233
- "quiz": [
234
- {"q": "Privacy protects?", "O": ["Personal info","Weather","Rivers","Animals"], "A": "Personal info"},
235
- {"q": "2FA means?", "O": ["Double Factor Authentication","2 Forms Access","Two Fun Activities","None"], "A": "Double Factor Authentication"},
236
- {"q": "Encrypted sites use?", "O": ["HTTPS","HTTP","FTP","POP3"], "A": "HTTPS"},
237
- {"q": "Avoid sharing?", "O": ["Passwords","Jokes","Memes","Songs"], "A": "Passwords"},
238
- {"q": "Privacy laws include?", "O": ["GDPR","HTML","NoSQL","CSS"], "A": "GDPR"}
239
- ]
240
- },
241
- "Ethics in AI": {
242
- "intro": [
243
- "AI ethics is about responsible, fair, and transparent AI usage.",
244
- "Biased data can lead to unfair decisions in AI systems.",
245
- "Ethical AI respects privacy and avoids discrimination.",
246
- "Transparency means understanding how AI reaches decisions.",
247
- "Regulations guide developers to use AI responsibly.",
248
- "We must balance innovation with societal well-being.",
249
- "Involving users in decisions builds trust in AI systems.",
250
- "Ethical design empowers all stakeholders equally.",
251
- "Learning AI ethics creates safer and fairer technologies.",
252
- "Your knowledge can ensure AI benefits everyone."
253
- ],
254
- "quiz": [
255
- {"q": "AI ethics ensures?", "O": ["Fairness","Speed","Cost","None"], "A": "Fairness"},
256
- {"q": "Biased AI can?", "O": ["Discriminate","Cook","Paint","Drive"], "A": "Discriminate"},
257
- {"q": "Transparency means?", "O": ["Explain decisions","Hide code","Blur data","Remove users"], "A": "Explain decisions"},
258
- {"q": "Ethical AI respects?", "O": ["Privacy","Speed","Noise","Weight"], "A": "Privacy"},
259
- {"q": "Ethical design builds?", "O": ["Trust","Fear","Spam","Ads"], "A": "Trust"}
260
- ]
261
- },
262
- "Computer Vision & CV": {
263
- "intro": [
264
- "Computer Vision (CV) enables machines to interpret visual data.",
265
- "It uses cameras, sensors, and algorithms to process images.",
266
- "CV applications include facial recognition, object tracking, and medical imaging.",
267
- "It uses CNNs, image filters, and feature extraction techniques.",
268
- "CV helps quality inspection in factories and autonomous vehicles.",
269
- "It can read handwritten text and diagnose diseases from scans.",
270
- "Real-time video analysis helps surveillance and safety.",
271
- "CV combined with AI enables powerful automation solutions.",
272
- "Understanding CV opens doors to robotics and intelligent systems.",
273
- "Ethical CV requires consent and data protection in public spaces."
274
- ],
275
- "quiz": [
276
- {"q": "CV stands for?", "O": ["Core Vision","Computer Vision","Camera View","Control Voice"], "A": "Computer Vision"},
277
- {"q": "CV uses?", "O": ["Images","Audio","Text only","None"], "A": "Images"},
278
- {"q": "CNN is used in?", "O": ["CV","Typing","Email","Games"], "A": "CV"},
279
- {"q": "CV helps in factories by?", "O": ["Inspecting products","Cooking","Sleeping","Entertainment"], "A": "Inspecting products"},
280
- {"q": "CV requires ?", "O": ["Privacy","Cameras","Coins","Walls"], "A": "Cameras"}
281
- ]
282
- },
283
- "AI in Healthcare": {
284
- "intro": [
285
- "AI improves healthcare by analyzing medical images for diagnosis.",
286
- "It can detect anomalies in X-rays, MRIs and CT scans.",
287
- "Predictive models help in identifying disease risks early.",
288
- "AI-driven robots assist in surgeries with precision.",
289
- "Chatbots help patients with common health queries.",
290
- "Drug discovery processes are accelerated by AI algorithms.",
291
- "Personalized care plans benefit from AI data analysis.",
292
- "Hospital administration uses AI for scheduling and predictions.",
293
- "Wearable AI devices monitor vitals and alert emergencies.",
294
- "Ethical use ensures patient privacy and unbiased care."
295
- ],
296
- "quiz": [
297
- {"q": "AI in imaging helps detect?", "O": ["Diseases","Music","Movies","Weather"], "A": "Diseases"},
298
- {"q": "Predictive AI finds?", "O": ["Risks early","New jokes","Songs","Photos"], "A": "Risks early"},
299
- {"q": "Surgery robots are?", "O": ["AI-assisted","Manual only","Electric fans","Toys"], "A": "AI-assisted"},
300
- {"q": "Chatbots in healthcare?", "O": ["Answer questions","Cook food","Dance","Sleep"], "A": "Answer questions"},
301
- {"q": "Wearables monitor?", "O": ["Vitals","Sand","Stars","Cars"], "A": "Vitals"}
302
- ]
303
- }
304
  }
305
 
306
- # Initialize analytics & leaderboard for all topics
307
  for topic in modules:
308
  st.session_state.analytics.setdefault(topic, 0)
309
  st.session_state.leaderboard.setdefault(topic, [])
310
 
311
  # -------------------------------
312
- # Show Module + Quiz
313
  # -------------------------------
314
  def show_module(topic):
315
  explanation = "\n\n".join(modules[topic]["intro"])
@@ -344,9 +153,8 @@ def show_module(topic):
344
  cert = create_certificate(name, topic, score)
345
  st.download_button("๐Ÿ“„ Download Certificate", data=open(cert, "rb"), file_name=cert, mime="application/pdf")
346
 
347
- share_text = f"I scored {score}/5 on '{topic}'! ๐ŸŽ“ #AIForEveryone"
348
- st.markdown(f"[๐Ÿ”— Share on WhatsApp](https://wa.me/?text={share_text}) | "
349
- f"[๐Ÿฆ Share on Twitter](https://twitter.com/intent/tweet?text={share_text})")
350
 
351
  st.subheader("โœ… Answer Key:")
352
  for i, qd in enumerate(modules[topic]["quiz"]):
@@ -357,26 +165,26 @@ def show_module(topic):
357
  # -------------------------------
358
  if not st.session_state.started:
359
  st.title("๐Ÿค– AI For Everyone โ€“ Future Tech Leaders")
360
- st.markdown("### Empowering global learners with audio, quizzes, certificates, and AI education.")
361
  if st.button("๐Ÿš€ Get Started Now"):
362
  st.session_state.started = True
363
  st.stop()
364
 
365
  # -------------------------------
366
- # Sidebar Info
367
  # -------------------------------
368
  st.sidebar.title("๐Ÿ“˜ Topics")
369
  topic = st.selectbox("Choose your module:", list(modules.keys()))
370
 
371
- st.sidebar.subheader("๐Ÿ“Š Analytics")
372
- for t, v in st.session_state.analytics.items():
373
- st.sidebar.write(f"{t}: {v} completed")
374
 
375
- st.sidebar.subheader("๐Ÿ† Leaderboards")
376
- for t, v in st.session_state.leaderboard.items():
377
- if v:
378
- st.sidebar.markdown(f"**{t}**")
379
- for entry in v:
380
  st.sidebar.write(f"{entry['name']}: {entry['score']}/5")
381
 
382
  # -------------------------------
 
12
  os.makedirs("audio", exist_ok=True)
13
 
14
  # -------------------------------
15
+ # Session State Setup
16
  # -------------------------------
17
  if "analytics" not in st.session_state:
18
  st.session_state.analytics = {}
 
22
  st.session_state.started = False
23
 
24
  # -------------------------------
25
+ # Helpers
26
  # -------------------------------
27
  def clean_filename(text):
28
  return re.sub(r"[^\w\s-]", "", text).replace(" ", "_")
29
 
30
+ def remove_non_latin(text):
31
+ return text.encode("latin-1", "ignore").decode("latin-1")
32
+
33
  # -------------------------------
34
+ # Certificate Generator
35
  # -------------------------------
36
  def create_certificate(user, topic, score):
37
  pdf = FPDF(orientation="L", unit="mm", format="A4")
 
43
  pdf.set_text_color(255, 255, 255)
44
  pdf.set_font("Arial", "B", 22)
45
  pdf.set_y(5)
46
+ pdf.cell(0, 10, remove_non_latin("FUTURE TECH LEADERS"), ln=True, align="C")
47
 
48
  # Main content
49
  pdf.set_y(35)
50
  pdf.set_text_color(0, 0, 0)
51
  pdf.set_font("Arial", "B", 28)
52
+ pdf.cell(0, 15, remove_non_latin(user.upper()), ln=True, align="C")
53
 
54
  pdf.set_font("Arial", "", 16)
55
+ pdf.cell(0, 10, remove_non_latin(f"has completed the training in {topic.upper()} under"), ln=True, align="C")
56
+ pdf.cell(0, 10, remove_non_latin("AI For Everyone - Digital Literacy Hub"), ln=True, align="C")
57
 
58
  pdf.set_font("Arial", "I", 12)
59
+ pdf.cell(0, 10, remove_non_latin("Batch-01 | Jul 2025 - Sep 2025"), ln=True, align="C")
60
 
61
  pdf.set_font("Arial", "", 14)
62
  pdf.ln(4)
63
+ pdf.cell(0, 10, remove_non_latin(f"Score Achieved: {score}/5"), ln=True, align="C")
64
 
65
  # Footer
66
  pdf.set_y(-35)
67
  pdf.set_font("Arial", "I", 11)
68
  pdf.cell(0, 10, f"Issue Date: {datetime.today().strftime('%d/%m/%Y')}", ln=True, align="C")
69
+ pdf.cell(0, 10, remove_non_latin("Issued by Future Tech Leaders"), ln=True, align="C")
70
  cert_id = f"FTL-{datetime.now().strftime('%y%m%d%H%M%S')}"
71
  pdf.cell(0, 10, f"Certificate ID: {cert_id}", ln=True, align="C")
72
 
 
85
  return filename
86
 
87
  # -------------------------------
88
+ # Topic Modules (Paste Full Here)
 
 
89
  # -------------------------------
90
  modules = {
91
  "What is AI?": {
92
  "intro": [
93
+ "Artificial Intelligence (AI) is the simulation of human intelligence by machines.",
94
+ "It includes reasoning, learning, problem-solving, perception, and language understanding.",
95
+ "AI is used in voice assistants, self-driving cars, and recommendation systems.",
96
+ "There are three types of AI: Narrow AI, General AI, and Super AI.",
97
+ "Narrow AI is task-specific (like Siri), General AI is human-like (still theoretical), and Super AI would outperform humans.",
98
+ "AI works by training models on large datasets using algorithms.",
99
+ "Understanding AI helps us build a smarter and fairer digital future.",
100
+ "You donโ€™t need to be a programmer to understand the basics of AI.",
101
+ "AI is changing industries like health, finance, education, and agriculture.",
102
+ "Letโ€™s explore how it works and what it can do.",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  ],
104
  "quiz": [
105
+ {"q": "What does AI stand for?", "O": ["Automatic Internet", "Artificial Intelligence", "Advanced Input", "Auto Integration"], "A": "Artificial Intelligence"},
106
+ {"q": "Which is an example of AI?", "O": ["Fan", "Google Assistant", "Light Bulb", "Calculator"], "A": "Google Assistant"},
107
+ {"q": "Which AI exists today?", "O": ["Super AI", "General AI", "Narrow AI", "Meta AI"], "A": "Narrow AI"},
108
+ {"q": "AI works by learning from?", "O": ["Sunlight", "Data", "Magic", "Dreams"], "A": "Data"},
109
+ {"q": "Which of these is NOT AI?", "O": ["Face Unlock", "Spam Filter", "Alarm Clock", "Netflix Suggestions"], "A": "Alarm Clock"},
110
  ]
111
  },
112
+ # Paste 9 more modules here with "intro" and "quiz"...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
 
115
+ # Initialize analytics & leaderboard
116
  for topic in modules:
117
  st.session_state.analytics.setdefault(topic, 0)
118
  st.session_state.leaderboard.setdefault(topic, [])
119
 
120
  # -------------------------------
121
+ # Module Display
122
  # -------------------------------
123
  def show_module(topic):
124
  explanation = "\n\n".join(modules[topic]["intro"])
 
153
  cert = create_certificate(name, topic, score)
154
  st.download_button("๐Ÿ“„ Download Certificate", data=open(cert, "rb"), file_name=cert, mime="application/pdf")
155
 
156
+ share_text = f"I scored {score}/5 on '{topic}'! #AIForEveryone"
157
+ st.markdown(f"[๐Ÿ”— WhatsApp](https://wa.me/?text={share_text}) | [๐Ÿฆ Twitter](https://twitter.com/intent/tweet?text={share_text})")
 
158
 
159
  st.subheader("โœ… Answer Key:")
160
  for i, qd in enumerate(modules[topic]["quiz"]):
 
165
  # -------------------------------
166
  if not st.session_state.started:
167
  st.title("๐Ÿค– AI For Everyone โ€“ Future Tech Leaders")
168
+ st.markdown("### Learn AI, earn certificates, and grow your future with the power of digital literacy.")
169
  if st.button("๐Ÿš€ Get Started Now"):
170
  st.session_state.started = True
171
  st.stop()
172
 
173
  # -------------------------------
174
+ # Sidebar
175
  # -------------------------------
176
  st.sidebar.title("๐Ÿ“˜ Topics")
177
  topic = st.selectbox("Choose your module:", list(modules.keys()))
178
 
179
+ st.sidebar.subheader("๐Ÿ“Š Completions")
180
+ for t, c in st.session_state.analytics.items():
181
+ st.sidebar.write(f"{t}: {c} completed")
182
 
183
+ st.sidebar.subheader("๐Ÿ† Leaderboard")
184
+ for t, scores in st.session_state.leaderboard.items():
185
+ if scores:
186
+ st.sidebar.write(f"**{t}**")
187
+ for entry in scores:
188
  st.sidebar.write(f"{entry['name']}: {entry['score']}/5")
189
 
190
  # -------------------------------