Repository navigation
Expand file tree
/
Copy pathexcel_101.html
More file actions
467 lines (433 loc) · 28.6 KB
/
Copy pathexcel_101.html
File metadata and controls
467 lines (433 loc) · 28.6 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Excel 101 — Fundamentals for Analysts</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #0f1a12;
--card: #16261c;
--surface: #122016;
--border: #1f3326;
--accent: #4ade80;
--accent-dark: #16a34a;
--accent-light: #142a1a;
--amber: #fbbf24;
--amber-light: #2e2410;
--green: #34d399;
--green-light: #0a2a1f;
--red: #f87171;
--red-light: #2a0f0f;
--cyan: #22d3ee;
--cyan-light: #0a2530;
--text: #ecf5ee;
--muted: #85a68e;
}
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
header { background: #0a120c; border-bottom: 1px solid var(--border); color: white; padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between; }
header h1 { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; color: var(--accent); }
.header-hub-link { font-size: 0.78rem; font-weight: 500; color: var(--muted); text-decoration: none; white-space: nowrap; transition: color 0.15s; }
.header-hub-link:hover { color: var(--text); }
.header-left { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.progress-wrap { display: flex; align-items: center; gap: 0.75rem; }
.progress-track { width: 140px; height: 8px; background: var(--border); border-radius: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 8px; transition: width 0.4s; }
.progress-label { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.main { max-width: 680px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.lesson-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 2rem; margin-bottom: 1rem; display: none; animation: slideIn 0.3s ease; }
.lesson-card.active { display: block; }
@keyframes slideIn { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: translateY(0); } }
.lesson-tag { display: inline-block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; background: var(--accent-light); color: var(--accent); padding: 0.25rem 0.65rem; border-radius: 20px; margin-bottom: 0.875rem; }
.lesson-tag.quiz-tag { background: var(--amber-light); color: var(--amber); }
.lesson-tag.tip-tag { background: var(--cyan-light); color: var(--cyan); }
.lesson-tag.level-tag { background: var(--green-light); color: var(--green); }
.lesson-emoji { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; }
.lesson-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.75rem; line-height: 1.25; color: var(--text); }
.lesson-body { font-size: 0.9rem; color: var(--muted); line-height: 1.75; }
.lesson-body p { margin-bottom: 0.75rem; }
.lesson-body p:last-child { margin-bottom: 0; }
.lesson-body strong { color: var(--text); }
.lesson-body table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.82rem; }
.lesson-body th, .lesson-body td { text-align: left; padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--border); }
.lesson-body th { color: var(--text); font-weight: 700; }
.lesson-body code { background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 0.1rem 0.4rem; font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.85em; color: var(--accent); }
.callout { border-radius: 12px; padding: 0.875rem 1rem; margin: 1rem 0; font-size: 0.875rem; line-height: 1.6; }
.callout.accent { background: var(--accent-light); border-left: 4px solid var(--accent); color: var(--accent); }
.callout.cyan { background: var(--cyan-light); border-left: 4px solid var(--cyan); color: var(--cyan); }
.callout.amber { background: var(--amber-light); border-left: 4px solid var(--amber); color: var(--amber); }
.callout.green { background: var(--green-light); border-left: 4px solid var(--green); color: var(--green); }
.callout.red { background: var(--red-light); border-left: 4px solid var(--red); color: var(--red); }
.analogy-block { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem; margin: 1rem 0; }
.analogy-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 0.5rem; }
.analogy-title { font-size: 0.95rem; font-weight: 700; color: var(--text); margin-bottom: 0.4rem; }
.analogy-body { font-size: 0.83rem; color: var(--muted); line-height: 1.6; }
.usecase-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; margin: 0.6rem 0; display: flex; gap: 0.75rem; align-items: flex-start; }
.usecase-icon { font-size: 1.3rem; flex-shrink: 0; }
.usecase-title { font-size: 0.85rem; font-weight: 700; color: var(--text); margin-bottom: 0.2rem; }
.usecase-desc { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
.step-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem; margin: 1rem 0; }
.step-item { display: flex; gap: 0.875rem; align-items: flex-start; padding-bottom: 0.875rem; }
.step-item:last-child { padding-bottom: 0; }
.step-num { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-light); font-weight: 800; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-title { font-size: 0.85rem; font-weight: 700; color: var(--text); margin-bottom: 0.15rem; }
.step-desc { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
.risk-card { border-radius: 12px; padding: 1rem; margin: 0.6rem 0; border: 1px solid var(--border); background: var(--surface); }
.risk-level { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.4rem; }
.risk-title { font-size: 0.875rem; font-weight: 700; color: var(--text); margin-bottom: 0.4rem; }
.risk-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
.risk-green .risk-level { color: var(--green); }
.risk-amber .risk-level { color: var(--amber); }
.risk-red .risk-level { color: var(--red); }
.quiz-options { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1.25rem; }
.quiz-option { background: var(--surface); border: 2px solid var(--border); border-radius: 12px; padding: 0.875rem 1rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; text-align: left; transition: all 0.15s; display: flex; align-items: center; gap: 0.75rem; color: var(--text); }
.quiz-option:hover { border-color: var(--accent); background: var(--accent-light); }
.quiz-option.correct { border-color: var(--green); background: var(--green-light); color: var(--green); pointer-events: none; }
.quiz-option.wrong { border-color: var(--red); background: var(--red-light); color: var(--red); pointer-events: none; }
.quiz-option.disabled { pointer-events: none; opacity: 0.4; }
.option-letter { width: 26px; height: 26px; border-radius: 50%; background: var(--border); color: var(--muted); font-size: 0.75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.quiz-option.correct .option-letter { background: var(--green); color: #0a2a1f; }
.quiz-option.wrong .option-letter { background: var(--red); color: #2a0f0f; }
.quiz-feedback { margin-top: 1rem; padding: 0.875rem 1rem; border-radius: 12px; font-size: 0.875rem; line-height: 1.6; display: none; }
.quiz-feedback.show { display: block; }
.quiz-feedback.correct { background: var(--green-light); color: var(--green); }
.quiz-feedback.wrong { background: var(--red-light); color: var(--red); }
.try-it { margin-top: 1.25rem; }
.try-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 0.5rem; }
.try-input { width: 100%; border: 2px solid var(--border); border-radius: 12px; padding: 0.75rem 1rem; font-size: 0.875rem; font-family: inherit; resize: none; outline: none; background: var(--surface); color: var(--text); transition: border-color 0.15s; }
.try-input:focus { border-color: var(--accent); }
.try-submit { margin-top: 0.5rem; background: var(--accent-dark); color: white; border: none; border-radius: 10px; padding: 0.6rem 1.25rem; font-size: 0.875rem; font-weight: 700; cursor: pointer; }
.try-submit:hover { background: var(--accent); }
.try-response { display: none; margin-top: 0.75rem; background: var(--accent-light); border-radius: 12px; padding: 0.875rem 1rem; font-size: 0.875rem; line-height: 1.6; color: var(--accent); }
.try-response.show { display: block; }
.nav-row { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.btn-next { background: var(--accent-dark); color: white; border: none; border-radius: 12px; padding: 0.75rem 1.75rem; font-size: 0.9rem; font-weight: 700; cursor: pointer; transition: background 0.15s; }
.btn-next:hover { background: var(--accent); }
.btn-back { background: none; color: var(--muted); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 1.25rem; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.btn-back:hover { color: var(--text); border-color: var(--muted); }
.score-card { text-align: center; padding: 1rem 0; }
.score-emoji { font-size: 4rem; margin-bottom: 0.75rem; }
.score-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.5rem; }
.score-sub { font-size: 0.9rem; color: var(--muted); margin-bottom: 1.5rem; }
.score-badge { display: inline-block; background: var(--accent-light); color: var(--accent); border-radius: 20px; padding: 0.5rem 1.5rem; font-size: 1.1rem; font-weight: 700; margin-bottom: 1.5rem; }
.restart-btn { background: var(--accent-dark); color: white; border: none; border-radius: 12px; padding: 0.75rem 2rem; font-size: 0.9rem; font-weight: 700; cursor: pointer; }
.back-to-hub-btn { display: inline-block; margin-left: 0.75rem; background: none; color: var(--muted); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 1.5rem; font-size: 0.9rem; font-weight: 600; cursor: pointer; text-decoration: none; }
.back-to-hub-btn:hover { color: var(--text); }
@media (max-width: 480px) {
.lesson-card { padding: 1.25rem; }
header { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
}
</style>
</head>
<body>
<header>
<div class="header-left">
<a class="header-hub-link" href="excel_learn.html">← Hub</a>
<h1>📊 Excel 101 — Fundamentals for Analysts</h1>
</div>
<div class="progress-wrap">
<div class="progress-track"><div class="progress-fill" id="progress-fill" style="width:0%"></div></div>
<div class="progress-label" id="progress-label">Lesson 1 of 9</div>
</div>
</header>
<div class="main" id="main"></div>
<script>
let currentLesson = 0;
let quizScore = 0;
let quizAnswered = {};
const lessons =
[
{
type: 'lesson',
tag: 'Beginner',
emoji: '📊',
title: "Excel Fundamentals: building the foundation analysts actually use",
body: `
<p>Every data analyst job posting lists "Excel" as a requirement, but what interviewers actually mean is: can you navigate a workbook fast, write a correct formula without thinking twice, and format a sheet so someone else can read it?</p>
<p>This module covers:</p>
<div class="callout accent">
🧭 <strong>Navigation & references</strong> — cells, ranges, and the $ symbol that trips up beginners<br><br>
🧮 <strong>Basic formulas</strong> — order of operations and the mistakes that cause #REF! and #VALUE! errors<br><br>
🎨 <strong>Formatting for readability</strong> — because a correct answer nobody can read isn't useful<br><br>
⌨️ <strong>Analyst habits</strong> — the keyboard shortcuts that separate "knows Excel" from "uses Excel daily"
</div>
<p>No prior spreadsheet experience assumed. If you've used Excel casually, feel free to skim the first two lessons.</p>
`
},
{
type: 'lesson',
tag: 'Cell references',
emoji: '🧭',
title: "Relative vs. absolute references — the $ that changes everything",
body: `
<p>Every cell has an address like <code>B4</code> — column B, row 4. When you write a formula and copy it to other cells, Excel adjusts those addresses automatically. That's a <strong>relative reference</strong>, and it's usually exactly what you want.</p>
<p>But sometimes you need one part of a formula to stay locked in place no matter where you copy it — say, a tax rate sitting in a single cell that every row's formula should reference. That's where <code>$</code> comes in:</p>
<table>
<tr><th>Reference</th><th>Behavior when copied</th></tr>
<tr><td><code>B4</code></td><td>Both row and column shift (relative)</td></tr>
<tr><td><code>$B4</code></td><td>Column locked, row shifts</td></tr>
<tr><td><code>B$4</code></td><td>Row locked, column shifts</td></tr>
<tr><td><code>$B$4</code></td><td>Both locked (absolute)</td></tr>
</table>
<div class="analogy-block">
<div class="analogy-label">Analogy</div>
<div class="analogy-title">Relative references are directions from where you're standing. Absolute is a street address.</div>
<div class="analogy-body">"Two blocks north" means something different depending on where you start — that's relative. "123 Main St" points to the same place no matter who's asking — that's absolute, marked with $.</div>
</div>
<div class="callout amber">💡 <strong>Shortcut:</strong> Press <code>F4</code> right after typing a cell reference to cycle through the four locking states instead of typing $ manually.</div>
`
},
{
type: 'quiz',
tag: 'Quick check ✏️',
emoji: '🤔',
title: "References check",
question: "You have a commission rate in cell B1 that every row's formula needs to reference. You write a formula in C2 and want to copy it down to C3, C4, etc. — B1 should never shift. How should you reference it?",
options: [
"B1 — plain reference is fine",
"$B$1 — locking both row and column",
"B$1 — locking only the row",
"It doesn't matter, Excel figures it out automatically"
],
correct: 1,
feedback: {
correct: "Exactly. 🎯 Since B1 is a single fixed cell you're referencing from many different rows, locking both the column and row with $B$1 ensures it never shifts no matter where the formula is copied.",
wrong: "The answer is B, $B$1. Because B1 is a single source cell referenced from multiple rows below it, both the column and row need to stay locked — otherwise copying the formula down would shift the reference to B2, B3, and so on, which isn't what you want."
}
},
{
type: 'lesson',
tag: 'Formulas',
emoji: '🧮',
title: "Writing formulas without the common beginner mistakes",
body: `
<p>Every formula starts with <code>=</code>. Excel follows standard order of operations — parentheses, then exponents, then multiplication/division, then addition/subtraction (PEMDAS) — just like the math you already know.</p>
<div class="usecase-card">
<div class="usecase-icon">⚠️</div>
<div><div class="usecase-title">#REF! error</div><div class="usecase-desc">A formula points to a cell that got deleted. Common after deleting a row or column that other formulas depended on.</div></div>
</div>
<div class="usecase-card">
<div class="usecase-icon">⚠️</div>
<div><div class="usecase-title">#VALUE! error</div><div class="usecase-desc">A formula is trying to do math on text — like adding a number to a cell that contains "N/A" or has a stray space.</div></div>
</div>
<div class="usecase-card">
<div class="usecase-icon">⚠️</div>
<div><div class="usecase-title">A number stored as text</div><div class="usecase-desc">Shows up left-aligned instead of right-aligned, and SUM silently ignores it. Usually caused by data pasted from a system export.</div></div>
</div>
<div class="callout cyan">💡 <strong>Habit:</strong> When a total looks wrong, check alignment first. Numbers align right by default; text aligns left. A left-aligned "number" is your first clue something's being read as text.</div>
`
},
{
type: 'quiz',
tag: 'Quick check ✏️',
emoji: '🤔',
title: "Formula errors check",
question: "You SUM a column of what look like numbers and the total is lower than expected — some values seem to be getting skipped. What's the most likely cause?",
options: [
"Excel has a bug and needs to be restarted",
"Some of those 'numbers' are actually stored as text, so SUM ignores them",
"You need to add more decimal places to the formula",
"The column is too long for SUM to handle"
],
correct: 1,
feedback: {
correct: "Exactly. 🎯 Numbers stored as text are the single most common cause of a SUM that comes up short. They display like numbers but SUM, AVERAGE, and similar functions treat them as non-numeric and skip them.",
wrong: "The answer is B. When a total is unexpectedly low, the first thing to check is whether some cells contain numbers stored as text — often from a data export — since SUM silently skips over them without any error message."
}
},
{
type: 'lesson',
tag: 'Formatting',
emoji: '🎨',
title: "Formatting for the reader, not just yourself",
body: `
<p>A technically correct spreadsheet that nobody else can parse in ten seconds isn't doing its job. Analysts format for the person who'll open the file after them — often a manager skimming on their phone between meetings.</p>
<div class="step-wrap">
<div class="step-item">
<div class="step-num">1</div>
<div><div class="step-title">Number formats match meaning</div><div class="step-desc">Currency shows as $1,250.00, percentages show as 12%, not 0.12 — formatting a cell doesn't change its underlying value, only how it displays.</div></div>
</div>
<div class="step-item">
<div class="step-num">2</div>
<div><div class="step-title">Freeze panes for long sheets</div><div class="step-desc"><strong>View → Freeze Panes</strong> keeps header rows visible while scrolling through thousands of rows of data.</div></div>
</div>
<div class="step-item">
<div class="step-num">3</div>
<div><div class="step-title">Conditional formatting flags outliers</div><div class="step-desc">Color scales or icon sets let a reader spot the highest/lowest values at a glance, without reading every cell.</div></div>
</div>
</div>
<div class="callout green">✅ <strong>Interview tell:</strong> Candidates who mention formatting for readability — not just getting the right number — read as more experienced, because it shows they've actually handed work to someone else before.</div>
`
},
{
type: 'tryit',
tag: 'Try it 💪',
emoji: '✍️',
title: "Write the formula",
instruction: "You have Revenue in column B and Cost in column C, starting at row 2. You want a Profit Margin column in D that calculates (Revenue - Cost) / Revenue, formatted as a percentage, for row 2. What formula would you type in D2? Write it out.",
placeholder: "Type the formula you'd enter in D2...",
response: "A solid answer: =(B2-C2)/B2, then format the cell as a percentage. The parentheses matter — without them, order of operations would divide C2 by B2 before subtracting, which isn't what you want. Once it's correct in D2, you'd copy it down the column and each row's B and C references shift automatically since they're relative references, not absolute."
},
{
type: 'lesson',
tag: 'Efficiency',
emoji: '⌨️',
title: "Habits that separate casual users from daily analysts",
body: `
<p>Speed matters more than people expect in interviews and on the job — being able to navigate a 50,000-row sheet without touching the mouse signals real, regular use.</p>
<table>
<tr><th>Shortcut</th><th>What it does</th></tr>
<tr><td><code>Ctrl + Arrow key</code></td><td>Jump to the edge of a data block instantly</td></tr>
<tr><td><code>Ctrl + Shift + L</code></td><td>Toggle filter dropdowns on the header row</td></tr>
<tr><td><code>Ctrl + T</code></td><td>Convert a range into a proper Excel Table (auto-expanding formulas)</td></tr>
<tr><td><code>Alt + =</code></td><td>AutoSum the column above the active cell</td></tr>
<tr><td><code>F4</code></td><td>Repeat your last action, or cycle $ locking in a formula</td></tr>
</table>
<div class="callout accent">💡 <strong>Named ranges:</strong> Instead of referencing $B$1 for a tax rate, you can name that cell "TaxRate" (Formulas → Define Name) and write =Revenue*TaxRate. It reads like plain English and never breaks if rows get inserted above it.</div>
`
},
{
type: 'quiz',
tag: 'Final check ✏️',
emoji: '🎯',
title: "Fundamentals wrap-up",
question: "You're about to copy a formula down 200 rows, and one part of it must always point to a single 'exchange rate' cell at the top of the sheet. What's the risk of leaving that reference as a plain relative reference (no $)?",
options: [
"No risk — Excel will keep it locked automatically since it's near the top",
"As the formula copies down, the reference will shift row by row and eventually point to blank or wrong cells",
"The formula simply won't work at all and will show an error immediately",
"It only matters if the file is shared with someone else"
],
correct: 1,
feedback: {
correct: "Exactly right. 🎯 A relative reference shifts with every row it's copied to. By row 200, it would be pointing 199 rows below the original exchange rate cell — almost certainly blank or wrong. Locking it with $ (making it $B$1, for example) is what prevents this.",
wrong: "The answer is B. Without $ locking, a reference shifts by one row for every row the formula is copied to — so by the time you're 200 rows down, it's no longer pointing at the exchange rate cell at all. This is one of the most common real-world spreadsheet bugs."
}
}
]
;
function renderProgress() {
const pct = (currentLesson / (lessons.length - 1)) * 100;
document.getElementById('progress-fill').style.width = pct + '%';
document.getElementById('progress-label').textContent = `Lesson ${currentLesson + 1} of ${lessons.length}`;
}
function renderLesson() {
const main = document.getElementById('main');
main.innerHTML = '';
renderProgress();
if(currentLesson >= lessons.length) { renderScore(); return; }
const l = lessons[currentLesson];
const card = document.createElement('div');
card.className = 'lesson-card active';
const backBtn = currentLesson > 0 ? '<button class="btn-back" onclick="goBack()">← Back</button>' : '';
if(l.type === 'lesson') {
card.innerHTML = `
<div class="lesson-tag level-tag">${l.tag}</div>
<span class="lesson-emoji">${l.emoji}</span>
<div class="lesson-title">${l.title}</div>
<div class="lesson-body">${l.body}</div>
<div class="nav-row">${backBtn}<button class="btn-next" onclick="nextLesson()">Next →</button></div>
`;
} else if(l.type === 'quiz') {
const answered = quizAnswered[currentLesson];
const letters = ['A','B','C','D'];
const optionsHTML = l.options.map((o, i) => {
let cls = '';
if(answered !== undefined) { if(i === l.correct) cls = 'correct'; else if(i === answered) cls = 'wrong'; else cls = 'disabled'; }
return `<button class="quiz-option ${cls}" onclick="answerQuiz(${i})"><div class="option-letter">${letters[i]}</div>${o}</button>`;
}).join('');
const feedbackCls = answered !== undefined ? (answered === l.correct ? 'correct' : 'wrong') : '';
const feedbackText = answered !== undefined ? (answered === l.correct ? l.feedback.correct : l.feedback.wrong) : '';
card.innerHTML = `
<div class="lesson-tag quiz-tag">${l.tag}</div>
<span class="lesson-emoji">${l.emoji}</span>
<div class="lesson-title">${l.title}</div>
<div class="lesson-body"><p>${l.question}</p></div>
<div class="quiz-options">${optionsHTML}</div>
<div class="quiz-feedback ${answered!==undefined?'show':''} ${feedbackCls}">${feedbackText}</div>
<div class="nav-row" id="quiz-nav" style="${answered===undefined?'display:none':''}">${backBtn}<button class="btn-next" onclick="nextLesson()">Next →</button></div>
`;
} else if(l.type === 'tryit') {
card.innerHTML = `
<div class="lesson-tag tip-tag">${l.tag}</div>
<span class="lesson-emoji">${l.emoji}</span>
<div class="lesson-title">${l.title}</div>
<div class="lesson-body"><p>${l.instruction}</p></div>
<div class="try-it">
<div class="try-label">Your answer</div>
<textarea class="try-input" id="try-input" rows="5" placeholder="${l.placeholder}"></textarea>
<button class="try-submit" onclick="submitTryIt()">Submit →</button>
<div class="try-response" id="try-response"></div>
</div>
<div class="nav-row" id="tryit-nav" style="display:none">${backBtn}<button class="btn-next" onclick="nextLesson()">Next →</button></div>
`;
}
main.appendChild(card);
window.scrollTo(0, 0);
}
function answerQuiz(selected) {
const l = lessons[currentLesson];
if(quizAnswered[currentLesson] !== undefined) return;
quizAnswered[currentLesson] = selected;
if(selected === l.correct) quizScore++;
renderLesson();
}
function submitTryIt() {
const input = document.getElementById('try-input').value.trim();
if(!input) return;
const el = document.getElementById('try-response');
el.textContent = lessons[currentLesson].response;
el.classList.add('show');
document.getElementById('tryit-nav').style.display = 'flex';
document.querySelector('.try-submit').disabled = true;
}
function nextLesson() { currentLesson++; renderLesson(); }
function goBack() { if(currentLesson > 0) { currentLesson--; renderLesson(); } }
function renderScore() {
const main = document.getElementById('main');
const quizCount = Object.keys(quizAnswered).length;
const pct = quizCount > 0 ? Math.round((quizScore / quizCount) * 100) : 0;
let emoji, title, sub;
if(pct === 100) { emoji = '📊'; title = "You've got the fundamentals locked in."; sub = "References, formulas, formatting, and the shortcuts that separate casual use from daily analyst work — you're ready for functions and logic next."; }
else if(pct >= 66) { emoji = '🎉'; title = "Solid grasp!"; sub = "You've got the core ideas of references and formula structure down. A second pass on the $ locking rules will lock in anything that didn't fully click."; }
else { emoji = '💪'; title = "Keep digging!"; sub = "References and formula mechanics take repetition to stick. Revisiting Lessons 2 and 3 before moving on will pay off in every module after this one."; }
const card = document.createElement('div');
card.className = 'lesson-card active';
card.innerHTML = `
<div class="score-card">
<div class="score-emoji">${emoji}</div>
<div class="score-title">${title}</div>
<div class="score-sub">${sub}</div>
<div class="score-badge">Quiz score: ${quizScore} / ${quizCount} correct</div>
<br>
<div class="lesson-body" style="text-align:left;margin-bottom:1.5rem">
<div class="callout accent">
<strong>What you now know:</strong><br><br>
🧭 <strong>References</strong> — relative shifts, absolute ($) stays locked<br>
🧮 <strong>Formula mechanics</strong> — order of operations, and why #REF!/#VALUE! happen<br>
🎨 <strong>Formatting for readers</strong> — number formats, freeze panes, conditional formatting<br>
⌨️ <strong>Analyst shortcuts</strong> — Ctrl+Arrow, Ctrl+T, named ranges
</div>
<div class="callout cyan">
<strong>The one rule that ties it all together:</strong><br>
Every formula you write will eventually get copied somewhere else — across a row, down a column, into next month's version of the same sheet. Think about where it needs to travel before you write it, not after it breaks.
</div>
</div>
<button class="restart-btn" onclick="restartModule()">Start over 🔄</button> <a class="back-to-hub-btn" href="excel_learn.html">← Back to Learn Excel</a>
</div>
`;
main.appendChild(card);
document.getElementById('progress-fill').style.width = '100%';
document.getElementById('progress-label').textContent = 'Complete! 🎉';
window.scrollTo(0, 0);
}
function restartModule() {
currentLesson = 0; quizScore = 0; quizAnswered = {};
renderLesson();
}
renderLesson();
</script>
</body>
</html>