Spaces:
Sleeping
Sleeping
| from .base_agent import BaseAgent | |
| from .teacher import NoviceTeacherAgent, IntermediateTeacherAgent, AdvancedTeacherAgent | |
| from .bloom_assess import BloomsAssessmentAgent | |
| from curriculum import Chapter, Module | |
| class CoordinatorAgent(BaseAgent): | |
| def __init__(self, user_level, user_state): | |
| super().__init__("CoordinatorAgent") | |
| if user_level == "novice": | |
| self.teacher = NoviceTeacherAgent() | |
| elif user_level == "intermediate": | |
| self.teacher = IntermediateTeacherAgent() | |
| else: | |
| self.teacher = AdvancedTeacherAgent() | |
| self.bloom_assessor = BloomsAssessmentAgent() | |
| self.user_state = user_state | |
| def teach_curriculum(self, curriculum): | |
| print("\n[System] Starting the teaching session!") | |
| print(self.user_state.get_progress_summary(curriculum)) | |
| for chapter_idx, chapter in enumerate(curriculum.chapters, 1): | |
| print(f"\n{'='*60}") | |
| print(f"CHAPTER {chapter_idx}: {chapter.name}") | |
| print(f"{'='*60}") | |
| # Teach all modules in the chapter | |
| for module_idx, module in enumerate(chapter.modules, 1): | |
| while True: | |
| print(f"\n--- Module {chapter_idx}.{module_idx}: {module.name} ---") | |
| # Display the teaching content | |
| explanation = self.teacher.teach_module(module) | |
| print(f"\nπ {explanation}") | |
| if self.teacher.check_example(module): | |
| print("[System] Good job! Moving to next module.") | |
| # Update progress | |
| self.user_state.update_module_progress(chapter.name, module.name, "completed") | |
| break | |
| else: | |
| print("[System] Let's review this module again.") | |
| self.user_state.update_module_progress(chapter.name, module.name, "reviewed") | |
| # Chapter completed - run Bloom's assessment | |
| print(f"\n[System] Chapter '{chapter.name}' completed! Time for a comprehensive assessment.") | |
| assessment_results = self.bloom_assessor.process(chapter) | |
| # Check if student should advance or review based on Bloom's assessment | |
| should_advance = assessment_results.get('should_advance', False) | |
| percentage = assessment_results.get('percentage', 0) | |
| if should_advance: | |
| print(f"\nπ Excellent work! You scored {percentage:.1f}% and demonstrated mastery.") | |
| print("β You're ready to advance to the next chapter!") | |
| # Update progress with assessment results | |
| self.user_state.update_bloom_assessment(chapter.name, assessment_results) | |
| self.user_state.update_chapter_progress(chapter.name, "completed") | |
| # Show updated progress | |
| print("\n" + self.user_state.get_progress_summary(curriculum)) | |
| # Ask if user wants to continue | |
| if chapter_idx < len(curriculum.chapters): | |
| continue_choice = input("\nContinue to next chapter? (y/n): ").lower().strip() | |
| if continue_choice != 'y': | |
| print("[System] Progress updated. You can resume later.") | |
| return | |
| else: | |
| print(f"\n{'='*60}") | |
| print("CONGRATULATIONS!") | |
| print(f"{'='*60}") | |
| print("You have completed the entire curriculum!") | |
| print(self.user_state.get_progress_summary(curriculum)) | |
| else: | |
| print(f"\nπ You scored {percentage:.1f}% on the assessment.") | |
| print("π Based on your performance, let's review this chapter to strengthen your understanding.") | |
| # Update progress but mark chapter as needing review | |
| self.user_state.update_bloom_assessment(chapter.name, assessment_results) | |
| self.user_state.update_chapter_progress(chapter.name, "needs_review") | |
| # Ask if user wants to retake the chapter or continue anyway | |
| review_choice = input("\nWould you like to:\n1. Review this chapter again (r)\n2. Continue to next chapter anyway (c)\n3. Save progress and exit (s)\nChoice: ").lower().strip() | |
| if review_choice == 'r': | |
| print(f"\nπ Let's review Chapter {chapter_idx}: {chapter.name}") | |
| # Restart the chapter | |
| chapter_idx -= 1 # Will be incremented at the end of the loop | |
| elif review_choice == 'c': | |
| print("β οΈ Continuing to next chapter. Consider reviewing weak areas later.") | |
| if chapter_idx < len(curriculum.chapters): | |
| continue_choice = input("\nContinue to next chapter? (y/n): ").lower().strip() | |
| if continue_choice != 'y': | |
| print("[System] Progress updated. You can resume later.") | |
| return | |
| else: | |
| print(f"\n{'='*60}") | |
| print("CURRICULUM COMPLETED!") | |
| print(f"{'='*60}") | |
| print("You have completed the entire curriculum!") | |
| print("Note: Some chapters may need review for better mastery.") | |
| print(self.user_state.get_progress_summary(curriculum)) | |
| else: # exit | |
| print("[System] Progress updated. You can resume later.") | |
| return | |