Spaces:
Build error
Build error
Update src/components/learning_paths.py
Browse files
src/components/learning_paths.py
CHANGED
|
@@ -175,7 +175,10 @@ class LearningPaths:
|
|
| 175 |
progress = self.get_path_progress(path_id)
|
| 176 |
st.progress(progress, f"Progress: {int(progress * 100)}%")
|
| 177 |
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
| 179 |
with st.expander(f"📚 {module['name']} ({module['difficulty']})"):
|
| 180 |
completed = self.is_module_complete(module['id'])
|
| 181 |
|
|
@@ -184,11 +187,54 @@ class LearningPaths:
|
|
| 184 |
|
| 185 |
if st.button(f"Generate Content for {module['name']}", key=f"generate_{module['id']}"):
|
| 186 |
content = self.generate_module_content_async(module['id'])
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
def load_curriculum(self):
|
| 194 |
"""Load or initialize curriculum structure"""
|
|
|
|
| 175 |
progress = self.get_path_progress(path_id)
|
| 176 |
st.progress(progress, f"Progress: {int(progress * 100)}%")
|
| 177 |
|
| 178 |
+
self.display_modules(path['modules'])
|
| 179 |
+
|
| 180 |
+
def display_modules(self, modules: list):
|
| 181 |
+
for module in modules:
|
| 182 |
with st.expander(f"📚 {module['name']} ({module['difficulty']})"):
|
| 183 |
completed = self.is_module_complete(module['id'])
|
| 184 |
|
|
|
|
| 187 |
|
| 188 |
if st.button(f"Generate Content for {module['name']}", key=f"generate_{module['id']}"):
|
| 189 |
content = self.generate_module_content_async(module['id'])
|
| 190 |
+
self.display_module_content(module, content)
|
| 191 |
+
|
| 192 |
+
def display_module_content(self, module: dict, content: dict):
|
| 193 |
+
"""Display module content"""
|
| 194 |
+
if content:
|
| 195 |
+
st.write(content['introduction'])
|
| 196 |
+
|
| 197 |
+
for section in content['sections']:
|
| 198 |
+
st.markdown(f"### {section['title']}")
|
| 199 |
+
st.write(section['content'])
|
| 200 |
+
if 'examples' in section:
|
| 201 |
+
for example in section['examples']:
|
| 202 |
+
st.code(example)
|
| 203 |
+
|
| 204 |
+
st.markdown("### Practice Exercises")
|
| 205 |
+
for exercise in content['exercises']:
|
| 206 |
+
with st.expander(exercise['title']):
|
| 207 |
+
st.write(exercise['description'])
|
| 208 |
+
if st.button("Show Solution", key=f"sol_{module['id']}_{exercise['title']}"):
|
| 209 |
+
st.code(exercise['solution'])
|
| 210 |
+
|
| 211 |
+
st.markdown("### Quiz")
|
| 212 |
+
self.display_quiz(content['quiz'], module['id'])
|
| 213 |
+
else:
|
| 214 |
+
st.info("Content not generated. Click 'Generate Content' to create learning materials.")
|
| 215 |
+
|
| 216 |
+
def display_quiz(self, quiz: dict, module_id: str):
|
| 217 |
+
"""Display quiz for a module"""
|
| 218 |
+
correct_answers = 0
|
| 219 |
+
total_questions = len(quiz['questions'])
|
| 220 |
+
|
| 221 |
+
for i, q in enumerate(quiz['questions']):
|
| 222 |
+
st.write(f"\n**Question {i+1}:** {q['question']}")
|
| 223 |
+
answer = st.radio(
|
| 224 |
+
"Select your answer:",
|
| 225 |
+
q['options'],
|
| 226 |
+
key=f"quiz_{module_id}_{i}"
|
| 227 |
+
)
|
| 228 |
+
if answer == q['options'][q['correct']]:
|
| 229 |
+
correct_answers += 1
|
| 230 |
+
|
| 231 |
+
if st.button("Submit Quiz", key=f"submit_{module_id}"):
|
| 232 |
+
score = correct_answers / total_questions
|
| 233 |
+
if score >= 0.8:
|
| 234 |
+
st.success(f"🎉 Congratulations! Score: {score*100:.0f}%")
|
| 235 |
+
self.complete_module(module_id, module['path_id'])
|
| 236 |
+
else:
|
| 237 |
+
st.warning(f"Score: {score*100:.0f}%. You need 80% to complete the module.")
|
| 238 |
|
| 239 |
def load_curriculum(self):
|
| 240 |
"""Load or initialize curriculum structure"""
|