File size: 5,817 Bytes
6bc3db2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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