bChaukar commited on
Commit
4cdd9ce
·
verified ·
1 Parent(s): 0753d6d

Update dashboard.html

Browse files
Files changed (1) hide show
  1. dashboard.html +658 -59
dashboard.html CHANGED
@@ -1,3 +1,4 @@
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
@@ -5,7 +6,211 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Dashboard - RISE</title>
7
  <link rel="stylesheet" href="style.css">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  </head>
 
9
  <body>
10
  <nav class="navbar">
11
  <div class="logo">RISE</div>
@@ -17,71 +222,465 @@
17
  <a href="index.html" class="signin-btn">Log Out</a>
18
  </nav>
19
 
20
- <section class="dashboard-welcome">
21
- <div>
22
- <p class="small-title">WELCOME TO RISE</p>
23
- <h1>Hello! 👋<br><span>Ready to grow your reading skills?</span></h1>
24
- <p>Your personalized reading journey starts here. Choose a level and improve step by step.</p>
25
- <p id="level-message"></p>
26
- </div>
27
- </section>
28
 
29
- <section class="dashboard-section" id="practice">
30
- <div class="section-heading">
31
- <p>YOUR PRACTICE</p>
32
- <h2>Ready to practise?</h2>
33
- <p>Choose your level, read aloud, and build your fluency one step at a time.</p>
34
- </div>
35
- <div class="dashboard-cards" style="grid-template-columns:minmax(260px,520px);justify-content:center">
36
- <div class="dashboard-card" style="text-align:center">
37
- <div class="dashboard-icon">📖</div>
38
- <h3>Reading Practice</h3>
39
- <p>Start with a sentence, progress to a paragraph, and finish with a story. Score above 80% to advance.</p>
40
- <a href="practice.html" class="primary-btn" style="display:inline-flex;justify-content:center;align-items:center;text-decoration:none;width:100%;box-sizing:border-box">Start Practice</a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  </div>
42
- </div>
43
- </section>
44
-
45
- <section class="dashboard-section progress-section" id="progress">
46
- <div class="section-heading"><p>YOUR PROGRESS</p><h2>Keep growing every day</h2></div>
47
- <div class="progress-container">
48
- <div class="progress-card"><h3>Communication Confidence</h3><div class="progress-bar"><div class="progress-fill"></div></div><p>Getting started</p></div>
49
- <div class="progress-card"><h3>Practice Sessions</h3><div class="progress-number">0</div><p>Sessions completed</p></div>
50
- <div class="progress-card"><h3>Starting Level</h3><div class="progress-number" id="current-level">Level 1</div><p id="level-description">Getting Started</p></div>
51
- </div>
52
- </section>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
- <footer><div class="logo">RISE</div><p>AI-powered reading and communication assistance.</p><p class="copyright">© 2026 RISE. All rights reserved.</p></footer>
55
  <script>
56
  (() => {
57
- const email = (localStorage.getItem("riseActiveUserEmail") || "").trim().toLowerCase();
58
- const key = email ? "riseUser:" + email : null;
59
- let profile = key ? JSON.parse(localStorage.getItem(key) || "null") : null;
60
- if (!profile) {
61
- const level = 1;
62
- profile = { startingLevel: level, unlockedLevel: level, attempts: [], sessionsCompleted: 0, averageScore: 0 };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
- profile.startingLevel = Math.min(5, Math.max(1, Number(profile.startingLevel) || 1));
65
- profile.unlockedLevel = Math.min(5, Math.max(profile.startingLevel, Number(profile.unlockedLevel) || profile.startingLevel));
66
- profile.attempts = Array.isArray(profile.attempts) ? profile.attempts : [];
67
- const names = {1:"Beginner",2:"Elementary",3:"Intermediate",4:"Upper Intermediate",5:"Advanced"};
68
- const descriptions = {1:"Let's build basic reading skills.",2:"Let's strengthen familiar reading skills.",3:"Let's practise connected ideas and varied vocabulary.",4:"Let's develop more complex reading skills.",5:"Let's practise advanced vocabulary and sentence structures."};
69
- document.getElementById("current-level").textContent = "Level " + profile.unlockedLevel;
70
- document.getElementById("level-description").textContent = names[profile.unlockedLevel];
71
- document.getElementById("level-message").textContent =
72
- "Your current level is Level " + profile.unlockedLevel + " — " + names[profile.unlockedLevel] + ". " + descriptions[profile.unlockedLevel] +
73
- " Levels 1–" + profile.unlockedLevel + " are available; higher levels unlock after you score at least 80% on the story at your current level.";
74
- const count = document.querySelector(".progress-card:nth-child(2) .progress-number");
75
- if (count) count.textContent = String(Number(profile.sessionsCompleted) || 0);
76
- const scores = profile.attempts.map(a => Number(a.overall)).filter(n => Number.isFinite(n));
77
- const avg = scores.length ? scores.reduce((a,b) => a+b,0) / scores.length : 0;
78
- profile.averageScore = Math.round(avg * 100) / 100;
79
- const confidence = document.querySelector(".progress-card:first-child .progress-fill");
80
- if (confidence) confidence.style.width = Math.max(0, Math.min(100, profile.averageScore)) + "%";
81
- const confidenceText = document.querySelector(".progress-card:first-child p");
82
- if (confidenceText) confidenceText.textContent = scores.length ? "Average practice score: " + profile.averageScore + "%" : "No practice attempts recorded yet";
83
- if (key) localStorage.setItem(key, JSON.stringify(profile));
84
- document.querySelectorAll(".signin-btn").forEach(link => link.addEventListener("click", () => localStorage.removeItem("riseActiveUserEmail")));
85
  })();
86
  </script>
87
  </body>
 
1
+
2
  <!DOCTYPE html>
3
  <html lang="en">
4
  <head>
 
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
  <title>Dashboard - RISE</title>
8
  <link rel="stylesheet" href="style.css">
9
+
10
+ <style>
11
+ .rise-dashboard {
12
+ max-width: 1180px;
13
+ margin: 0 auto;
14
+ padding: 30px 22px 55px;
15
+ color: #172033;
16
+ }
17
+
18
+ .rise-dashboard * { box-sizing: border-box; }
19
+
20
+ .rd-welcome {
21
+ padding: 30px;
22
+ border-radius: 22px;
23
+ background: linear-gradient(120deg, #e9f7f4, #f2f5ff);
24
+ margin-bottom: 25px;
25
+ }
26
+
27
+ .rd-eyebrow {
28
+ font-size: 12px;
29
+ font-weight: 800;
30
+ letter-spacing: 1.6px;
31
+ color: #0d8178;
32
+ }
33
+
34
+ .rd-welcome h1 {
35
+ font-size: clamp(27px, 4vw, 38px);
36
+ margin: 12px 0;
37
+ }
38
+
39
+ .rd-welcome p { line-height: 1.65; }
40
+
41
+ .rd-button {
42
+ display: inline-block;
43
+ padding: 12px 20px;
44
+ border-radius: 10px;
45
+ background: #087f75;
46
+ color: white;
47
+ text-decoration: none;
48
+ font-weight: 700;
49
+ margin-top: 10px;
50
+ }
51
+
52
+ .rd-section { margin-top: 32px; }
53
+
54
+ .rd-section h2 {
55
+ font-size: 23px;
56
+ margin-bottom: 7px;
57
+ }
58
+
59
+ .rd-muted { color: #64748b; font-size: 14px; }
60
+
61
+ .rd-grid {
62
+ display: grid;
63
+ grid-template-columns: repeat(4, minmax(0, 1fr));
64
+ gap: 15px;
65
+ margin-top: 18px;
66
+ }
67
+
68
+ .rd-card {
69
+ background: white;
70
+ border: 1px solid #e2e8f0;
71
+ border-radius: 17px;
72
+ padding: 20px;
73
+ min-width: 0;
74
+ box-shadow: 0 5px 18px rgba(15, 23, 42, 0.035);
75
+ }
76
+
77
+ .rd-stat-label {
78
+ font-size: 13px;
79
+ color: #64748b;
80
+ font-weight: 650;
81
+ }
82
+
83
+ .rd-stat {
84
+ font-size: 30px;
85
+ font-weight: 800;
86
+ margin: 12px 0 5px;
87
+ overflow-wrap: anywhere;
88
+ }
89
+
90
+ .rd-stat-note {
91
+ font-size: 12px;
92
+ color: #64748b;
93
+ line-height: 1.5;
94
+ }
95
+
96
+ .rd-chart-grid {
97
+ display: grid;
98
+ grid-template-columns: repeat(2, minmax(0, 1fr));
99
+ gap: 18px;
100
+ margin-top: 18px;
101
+ }
102
+
103
+ .rd-chart-card {
104
+ background: white;
105
+ border: 1px solid #e2e8f0;
106
+ border-radius: 17px;
107
+ padding: 20px;
108
+ min-width: 0;
109
+ }
110
+
111
+ .rd-chart-card h3 { margin: 0 0 6px; }
112
+
113
+ .rd-chart-wrap {
114
+ position: relative;
115
+ width: 100%;
116
+ height: 245px;
117
+ margin-top: 15px;
118
+ }
119
+
120
+ .rd-chart-wrap canvas {
121
+ display: block;
122
+ width: 100%;
123
+ height: 100%;
124
+ }
125
+
126
+ .rd-progress-track {
127
+ height: 9px;
128
+ background: #e2e8f0;
129
+ border-radius: 20px;
130
+ overflow: hidden;
131
+ margin: 14px 0 8px;
132
+ }
133
+
134
+ .rd-progress-fill {
135
+ height: 100%;
136
+ width: 0%;
137
+ background: #0d9488;
138
+ border-radius: inherit;
139
+ transition: width .35s ease;
140
+ }
141
+
142
+ .rd-levels {
143
+ display: grid;
144
+ grid-template-columns: repeat(5, minmax(0, 1fr));
145
+ gap: 10px;
146
+ margin-top: 18px;
147
+ }
148
+
149
+ .rd-level {
150
+ padding: 15px 8px;
151
+ text-align: center;
152
+ border: 1px solid #e2e8f0;
153
+ border-radius: 13px;
154
+ background: #f8fafc;
155
+ }
156
+
157
+ .rd-level strong { display: block; margin-bottom: 7px; }
158
+ .rd-level span { font-size: 12px; color: #64748b; }
159
+ .rd-level.current { background: #e0f2fe; border-color: #38bdf8; }
160
+ .rd-level.passed { background: #dcfce7; border-color: #86efac; }
161
+
162
+ .rd-table-wrap { overflow-x: auto; margin-top: 15px; }
163
+
164
+ .rd-table {
165
+ width: 100%;
166
+ border-collapse: collapse;
167
+ font-size: 14px;
168
+ }
169
+
170
+ .rd-table th, .rd-table td {
171
+ padding: 13px 10px;
172
+ border-bottom: 1px solid #e2e8f0;
173
+ text-align: left;
174
+ white-space: nowrap;
175
+ }
176
+
177
+ .rd-table th { color: #64748b; font-weight: 700; }
178
+
179
+ .rd-empty {
180
+ padding: 25px 10px;
181
+ text-align: center;
182
+ color: #64748b;
183
+ line-height: 1.7;
184
+ }
185
+
186
+ .rd-streak-message {
187
+ background: #f8fafc;
188
+ padding: 13px;
189
+ border-radius: 11px;
190
+ margin-top: 15px;
191
+ font-size: 14px;
192
+ line-height: 1.6;
193
+ }
194
+
195
+ @media (max-width: 850px) {
196
+ .rd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
197
+ .rd-chart-grid { grid-template-columns: 1fr; }
198
+ }
199
+
200
+ @media (max-width: 500px) {
201
+ .rise-dashboard { padding: 20px 14px 40px; }
202
+ .rd-welcome { padding: 22px; }
203
+ .rd-grid { gap: 10px; }
204
+ .rd-card { padding: 15px; }
205
+ .rd-stat { font-size: 25px; }
206
+ .rd-levels { gap: 5px; }
207
+ .rd-level { padding: 12px 3px; }
208
+ .rd-level strong { font-size: 12px; }
209
+ .rd-level span { font-size: 10px; }
210
+ }
211
+ </style>
212
  </head>
213
+
214
  <body>
215
  <nav class="navbar">
216
  <div class="logo">RISE</div>
 
222
  <a href="index.html" class="signin-btn">Log Out</a>
223
  </nav>
224
 
225
+ <main class="rise-dashboard">
 
 
 
 
 
 
 
226
 
227
+ <section class="rd-welcome">
228
+ <div class="rd-eyebrow">YOUR PERSONAL LEARNING SPACE</div>
229
+ <h1>Welcome back to RISE</h1>
230
+ <p>
231
+ Every practice session is a step forward.
232
+ Keep reading, track your improvement, and build your confidence.
233
+ </p>
234
+ <p id="rd-date" class="rd-muted"></p>
235
+ <a href="practice.html" class="rd-button">Continue Practising</a>
236
+ </section>
237
+
238
+ <section class="rd-section" id="progress">
239
+ <h2>Your learning at a glance</h2>
240
+ <p class="rd-muted">Your statistics update as you complete reading sessions.</p>
241
+
242
+ <div class="rd-grid">
243
+ <article class="rd-card">
244
+ <div class="rd-stat-label">Current streak</div>
245
+ <div class="rd-stat" id="rd-streak">0 days</div>
246
+ <div class="rd-stat-note" id="rd-streak-note">Complete a session to begin.</div>
247
+ </article>
248
+
249
+ <article class="rd-card">
250
+ <div class="rd-stat-label">Practice sessions</div>
251
+ <div class="rd-stat" id="rd-sessions">0</div>
252
+ <div class="rd-stat-note">Recorded reading results</div>
253
+ </article>
254
+
255
+ <article class="rd-card">
256
+ <div class="rd-stat-label">Average score</div>
257
+ <div class="rd-stat" id="rd-average">--</div>
258
+ <div class="rd-stat-note">Average overall score</div>
259
+ </article>
260
+
261
+ <article class="rd-card">
262
+ <div class="rd-stat-label">Best score</div>
263
+ <div class="rd-stat" id="rd-best">--</div>
264
+ <div class="rd-stat-note">Your highest recorded score</div>
265
+ </article>
266
  </div>
267
+ </section>
268
+
269
+ <section class="rd-section">
270
+ <h2>Your activity and improvement</h2>
271
+ <p class="rd-muted">Review your practice frequency and recent scores.</p>
272
+
273
+ <div class="rd-chart-grid">
274
+ <article class="rd-chart-card">
275
+ <h3>Weekly activity</h3>
276
+ <p class="rd-muted">Days on which you completed a session</p>
277
+ <div class="rd-chart-wrap">
278
+ <canvas id="rd-week-chart" role="img"
279
+ aria-label="Bar chart of practice sessions by day"></canvas>
280
+ </div>
281
+ <p class="rd-muted" id="rd-week-total"></p>
282
+ </article>
283
+
284
+ <article class="rd-chart-card">
285
+ <h3>Score trend</h3>
286
+ <p class="rd-muted">Your most recent recorded results</p>
287
+ <div class="rd-chart-wrap">
288
+ <canvas id="rd-score-chart" role="img"
289
+ aria-label="Line chart of recent overall scores"></canvas>
290
+ </div>
291
+ <p class="rd-muted">The dashed line represents the 80% target.</p>
292
+ </article>
293
+ </div>
294
+ </section>
295
+
296
+ <section class="rd-section">
297
+ <h2>Level progression</h2>
298
+ <p class="rd-muted">
299
+ Your starting level comes from your saved assessment setting.
300
+ This display does not independently unlock levels.
301
+ </p>
302
+
303
+ <div class="rd-card">
304
+ <div class="rd-stat-label">Starting level</div>
305
+ <div class="rd-stat" id="rd-current-level">Level 1</div>
306
+ <div id="rd-level-description" class="rd-muted"></div>
307
+ <div class="rd-progress-track">
308
+ <div class="rd-progress-fill" id="rd-level-progress"></div>
309
+ </div>
310
+ <div class="rd-stat-note" id="rd-level-note"></div>
311
+ </div>
312
+
313
+ <div class="rd-levels" id="rd-levels"></div>
314
+ </section>
315
+
316
+ <section class="rd-section">
317
+ <h2>Recent practice sessions</h2>
318
+ <p class="rd-muted">Your saved results from the RISE practice page.</p>
319
+
320
+ <div class="rd-card">
321
+ <div class="rd-table-wrap">
322
+ <table class="rd-table">
323
+ <thead>
324
+ <tr>
325
+ <th>Level</th>
326
+ <th>Activity</th>
327
+ <th>Overall score</th>
328
+ <th>Word accuracy</th>
329
+ <th>Word error rate</th>
330
+ </tr>
331
+ </thead>
332
+ <tbody id="rd-history-body"></tbody>
333
+ </table>
334
+ </div>
335
+ <div id="rd-history-empty" class="rd-empty" hidden>
336
+ No practice results saved yet.<br>
337
+ Start a reading session and select “Finish passage &amp; show score”
338
+ to record your results.
339
+ </div>
340
+ </div>
341
+ </section>
342
+
343
+ <section class="rd-section">
344
+ <h2>Your next step</h2>
345
+ <div class="rd-card">
346
+ <h3 id="rd-next-title">Start your first session</h3>
347
+ <p class="rd-muted" id="rd-next-description">
348
+ Read a sentence, review your feedback, and continue practising.
349
+ </p>
350
+ <a href="practice.html" class="rd-button">Go to Practice</a>
351
+ </div>
352
+ </section>
353
+
354
+ </main>
355
+
356
+ <footer>
357
+ <div class="logo">RISE</div>
358
+ <p>AI-powered reading and communication assistance.</p>
359
+ <p class="copyright">© 2026 RISE. All rights reserved.</p>
360
+ </footer>
361
 
 
362
  <script>
363
  (() => {
364
+ "use strict";
365
+
366
+ const $ = id => document.getElementById(id);
367
+ const levelNames = [
368
+ "Beginner",
369
+ "Elementary",
370
+ "Intermediate",
371
+ "Upper Intermediate",
372
+ "Advanced"
373
+ ];
374
+
375
+ function readArray(key) {
376
+ try {
377
+ const value = JSON.parse(localStorage.getItem(key) || "[]");
378
+ return Array.isArray(value) ? value : [];
379
+ } catch {
380
+ return [];
381
+ }
382
+ }
383
+
384
+ function number(value) {
385
+ const n = Number(value);
386
+ return Number.isFinite(n) ? n : 0;
387
+ }
388
+
389
+ function dayKey(date) {
390
+ const y = date.getFullYear();
391
+ const m = String(date.getMonth() + 1).padStart(2, "0");
392
+ const d = String(date.getDate()).padStart(2, "0");
393
+ return `${y}-${m}-${d}`;
394
+ }
395
+
396
+ function readPracticeDays() {
397
+ return [...new Set(
398
+ readArray("risePracticeDays")
399
+ .filter(d => typeof d === "string" &&
400
+ /^\d{4}-\d{2}-\d{2}$/.test(d))
401
+ )].sort();
402
+ }
403
+
404
+ function calculateStreak(days) {
405
+ const set = new Set(days);
406
+ const today = new Date();
407
+ const todayKey = dayKey(today);
408
+ const yesterday = new Date(today);
409
+ yesterday.setDate(yesterday.getDate() - 1);
410
+ const yesterdayKey = dayKey(yesterday);
411
+
412
+ // A streak remains active until the current day is missed.
413
+ let cursor;
414
+ if (set.has(todayKey)) cursor = today;
415
+ else if (set.has(yesterdayKey)) cursor = yesterday;
416
+ else return 0;
417
+
418
+ let count = 0;
419
+ while (set.has(dayKey(cursor))) {
420
+ count++;
421
+ cursor.setDate(cursor.getDate() - 1);
422
+ }
423
+ return count;
424
+ }
425
+
426
+ function levelNumber(value) {
427
+ if (typeof value === "number") {
428
+ return Math.min(5, Math.max(1, value));
429
+ }
430
+
431
+ const names = [
432
+ "beginner", "elementary", "intermediate",
433
+ "upper_intermediate", "advanced"
434
+ ];
435
+ const index = names.indexOf(String(value || "").toLowerCase());
436
+ if (index >= 0) return index + 1;
437
+
438
+ const match = String(value || "").match(/level\s*([1-5])/i);
439
+ return match ? Number(match[1]) : 1;
440
+ }
441
+
442
+ function drawBarChart(canvas, labels, values) {
443
+ const ctx = canvas.getContext("2d");
444
+ const rect = canvas.getBoundingClientRect();
445
+ const width = Math.max(280, rect.width);
446
+ const height = Math.max(200, rect.height);
447
+ const ratio = window.devicePixelRatio || 1;
448
+
449
+ canvas.width = width * ratio;
450
+ canvas.height = height * ratio;
451
+ ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
452
+ ctx.clearRect(0, 0, width, height);
453
+
454
+ const left = 32, right = 10, top = 18, bottom = 35;
455
+ const plotW = width - left - right;
456
+ const plotH = height - top - bottom;
457
+ const maxValue = Math.max(3, ...values);
458
+
459
+ ctx.font = "11px sans-serif";
460
+ ctx.textAlign = "right";
461
+ ctx.fillStyle = "#64748b";
462
+
463
+ for (let i = 0; i <= 3; i++) {
464
+ const y = top + plotH * i / 3;
465
+ const value = Math.round(maxValue * (3 - i) / 3);
466
+ ctx.fillText(String(value), left - 7, y + 4);
467
+ ctx.beginPath();
468
+ ctx.strokeStyle = "#e2e8f0";
469
+ ctx.moveTo(left, y);
470
+ ctx.lineTo(width - right, y);
471
+ ctx.stroke();
472
+ }
473
+
474
+ const slot = plotW / labels.length;
475
+ const barW = Math.min(28, slot * 0.55);
476
+
477
+ labels.forEach((label, i) => {
478
+ const h = plotH * values[i] / maxValue;
479
+ const x = left + i * slot + (slot - barW) / 2;
480
+ const y = top + plotH - h;
481
+
482
+ ctx.fillStyle = "#0d9488";
483
+ ctx.fillRect(x, y, barW, h);
484
+
485
+ ctx.textAlign = "center";
486
+ ctx.fillStyle = "#64748b";
487
+ ctx.fillText(label, x + barW / 2, height - 12);
488
+ });
489
+ }
490
+
491
+ function drawScoreChart(canvas, scores) {
492
+ const ctx = canvas.getContext("2d");
493
+ const rect = canvas.getBoundingClientRect();
494
+ const width = Math.max(280, rect.width);
495
+ const height = Math.max(200, rect.height);
496
+ const ratio = window.devicePixelRatio || 1;
497
+
498
+ canvas.width = width * ratio;
499
+ canvas.height = height * ratio;
500
+ ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
501
+ ctx.clearRect(0, 0, width, height);
502
+
503
+ const left = 34, right = 14, top = 20, bottom = 30;
504
+ const plotW = width - left - right;
505
+ const plotH = height - top - bottom;
506
+
507
+ ctx.font = "11px sans-serif";
508
+ ctx.textAlign = "right";
509
+ ctx.fillStyle = "#64748b";
510
+
511
+ [0, 25, 50, 75, 100].forEach(v => {
512
+ const y = top + plotH * (100 - v) / 100;
513
+ ctx.fillText(v + "%", left - 6, y + 4);
514
+ ctx.beginPath();
515
+ ctx.strokeStyle = v === 80 ? "#f59e0b" : "#e2e8f0";
516
+ ctx.setLineDash(v === 80 ? [5, 4] : []);
517
+ ctx.moveTo(left, y);
518
+ ctx.lineTo(width - right, y);
519
+ ctx.stroke();
520
+ });
521
+ ctx.setLineDash([]);
522
+
523
+ if (!scores.length) {
524
+ ctx.textAlign = "center";
525
+ ctx.fillStyle = "#64748b";
526
+ ctx.fillText("Complete a session to see your scores", width / 2, height / 2);
527
+ return;
528
+ }
529
+
530
+ const points = scores.map((score, i) => ({
531
+ x: scores.length === 1
532
+ ? left + plotW / 2
533
+ : left + plotW * i / (scores.length - 1),
534
+ y: top + plotH * (100 - score) / 100
535
+ }));
536
+
537
+ ctx.beginPath();
538
+ points.forEach((p, i) => {
539
+ if (i === 0) ctx.moveTo(p.x, p.y);
540
+ else ctx.lineTo(p.x, p.y);
541
+ });
542
+ ctx.strokeStyle = "#2563eb";
543
+ ctx.lineWidth = 2.5;
544
+ ctx.stroke();
545
+
546
+ points.forEach((p, i) => {
547
+ ctx.beginPath();
548
+ ctx.arc(p.x, p.y, 4, 0, Math.PI * 2);
549
+ ctx.fillStyle = scores[i] >= 80 ? "#0d9488" : "#2563eb";
550
+ ctx.fill();
551
+ });
552
+
553
+ ctx.textAlign = "center";
554
+ ctx.fillStyle = "#64748b";
555
+ points.forEach((p, i) => {
556
+ ctx.fillText(String(i + 1), p.x, height - 10);
557
+ });
558
+ }
559
+
560
+ function render() {
561
+ $("rd-date").textContent = new Date().toLocaleDateString(
562
+ undefined,
563
+ { weekday: "long", year: "numeric", month: "long", day: "numeric" }
564
+ );
565
+
566
+ const history = readArray("riseHistory");
567
+ const days = readPracticeDays();
568
+ const streak = calculateStreak(days);
569
+
570
+ // History is stored by the existing RISE practice frontend.
571
+ const scores = history.map(r => number(r.overall))
572
+ .filter(n => n >= 0 && n <= 100);
573
+ const accuracies = history.map(r => number(r.word_accuracy))
574
+ .filter(n => n >= 0 && n <= 100);
575
+
576
+ const average = scores.length
577
+ ? scores.reduce((a, b) => a + b, 0) / scores.length
578
+ : null;
579
+ const best = scores.length ? Math.max(...scores) : null;
580
+
581
+ $("rd-streak").textContent = `${streak} ${streak === 1 ? "day" : "days"}`;
582
+ $("rd-streak-note").textContent = streak
583
+ ? "Keep practising regularly to maintain your streak."
584
+ : "Practise today to start a new streak.";
585
+
586
+ $("rd-sessions").textContent = history.length;
587
+ $("rd-average").textContent = average === null
588
+ ? "--" : average.toFixed(1) + "%";
589
+ $("rd-best").textContent = best === null
590
+ ? "--" : best.toFixed(1) + "%";
591
+
592
+ const startingLevel = Math.min(5, Math.max(
593
+ 1, Number(localStorage.getItem("startingLevel")) || 1
594
+ ));
595
+
596
+ $("rd-current-level").textContent = `Level ${startingLevel}`;
597
+ $("rd-level-description").textContent = levelNames[startingLevel - 1];
598
+
599
+ // This is a display of the starting level, not an unlock calculation.
600
+ $("rd-level-progress").style.width =
601
+ ((startingLevel - 1) / 4 * 100) + "%";
602
+ $("rd-level-note").textContent =
603
+ `Starting point: Level ${startingLevel} of 5.`;
604
+
605
+ $("rd-levels").innerHTML = levelNames.map((name, i) => {
606
+ const n = i + 1;
607
+ const state = n === startingLevel ? "current" : "";
608
+ const caption = n === startingLevel ? "Starting level" : "Level";
609
+ return `<div class="rd-level ${state}">
610
+ <strong>Level ${n}</strong>
611
+ <span>${name}</span><br>
612
+ <span>${caption}</span>
613
+ </div>`;
614
+ }).join("");
615
+
616
+ const body = $("rd-history-body");
617
+ body.replaceChildren();
618
+
619
+ const recent = history.slice(-8).reverse();
620
+ $("rd-history-empty").hidden = recent.length > 0;
621
+
622
+ recent.forEach(r => {
623
+ const tr = document.createElement("tr");
624
+ const values = [
625
+ `Level ${levelNumber(r.level)}`,
626
+ String(r.part || "Reading"),
627
+ number(r.overall).toFixed(1) + "%",
628
+ number(r.word_accuracy).toFixed(1) + "%",
629
+ number(r.wer).toFixed(1) + "%"
630
+ ];
631
+
632
+ values.forEach(value => {
633
+ const td = document.createElement("td");
634
+ td.textContent = value;
635
+ tr.appendChild(td);
636
+ });
637
+
638
+ body.appendChild(tr);
639
+ });
640
+
641
+ const today = new Date();
642
+ const weekLabels = [];
643
+ const weekKeys = [];
644
+
645
+ for (let i = 6; i >= 0; i--) {
646
+ const date = new Date(today);
647
+ date.setDate(today.getDate() - i);
648
+ weekKeys.push(dayKey(date));
649
+ weekLabels.push(date.toLocaleDateString(undefined, {weekday: "short"}));
650
+ }
651
+
652
+ const daySet = new Set(days);
653
+ const weekCounts = weekKeys.map(key => daySet.has(key) ? 1 : 0);
654
+
655
+ drawBarChart($("rd-week-chart"), weekLabels, weekCounts);
656
+ $("rd-week-total").textContent =
657
+ `${weekCounts.reduce((a, b) => a + b, 0)} of the last 7 days had recorded practice.`;
658
+
659
+ drawScoreChart($("rd-score-chart"), scores.slice(-8));
660
+
661
+ if (!history.length) {
662
+ $("rd-next-title").textContent = "Start your first session";
663
+ $("rd-next-description").textContent =
664
+ "Your charts and statistics will populate after you complete and score a reading session.";
665
+ } else if (average < 80) {
666
+ $("rd-next-title").textContent = "Keep practising your current activity";
667
+ $("rd-next-description").textContent =
668
+ "Your recorded average is below 80%. Review your feedback and practise again to improve.";
669
+ } else {
670
+ $("rd-next-title").textContent = "Keep building consistency";
671
+ $("rd-next-description").textContent =
672
+ "Your recorded average is at least 80%. Follow the progression rules shown in the practice page.";
673
+ }
674
  }
675
+
676
+ render();
677
+
678
+ // Keep charts sized correctly when the dashboard layout changes.
679
+ let resizeTimer;
680
+ window.addEventListener("resize", () => {
681
+ clearTimeout(resizeTimer);
682
+ resizeTimer = setTimeout(render, 150);
683
+ });
 
 
 
 
 
 
 
 
 
 
 
 
684
  })();
685
  </script>
686
  </body>