Repository navigation
Expand file tree
/
Copy pathLesson4.jsx
More file actions
211 lines (192 loc) · 6.45 KB
/
Copy pathLesson4.jsx
File metadata and controls
211 lines (192 loc) · 6.45 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// Lesson 4: Consumer Equilibrium - Indifference Curve Analysis - Main Page Component
// Based on Grade 11 NCERT Microeconomics syllabus
import { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import {
FaArrowLeft,
FaBookOpen,
FaBezierCurve,
FaListUl,
FaExchangeAlt,
FaChartLine,
FaBalanceScale,
FaClipboardList,
FaChevronRight,
FaChevronLeft
} from 'react-icons/fa';
import {
IntroToIC,
MeaningOfIC,
PropertiesOfIC,
MRSConcept,
BudgetLine,
ConsumerEquilibriumIC,
Quiz
} from './components';
import { lesson4Data } from '../data/lesson4Data';
import { logLessonProgress } from '../../../services/firebase';
import { useAuth } from '../../../context/AuthContext';
import MicroTopicsMenu from '../components/MicroTopicsMenu';
import '../css/lessons.css'; // Shared lesson styles
/**
* Lesson 4: Consumer Equilibrium - Indifference Curve Analysis
*
* 6 Topics:
* 1. Intro to IC - Ordinal Approach meaning and advantages
* 2. Meaning of IC - Definition, Schedule and Map
* 3. Properties of IC - Downward sloping, convex, etc.
* 4. MRS - Meaning and Diminishing nature
* 5. Budget Line - Equation, Slope and Shifts
* 6. Consumer Equilibrium - MRSxy = Px/Py and budget constraint
*/
const sections = [
{ id: 'intro-ic', name: 'Introduction', icon: FaBookOpen },
{ id: 'meaning-ic', name: 'Meaning of IC', icon: FaBezierCurve },
{ id: 'properties-ic', name: 'Properties of IC', icon: FaListUl },
{ id: 'mrs-concept', name: 'MRS Concept', icon: FaExchangeAlt },
{ id: 'budget-line', name: 'Budget Line', icon: FaChartLine },
{ id: 'equilibrium-ic', name: 'Equilibrium', icon: FaBalanceScale },
{ id: 'quiz', name: 'Quiz', icon: FaClipboardList }
];
function Lesson4() {
// Load active section from localStorage, default to 'intro-ic'
const [activeSection, setActiveSection] = useState(() => {
const saved = localStorage.getItem('lesson4-activeSection');
return saved || 'intro-ic';
});
const [startTime] = useState(() => Date.now());
const lessonId = 'micro11-4';
const { logActivity } = useAuth();
useEffect(() => {
if (logActivity) {
logActivity('lesson_visit', { lessonId, lessonName: 'Demand', chapter: 'Chapter 4' });
}
}, [logActivity, lessonId]);
// Save active section to localStorage whenever it changes
useEffect(() => {
localStorage.setItem('lesson4-activeSection', activeSection);
}, [activeSection]);
// Track time spent on unmount only
useEffect(() => {
return () => {
const timeSpent = Math.round((Date.now() - startTime) / 1000 / 60);
if (timeSpent > 0) {
logLessonProgress(lessonId, timeSpent);
}
};
}, [startTime, lessonId]);
const currentIndex = sections.findIndex(s => s.id === activeSection);
const goToPrevious = () => {
if (currentIndex > 0) {
setActiveSection(sections[currentIndex - 1].id);
}
};
const goToNext = () => {
if (currentIndex < sections.length - 1) {
setActiveSection(sections[currentIndex + 1].id);
}
};
const handleSectionChange = (sectionId) => {
setActiveSection(sectionId);
};
const renderActiveSection = () => {
switch (activeSection) {
case 'intro-ic':
return <IntroToIC />;
case 'meaning-ic':
return <MeaningOfIC />;
case 'properties-ic':
return <PropertiesOfIC />;
case 'mrs-concept':
return <MRSConcept />;
case 'budget-line':
return <BudgetLine />;
case 'equilibrium-ic':
return <ConsumerEquilibriumIC />;
case 'quiz':
return <Quiz
mcqQuestions={lesson4Data.mcqQuestions}
tfQuestions={lesson4Data.tfQuestions}
quizId="lesson4"
/>;
default:
return <IntroToIC />;
}
};
return (
<div className="lesson-page">
{/* Floating Background Elements */}
<div className="floating-elements">
<div className="float-circle circle-1"></div>
<div className="float-circle circle-2"></div>
<div className="float-circle circle-3"></div>
<div className="grid-pattern"></div>
</div>
{/* Header */}
<header className="lesson-header">
<div className="header-container">
<Link to="/lessons" className="back-link">
<FaArrowLeft />
<span>Back to Lessons</span>
</Link>
<div className="lesson-info">
<div className="lesson-badge">
<span className="badge-icon">📉</span>
<span className="badge-tag">Microeconomics</span>
</div>
<h1 className="lesson-title">
<span className="title-line">Consumer Equilibrium:</span>
<span className="title-gradient">Indifference Curve Analysis</span>
</h1>
<p className="lesson-meta">
Based on NCERT Grade 11 Microeconomics • {lesson4Data.mcqQuestions.length + lesson4Data.tfQuestions.length} Quiz Questions
</p>
</div>
</div>
</header>
{/* Navigation - Responsive Hybrid */}
<MicroTopicsMenu
sections={sections}
activeSection={activeSection}
onSectionChange={handleSectionChange}
/>
{/* Main Content */}
<main className="lesson-content">
<div className="content-container">
{renderActiveSection()}
</div>
</main>
{/* Footer Navigation */}
<footer className="lesson-footer">
<div className="footer-container">
<button
className={`footer-btn prev ${currentIndex === 0 ? 'disabled' : ''}`}
onClick={goToPrevious}
disabled={currentIndex === 0}
>
<FaChevronLeft />
<span>Previous</span>
</button>
<div className="progress-indicator">
{sections.map((section, index) => (
<span
key={section.id}
className={`progress-dot ${index === currentIndex ? 'active' : ''} ${index < currentIndex ? 'completed' : ''}`}
onClick={() => handleSectionChange(section.id)}
></span>
))}
</div>
<button
className={`footer-btn next ${currentIndex === sections.length - 1 ? 'disabled' : ''}`}
onClick={goToNext}
disabled={currentIndex === sections.length - 1}
>
<span>Next</span>
<FaChevronRight />
</button>
</div>
</footer>
</div>
);
}
export default Lesson4;