cryogenic22 commited on
Commit
7a9b771
·
verified ·
1 Parent(s): b65372c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -1
app.py CHANGED
@@ -204,4 +204,70 @@ def main():
204
 
205
  pages[page]()
206
 
207
- def display_current_course():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
  pages[page]()
206
 
207
+ def display_current_course():
208
+ """Display current course content"""
209
+ path = st.session_state.learning_path
210
+ display_progress_bar()
211
+
212
+ col1, col2 = st.columns([7, 3])
213
+
214
+ with col1:
215
+ current_module = path.modules[st.session_state.current_module]
216
+ display_module_content(current_module)
217
+
218
+ with col2:
219
+ st.markdown("### 📌 Navigation")
220
+
221
+ # Previous module button
222
+ if st.session_state.current_module > 0:
223
+ if st.button("⬅️ Previous Module", key="prev_module"):
224
+ st.session_state.current_module -= 1
225
+ st.rerun()
226
+
227
+ # Next module button
228
+ next_idx = st.session_state.current_module + 1
229
+ if next_idx < len(path.modules):
230
+ if path.modules[next_idx].is_complete:
231
+ if st.button("Next Module ➡️", key="next_module"):
232
+ st.session_state.current_module = next_idx
233
+ # Save progress to DB
234
+ cursor.execute('''INSERT OR REPLACE INTO progress (user, topic, current_module, completion_date) VALUES (?, ?, ?, ?)''',
235
+ ('user1', path.topic, st.session_state.current_module, None))
236
+ conn.commit()
237
+ st.rerun()
238
+ else:
239
+ with st.spinner("Generating next module as we speak..."):
240
+ asyncio.run(
241
+ platform.generate_next_module(path, next_idx)
242
+ )
243
+ st.rerun()
244
+ else:
245
+ st.success("🎉 You have completed all modules!")
246
+ if path not in st.session_state.completed_courses:
247
+ path.completion_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
248
+ st.session_state.completed_courses.append(path)
249
+ # Save completion to DB
250
+ cursor.execute('''INSERT OR REPLACE INTO progress (user, topic, current_module, completion_date) VALUES (?, ?, ?, ?)''',
251
+ ('user1', path.topic, len(path.modules), path.completion_date))
252
+ conn.commit()
253
+
254
+
255
+ def display_completed_courses():
256
+ """Display completed courses"""
257
+ st.markdown("### 🏆 Completed Courses")
258
+
259
+ if not st.session_state.completed_courses:
260
+ st.info("Complete your first course to see it here!")
261
+ return
262
+
263
+ for course in st.session_state.completed_courses:
264
+ st.markdown(f"""
265
+ <div class="module-card">
266
+ <h4>{course.topic}</h4>
267
+ <p>{course.description}</p>
268
+ <p><small>Completed on: {course.created_at}</small></p>
269
+ </div>
270
+ """, unsafe_allow_html=True)
271
+
272
+ if __name__ == "__main__":
273
+ main()