Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
1489 lines (1357 loc) · 60.8 KB
/
Copy pathapp.js
File metadata and controls
1489 lines (1357 loc) · 60.8 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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ============================================================================
CloudCert Lab — Zero-Server Multi-Cloud Exam Simulator Engine
Hosting cost: $0/month on Cloudflare Pages + Cloudflare Worker license check
============================================================================ */
const CONFIG = {
// Link real en vivo de Gumroad ($19.99 pago unico -> entrega ZIP + clave Pro AES-256):
CHECKOUT_URL: "https://gabbler407.gumroad.com/l/cloudcert-lab-pro?wanted=true",
// Opcional: si despliegas worker/license-worker.js en Cloudflare Workers ($0/mes), pega su URL aqui:
LICENSE_API_URL: "",
};
const KDP_COMPANIONS = {
"aws-clf-c02": {
title: "AWS Certified Cloud Practitioner (CLF-C02) Practice Exams (410 Qs)",
url: "https://www.amazon.com/dp/B0HQ8ZT44Y",
badge: "FREE on Kindle Unlimited ($2.99 eBook)",
},
"aws-aif-c01": {
title: "AWS Certified AI Practitioner (AIF-C01) Practice Tests",
url: "https://www.amazon.com/dp/B0HQXNM3VY",
badge: "FREE on Kindle Unlimited ($2.99 eBook)",
},
"aws-mla-c01": {
title: "AWS Machine Learning Engineer Associate (MLA-C01) Practice Tests",
url: "https://www.amazon.com/dp/B0HS1GKQSQ",
badge: "FREE on Kindle Unlimited ($2.99 eBook)",
},
"aws-saa-c03": {
title: "AWS Solutions Architect Associate (SAA-C03) Practice Tests",
url: "https://www.amazon.com/dp/B0HRVB8PZ3",
badge: "FREE on Kindle Unlimited ($2.99 eBook)",
},
"aws-dva-c03": {
title: "AWS Certified Developer – Associate (DVA-C03) Practice Tests (2026–2027)",
url: "https://www.amazon.com/dp/B0HTK8KRM5",
badge: "NEW DEC 2026 · FREE on Kindle Unlimited ($2.99 eBook · Paperback $16.99)",
},
"aws-dva-c02": {
title: "AWS Certification Practice Exams Series (2026–2027 Editions)",
url: "https://www.amazon.com/author/gabrieln",
badge: "AWS Associate Series · Free on Kindle Unlimited",
},
"aws-dea-c01": {
title: "AWS Certified Data Engineer – Associate (DEA-C01) Practice Tests (2026–2027)",
url: "https://www.amazon.com/dp/B0GX51KRYL",
badge: "FREE on Kindle Unlimited ($2.99 eBook · Paperback $16.99)",
},
"azure-ai-901": {
title: "Microsoft Azure AI Fundamentals (AI-901) Practice Tests",
url: "https://www.amazon.com/dp/B0HS93MZC7",
badge: "FREE on Kindle Unlimited ($2.99 eBook · Paperback $16.99)",
},
"azure-ai-103": {
title: "Microsoft Azure AI-103 (AI & Agents) Practice Tests (2026–2027 Edition)",
url: "https://www.amazon.com/author/gabrieln",
badge: "Azure AI Engineer Series · Gabriel N. on Amazon",
},
"aws-aip-c01": {
title: "AWS Generative AI Developer – Professional (AIP-C01) Practice Tests (2026–2027)",
url: "https://www.amazon.com/author/gabrieln",
badge: "AWS Professional Series · Gabriel N. on Amazon",
},
"gcp-genai-leader": {
title: "Google Cloud Certified Generative AI Leader Practice Tests",
url: "https://www.amazon.com/dp/B0HSL1MYYM",
badge: "FREE on Kindle Unlimited ($2.99 eBook · Paperback $16.99)",
},
default: {
title: "2026–2027 Multi-Cloud & AWS Practice Exams Series by Gabriel N.",
url: "https://www.amazon.com/author/gabrieln",
badge: "Read FREE on Kindle Unlimited",
},
};
function getKdpCompanion(slug) {
return KDP_COMPANIONS[slug] || KDP_COMPANIONS.default;
}
const UDEMY_COMPANIONS = {
"azure-ai-901": "https://www.udemy.com/course/microsoft-azure-ai-fundamentals-ai-901-practice-exams-2026-j/?couponCode=AI901DEC26",
"gcp-genai-leader": "https://www.udemy.com/course/google-cloud-generative-ai-leader-practice-exams-2026-2027/?couponCode=GCPGENAIDEC26",
"aws-aif-c01": "https://www.udemy.com/course/aws-certified-ai-practitioner-aif-c01-practice-exams-2026-mf/?couponCode=AIFC01DEC26",
"aws-mla-c01": "https://www.udemy.com/course/aws-machine-learning-engineer-associate-mla-c01-mock-tests/?couponCode=MLAC01DEC26",
"aws-dea-c01": "https://www.udemy.com/course/aws-certified-data-engineer-associate-dea-c01-mock-exams-d/?couponCode=DEAC01DEC26",
"aws-dva-c02": "https://www.udemy.com/course/aws-certified-developer-associate-dva-c02-practice-exams-dx/?couponCode=DVAC02DEC26",
"aws-saa-c03": "https://www.udemy.com/course/aws-solutions-architect-associate-saa-c03-practice-exams-m/?couponCode=SAAC03DEC26",
"aws-clf-c02": "https://www.udemy.com/course/aws-certified-cloud-practitioner-clf-c02-practice-exams-eg/?couponCode=CLFC02DEC26",
"aws-dva-c03": "https://www.udemy.com/course/aws-certified-developer-associate-dva-c03-practice-exams-p/?couponCode=DVAC03DEC26",
};
// Populate with Udemy instructor referral codes to earn 97% vs 37% revenue share:
const UDEMY_REFERRAL_CODES = {
"azure-ai-901": "D8A856261A80E97E9117",
"gcp-genai-leader": "277C95257CA6174C530B",
"aws-aif-c01": "F3F8E6DE85B56E6151A5",
"aws-mla-c01": "BA52EE4BBFC11D3A885E",
"aws-dea-c01": "A1754747AF112676F0B6",
"aws-dva-c02": "5842552C40A062AE0228",
"aws-saa-c03": "7A6DE3C64FBA7EF1F2F0",
"aws-clf-c02": "AE9A07D6FF925933AD30",
"aws-dva-c03": "BAE8E864A6D2DF74ADB3",
};
function getUdemyCompanion(slug) {
const base = UDEMY_COMPANIONS[slug] || "";
if (!base) return "";
const code = UDEMY_REFERRAL_CODES[slug];
if (!code) return base;
const sep = base.includes("?") ? "&" : "?";
return `${base}${sep}referralCode=${encodeURIComponent(code)}`;
}
const PRO_CACHE = {};
function b64ToBytes(b64) {
const bin = atob(b64);
const bytes = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
return bytes;
}
async function decryptProEnvelope(env, passphrase) {
const enc = new TextEncoder();
const baseKey = await crypto.subtle.importKey("raw", enc.encode(passphrase), "PBKDF2", false, ["deriveKey"]);
const aesKey = await crypto.subtle.deriveKey(
{ name: "PBKDF2", salt: b64ToBytes(env.salt), iterations: env.iter, hash: "SHA-256" },
baseKey,
{ name: "AES-GCM", length: 256 },
false,
["decrypt"]
);
const plainBuf = await crypto.subtle.decrypt(
{ name: "AES-GCM", iv: b64ToBytes(env.iv) },
aesKey,
b64ToBytes(env.ct)
);
return JSON.parse(new TextDecoder().decode(plainBuf));
}
async function fetchCertPayload(slug, tier) {
if (tier !== "pro") {
const resp = await fetch(`data/free/${slug}.json`);
return await resp.json();
}
if (PRO_CACHE[slug]) return PRO_CACHE[slug];
// 1) Try AES-256-GCM encrypted vault (zero-server GitHub Pages / Cloudflare Pages safe!)
const pass = localStorage.getItem("cloudcert_vault_pass") || "";
if (pass) {
const encResp = await fetch(`data/pro_enc/${slug}.enc.json`);
if (encResp.ok) {
const env = await encResp.json();
const payload = await decryptProEnvelope(env, pass);
PRO_CACHE[slug] = payload;
return payload;
}
}
// 2) Fallback for offline Gumroad ZIP edition (plain local data/pro/*.json)
const resp = await fetch(`data/pro/${slug}.json`);
const payload = await resp.json();
PRO_CACHE[slug] = payload;
return payload;
}
const STATE = {
catalog: null,
vendorFilter: "ALL",
searchQuery: "",
isPro: localStorage.getItem("cloudcert_pro_unlocked") === "1",
licenseKey: localStorage.getItem("cloudcert_license_key") || "",
activeCert: null,
activeQuestions: [],
mode: "study", // 'study' | 'exam'
examLabel: "",
currentIndex: 0,
answers: {}, // idx -> array of selected 0-based option indices
checked: {}, // idx -> boolean (study mode)
flagged: {}, // idx -> boolean
secondsLeft: 0,
elapsedSeconds: 0,
timerHandle: null,
};
const $ = (id) => document.getElementById(id);
const tr = (key, vars) => (window.CC_I18N ? window.CC_I18N.t(key, vars) : key);
function showView(viewId) {
["viewCatalog", "viewCertDetail", "viewRunner", "viewResults", "viewFlashcards"].forEach((v) => {
const el = $(v);
if (el) el.classList.toggle("hidden", v !== viewId);
});
window.scrollTo({ top: 0, behavior: "smooth" });
}
function getStudyStreak() {
try {
const raw = JSON.parse(localStorage.getItem("cloudcert_streak") || "{}");
const today = new Date().toISOString().slice(0, 10);
const yesterday = new Date(Date.now() - 86400000).toISOString().slice(0, 10);
if (raw.lastDate === today || raw.lastDate === yesterday) return Number(raw.count) || 0;
return 0;
} catch {
return 0;
}
}
function recordStudyActivity() {
try {
const today = new Date().toISOString().slice(0, 10);
const yesterday = new Date(Date.now() - 86400000).toISOString().slice(0, 10);
const raw = JSON.parse(localStorage.getItem("cloudcert_streak") || "{}");
let count = Number(raw.count) || 0;
if (raw.lastDate === today) {
count = Math.max(1, count);
} else if (raw.lastDate === yesterday) {
count += 1;
} else {
count = 1;
}
localStorage.setItem("cloudcert_streak", JSON.stringify({ lastDate: today, count }));
updateStreakUI();
} catch {}
}
function updateStreakUI() {
const el = $("statStreak");
if (!el) return;
const s = getStudyStreak();
el.textContent = `🔥 ${s}d`;
el.title = s > 0 ? `${s}-day study streak! Keep going.` : "Answer a question or flip a flashcard to start your streak.";
}
function updatePlanUI() {
const badge = $("planBadge");
const btnTop = $("btnUnlockTop");
if (STATE.isPro) {
badge.textContent = tr("plan_pro");
badge.className = "badge badge-success";
btnTop.textContent = tr("btn_pro_active");
btnTop.className = "btn btn-success";
} else {
badge.textContent = tr("plan_free");
badge.className = "badge badge-neutral";
btnTop.textContent = tr("btn_unlock_top");
btnTop.className = "btn btn-primary";
}
}
function getSavedAttempts() {
try {
return JSON.parse(localStorage.getItem("cloudcert_attempts") || "[]");
} catch {
return [];
}
}
function saveAttempt(attempt) {
const list = getSavedAttempts();
list.unshift(attempt);
localStorage.setItem("cloudcert_attempts", JSON.stringify(list.slice(0, 40)));
$("statAttempts").textContent = String(list.length);
}
function renderCatalog() {
if (!STATE.catalog) return;
const grid = $("certsGrid");
const q = STATE.searchQuery.trim().toLowerCase();
const filtered = STATE.catalog.certs.filter((c) => {
const matchVendor = STATE.vendorFilter === "ALL" || c.vendor === STATE.vendorFilter;
const matchQuery =
!q ||
`${c.vendor} ${c.code} ${c.title} ${c.subtitle}`.toLowerCase().includes(q);
return matchVendor && matchQuery;
});
$("statCerts").textContent = String(STATE.catalog.certs.length);
$("statQuestions").textContent = STATE.catalog.total_questions.toLocaleString("en-US");
$("statAttempts").textContent = String(getSavedAttempts().length);
updateStreakUI();
grid.innerHTML = filtered
.map(
(c) => `
<article class="card cert-card">
<div>
<div class="cert-head">
<span class="badge badge-brand">${escapeHtml(c.vendor)} · ${escapeHtml(c.code)}</span>
<span class="badge ${STATE.isPro ? "badge-success" : "badge-neutral"}">
${STATE.isPro ? tr("cert_badge_pro") : tr("cert_badge_free")}
</span>
</div>
<h3 class="cert-title">${escapeHtml(c.title)}</h3>
<p class="cert-sub">${escapeHtml(c.subtitle)}</p>
</div>
<div>
<div class="cert-meta">
<span>⏱ ${c.duration_min} min</span>
<span>🎯 ${tr("cert_meta_pass")} ${c.pass_pct}%</span>
<span>📝 ${c.exams} ${tr("cert_meta_mocks")}</span>
</div>
<div class="cert-actions" style="margin-top:0.8rem;">
<button class="btn btn-primary" type="button" data-action="quick-free" data-slug="${c.slug}">
${tr("cert_btn_free")}
</button>
<button class="btn" type="button" data-action="open-cert" data-slug="${c.slug}">
${tr("cert_btn_mocks")}
</button>
<a class="btn btn-ghost" href="exams/${c.slug}/">${tr("cert_btn_guide")}</a>
</div>
</div>
</article>`
)
.join("");
}
function openCertDetail(slug) {
const cert = STATE.catalog.certs.find((c) => c.slug === slug);
if (!cert) return;
STATE.activeCert = cert;
const domainRows = Object.entries(cert.domains)
.map(([k, v]) => `<li><strong>${escapeHtml(v)}</strong></li>`)
.join("");
const examCards = [1, 2, 3, 4]
.map((examNum) => {
const locked = !STATE.isPro;
return `
<div class="card" style="padding:1rem; background:var(--surface-2);">
<div style="display:flex; justify-content:space-between; align-items:center; gap:0.5rem;">
<strong>Mock Exam ${examNum} (65 Questions)</strong>
<span class="badge ${locked ? "badge-warning" : "badge-success"}">${locked ? "PRO" : "UNLOCKED"}</span>
</div>
<div style="font-size:var(--fs-sm); color:var(--muted); margin:0.35rem 0 0.8rem;">
Timed ${cert.duration_min} min · Pass bar ${cert.pass_pct}% · Full domain analytics
</div>
<div style="display:flex; gap:0.5rem; flex-wrap:wrap;">
<button class="btn btn-primary" type="button" data-start-exam="${examNum}" data-mode="exam" ${locked ? 'data-locked="1"' : ""}>
Timed Exam
</button>
<button class="btn" type="button" data-start-exam="${examNum}" data-mode="study" ${locked ? 'data-locked="1"' : ""}>
Study Mode
</button>
</div>
</div>`;
})
.join("");
$("certDetailCard").innerHTML = `
<div style="display:flex; justify-content:space-between; align-items:flex-start; gap:1rem; flex-wrap:wrap;">
<div>
<span class="badge badge-brand">${escapeHtml(cert.vendor)} · ${escapeHtml(cert.code)}</span>
<h2 style="margin:0.45rem 0 0.25rem;">${escapeHtml(cert.title)}</h2>
<p style="margin:0; color:var(--muted);">${escapeHtml(cert.subtitle)}</p>
</div>
<div style="display:flex; gap:0.5rem; flex-wrap:wrap;">
<button class="btn btn-primary" type="button" id="btnDetailFreeStudy">Try Free 15 Qs (Study)</button>
<button class="btn" type="button" id="btnDetailFreeExam">Try Free 15 Qs (Timed)</button>
<button class="btn" type="button" id="btnDetailFlashcards">Flip Flashcards</button>
</div>
</div>
<div style="margin:1.1rem 0; padding:0.9rem 1rem; border-radius:var(--radius); background:var(--surface-2); border:1px solid var(--border);">
<div style="font-weight:700; font-size:var(--fs-sm); margin-bottom:0.4rem;">Official Blueprint Domains Mapped:</div>
<ul style="margin:0; padding-left:1.2rem; font-size:var(--fs-sm); color:var(--muted);">${domainRows}</ul>
</div>
<h3 style="margin:1rem 0 0.7rem; font-size:1rem;">4 Full-Length Practice Exams (260 Total Scenarios)</h3>
<div style="display:grid; grid-template-columns:repeat(auto-fit, minmax(260px, 1fr)); gap:0.85rem;">
${examCards}
</div>
<div id="detailHacksPreview" style="margin-top:1.2rem; padding:1rem; border-radius:var(--radius); background:var(--surface-2); border:1px solid var(--border);">
<span class="badge badge-info">FREE CHEAT SHEET SAMPLE (3 OF 25 ${escapeHtml(cert.code)} EXAM HACKS)</span>
<div style="font-size:var(--fs-sm); color:var(--muted); margin-top:0.4rem;">Loading verified high-yield elimination rules...</div>
</div>
<div class="kdp-cross-sell" style="margin-top:1rem;">
<div>
<span class="badge badge-info">${escapeHtml(getKdpCompanion(cert.slug).badge)}</span>
<div style="font-weight:700; margin-top:0.3rem;">Study Offline or on Udemy: ${escapeHtml(getKdpCompanion(cert.slug).title)}</div>
<div style="font-size:var(--fs-sm); color:var(--muted);">Get all 11 exams (2,860 Qs) for <strong>$19.99</strong> on Gumroad vs <strong>$49.99/course</strong> on Udemy, or read free with Kindle Unlimited.</div>
</div>
<div style="display:flex; gap:0.5rem; flex-wrap:wrap;">
<a class="btn" href="${escapeHtml(getKdpCompanion(cert.slug).url)}" target="_blank" rel="noopener">Amazon Book →</a>
${getUdemyCompanion(cert.slug) ? `<a class="btn btn-ghost" href="${escapeHtml(getUdemyCompanion(cert.slug))}" target="_blank" rel="noopener">Udemy ($12.99 Launch Deal) →</a>` : ""}
</div>
</div>
`;
fetchCertPayload(cert.slug, "free")
.then((payload) => {
const box = $("detailHacksPreview");
if (!box || !STATE.activeCert || STATE.activeCert.slug !== cert.slug) return;
const hacks = (payload.questions || []).filter((q) => q.hack).slice(0, 3);
if (!hacks.length) {
box.classList.add("hidden");
return;
}
box.innerHTML = `
<div style="display:flex; justify-content:space-between; align-items:center; gap:0.5rem; flex-wrap:wrap;">
<span class="badge badge-info">FREE CHEAT SHEET SAMPLE (3 OF 25 ${escapeHtml(cert.code)} EXAM HACKS)</span>
<a href="exams/free-cloud-ai-exam-cheat-sheet-2026/" style="font-size:var(--fs-sm); font-weight:600; color:var(--brand);">See All 33 Free Hacks →</a>
</div>
${hacks
.map(
(q, i) =>
`<div class="hack-callout" style="margin-top:0.55rem;"><strong>Hack #${i + 1} (${escapeHtml(q.domain)}):</strong> ${escapeHtml(q.hack)}</div>`
)
.join("")}
<div style="margin-top:0.75rem; font-size:var(--fs-sm); color:var(--muted); display:flex; justify-content:space-between; align-items:center; gap:0.5rem; flex-wrap:wrap;">
<span>Full <strong>Master Cheat Sheets PDF</strong> + Offline ZIP included in Pro Vault ($19.99).</span>
<a class="btn btn-primary" href="${CONFIG.CHECKOUT_URL}">Get Full PDF + 2,860 Qs →</a>
</div>
`;
})
.catch(() => {});
$("btnDetailFreeStudy").onclick = () => startSession(cert.slug, "free", null, "study");
$("btnDetailFreeExam").onclick = () => startSession(cert.slug, "free", null, "exam");
$("btnDetailFlashcards").onclick = () => startFlashcards(cert.slug);
$("certDetailCard").querySelectorAll("[data-start-exam]").forEach((btn) => {
btn.addEventListener("click", () => {
if (btn.dataset.locked === "1") {
openProModal();
return;
}
startSession(cert.slug, "pro", Number(btn.dataset.startExam), btn.dataset.mode);
});
});
showView("viewCertDetail");
}
async function startSession(slug, tier, examNum, mode) {
const cert = STATE.catalog.certs.find((c) => c.slug === slug);
if (!cert) return;
STATE.activeCert = cert;
const payload = await fetchCertPayload(slug, tier);
let qs = payload.questions;
if (examNum) {
qs = qs.filter((q) => q.exam === examNum);
}
STATE.activeQuestions = qs;
STATE.mode = mode;
STATE.examLabel = examNum
? `${cert.code} — Mock Exam ${examNum} (${qs.length} Qs)`
: `${cert.code} — Free Diagnostic (${qs.length} Qs)`;
STATE.currentIndex = 0;
STATE.answers = {};
STATE.checked = {};
STATE.flagged = {};
STATE.elapsedSeconds = 0;
STATE.secondsLeft = examNum ? cert.duration_min * 60 : Math.round((cert.duration_min / 65) * qs.length * 60);
clearInterval(STATE.timerHandle);
STATE.timerHandle = setInterval(() => {
STATE.elapsedSeconds += 1;
if (STATE.mode === "exam") {
STATE.secondsLeft = Math.max(0, STATE.secondsLeft - 1);
$("runnerTimer").textContent = formatTime(STATE.secondsLeft);
if (STATE.secondsLeft === 0) {
finishExam();
}
} else {
$("runnerTimer").textContent = formatTime(STATE.elapsedSeconds);
}
}, 1000);
$("runnerBadge").textContent = mode === "exam" ? "TIMED EXAM MODE" : "STUDY MODE (INSTANT FEEDBACK)";
$("runnerBadge").className = `badge ${mode === "exam" ? "badge-warning" : "badge-brand"}`;
$("runnerTitle").textContent = STATE.examLabel;
$("runnerTimer").textContent = formatTime(mode === "exam" ? STATE.secondsLeft : 0);
renderQuestion();
showView("viewRunner");
}
function renderQuestion() {
const q = STATE.activeQuestions[STATE.currentIndex];
const total = STATE.activeQuestions.length;
const idx = STATE.currentIndex;
const selected = STATE.answers[idx] || [];
const isChecked = Boolean(STATE.checked[idx]);
$("qCounter").textContent = `Question ${idx + 1} of ${total}`;
$("qDomain").textContent = q.domain;
$("runnerProgress").style.width = `${Math.round(((idx + 1) / total) * 100)}%`;
$("qMultiNote").classList.toggle("hidden", !q.multi);
$("btnFlagQ").textContent = STATE.flagged[idx] ? "★ Flagged" : "☆ Flag for Review";
$("qStem").textContent = q.stem;
const letters = ["A", "B", "C", "D", "E", "F"];
$("qOptions").innerHTML = q.options
.map((optText, optIdx) => {
const isSel = selected.includes(optIdx);
let cls = "option-btn";
if (isChecked && STATE.mode === "study") {
if (q.correct.includes(optIdx)) cls += " correct";
else if (isSel) cls += " wrong";
} else if (isSel) {
cls += " selected";
}
return `
<button class="${cls}" type="button" data-opt="${optIdx}">
<span class="option-letter">${letters[optIdx]}</span>
<span>${escapeHtml(optText)}</span>
</button>`;
})
.join("");
$("qOptions").querySelectorAll("[data-opt]").forEach((btn) => {
btn.addEventListener("click", () => {
if (STATE.mode === "study" && STATE.checked[idx]) return;
const optIdx = Number(btn.dataset.opt);
const curr = new Set(STATE.answers[idx] || []);
if (q.multi) {
if (curr.has(optIdx)) curr.delete(optIdx);
else curr.add(optIdx);
} else {
curr.clear();
curr.add(optIdx);
}
STATE.answers[idx] = Array.from(curr).sort((a, b) => a - b);
renderQuestion();
});
});
$("btnCheckAnswer").classList.toggle("hidden", STATE.mode !== "study" || isChecked);
$("btnPrevQ").disabled = idx === 0;
$("btnNextQ").textContent = idx === total - 1 ? "Review & Finish →" : "Next →";
const expBox = $("qExplanation");
if (STATE.mode === "study" && isChecked) {
const isRight = arraysEqual(selected, q.correct);
const correctLetters = q.correct.map((i) => letters[i]).join(", ");
expBox.innerHTML = `
<h4 style="color:var(${isRight ? "--success" : "--danger"})">
${isRight ? "✓ Correct!" : `✕ Incorrect — Correct Answer: Option ${correctLetters}`}
</h4>
<div>${escapeHtml(q.explanation)}</div>
${q.use_case ? `<div class="usecase-callout"><strong>Production Use Case:</strong> ${escapeHtml(q.use_case)}</div>` : ""}
${q.hack ? `<div class="hack-callout"><strong>Exam Hack:</strong> ${escapeHtml(q.hack)}</div>` : ""}
`;
expBox.classList.remove("hidden");
} else {
expBox.classList.add("hidden");
}
renderQuestionMap();
}
function renderQuestionMap() {
const total = STATE.activeQuestions.length;
const answeredCount = Object.values(STATE.answers).filter((a) => a && a.length > 0).length;
$("qMapSummary").textContent = `${answeredCount} of ${total} answered`;
$("qMapGrid").innerHTML = STATE.activeQuestions
.map((_, i) => {
let cls = "qmap-item";
if (i === STATE.currentIndex) cls += " current";
if (STATE.flagged[i]) cls += " flagged";
else if (STATE.answers[i] && STATE.answers[i].length > 0) cls += " answered";
return `<button class="${cls}" type="button" data-jump="${i}">${i + 1}</button>`;
})
.join("");
$("qMapGrid").querySelectorAll("[data-jump]").forEach((btn) => {
btn.addEventListener("click", () => {
STATE.currentIndex = Number(btn.dataset.jump);
renderQuestion();
});
});
}
function finishExam() {
clearInterval(STATE.timerHandle);
const total = STATE.activeQuestions.length;
let correctCount = 0;
const domainStats = {};
const missed = [];
const letters = ["A", "B", "C", "D", "E", "F"];
STATE.activeQuestions.forEach((q, idx) => {
const sel = STATE.answers[idx] || [];
const ok = arraysEqual(sel, q.correct);
if (ok) correctCount += 1;
else missed.push({ idx, q, sel });
if (!domainStats[q.domain]) domainStats[q.domain] = { ok: 0, total: 0 };
domainStats[q.domain].total += 1;
if (ok) domainStats[q.domain].ok += 1;
});
const pct = Math.round((correctCount / total) * 100);
const passed = pct >= STATE.activeCert.pass_pct;
saveAttempt({
date: new Date().toISOString(),
label: STATE.examLabel,
pct,
passed,
correctCount,
total,
});
const domainRows = Object.entries(domainStats)
.map(([dom, st]) => {
const dpct = Math.round((st.ok / st.total) * 100);
return `
<tr>
<td>${escapeHtml(dom)}</td>
<td>${st.ok} / ${st.total}</td>
<td><span class="badge ${dpct >= STATE.activeCert.pass_pct ? "badge-success" : "badge-danger"}">${dpct}%</span></td>
</tr>`;
})
.join("");
const missedHtml = missed.length
? missed
.slice(0, 20)
.map(
({ idx, q, sel }) => `
<div class="explanation-box" style="margin-top:0.8rem;">
<div style="font-size:var(--fs-sm); color:var(--muted); margin-bottom:0.25rem;">
Q#${idx + 1} · ${escapeHtml(q.domain)}
</div>
<div style="font-weight:600; margin-bottom:0.45rem;">${escapeHtml(q.stem)}</div>
<div style="font-size:var(--fs-sm); margin-bottom:0.45rem;">
<span class="badge badge-danger">Your Answer: ${sel.length ? sel.map((i) => letters[i]).join(", ") : "Unanswered"}</span>
<span class="badge badge-success">Correct: ${q.correct.map((i) => letters[i]).join(", ")}</span>
</div>
<div style="font-size:var(--fs-sm);">${escapeHtml(q.explanation)}</div>
${q.hack ? `<div class="hack-callout"><strong>Exam Hack:</strong> ${escapeHtml(q.hack)}</div>` : ""}
</div>`
)
.join("")
: `<div class="badge badge-success" style="margin-top:1rem;">Perfect Score! Zero missed questions.</div>`;
const domainEntries = Object.entries(domainStats).map(([dom, st]) => ({
dom,
ok: st.ok,
total: st.total,
dpct: Math.round((st.ok / st.total) * 100),
}));
const weakest = domainEntries.slice().sort((a, b) => a.dpct - b.dpct)[0];
const remainingCertQs = Math.max(0, STATE.activeCert.total_questions - total);
const kdp = getKdpCompanion(STATE.activeCert.slug);
const udemyUrl = getUdemyCompanion(STATE.activeCert.slug);
const examFee = CERT_EXAM_FEES[STATE.activeCert.slug] || 150;
const retakeSavingsPct = Math.round((1 - 19.99 / examFee) * 100);
const upsellBanner = !STATE.isPro
? `<div class="cro-paywall">
<span class="badge badge-brand">PRO ALL-ACCESS VAULT · $549 VALUE → $19.99 (96% OFF)</span>
<span class="badge badge-warning" style="margin-left:0.35rem;">RETAKE PROTECTION: $${examFee} EXAM FEE VS $19.99 (${retakeSavingsPct}% CHEAPER THAN 1 RETAKE)</span>
<h3>${passed ? `Lock In Your ${escapeHtml(STATE.activeCert.code)} First-Try Pass` : `Close Your ${escapeHtml(STATE.activeCert.code)} Score Gap Before Risking a $${examFee} Retake`}</h3>
<p style="margin:0; color:var(--muted); font-size:var(--fs-sm);">
You just completed the 15-question Free Diagnostic (<strong>${pct}%</strong>). Instead of $49.99 per course or paying <strong>$${examFee} USD</strong> for an exam retake, unlock the remaining
<strong>${remainingCertQs} ${escapeHtml(STATE.activeCert.code)} scenarios</strong> plus all 10 other AWS, Azure & Google Cloud exams (<strong>2,860 scenarios · 44 timed mocks + Master Cheat Sheets PDF</strong>) for one single $19.99 payment.
</p>
${weakest ? `<div class="cro-gap-alert">
<strong>Biggest Exam Risk Detected:</strong> ${escapeHtml(weakest.dom)} (<strong>${weakest.dpct}%</strong> · ${weakest.ok}/${weakest.total} correct).
Full Pro Mocks 1–4 drill every subdomain with production use cases and Exam Hacks — <a href="${CONFIG.CHECKOUT_URL}" style="font-weight:700;">unlock all ${remainingCertQs} ${escapeHtml(STATE.activeCert.code)} scenarios for $19.99</a> or <a href="${kdp.url}" target="_blank" rel="noopener">study the companion Kindle book (KU $0)</a>.
</div>` : ""}
<div class="cro-teaser-grid">
<div class="cro-teaser-locked">
<strong>🔒 4 Full 65-Question Mocks</strong>
<span>Timed ${STATE.activeCert.duration_min}-min exam mode + instant study explanations for ${escapeHtml(STATE.activeCert.code)}.</span>
</div>
<div class="cro-teaser-locked">
<strong>🔒 All 11 Cloud & AI Blueprints</strong>
<span>Azure AI-103 & AI-901, GCP GenAI Leader, AWS AIP-C01 Pro, DVA-C03 (New Dec 2026), AIF-C01, MLA-C01, DEA-C01, DVA-C02, SAA-C03 & CLF-C02.</span>
</div>
<div class="cro-teaser-locked">
<strong>🔒 Offline Bundle + Cheat Sheets PDF</strong>
<span>Downloadable standalone HTML simulator + Master Exam Hacks PDF + instant AES-256 Pro Key.</span>
</div>
</div>
<div style="overflow-x:auto; margin:0.9rem 0 0.75rem;">
<table class="domain-table" style="margin-top:0; background:var(--surface); border-radius:var(--radius-sm); overflow:hidden;">
<thead>
<tr>
<th>Compare Options</th>
<th>Free Diagnostic ($0)</th>
<th>Single Udemy Course ($49.99)</th>
<th style="color:var(--brand);">Pro All-Access Vault ($19.99 Once)</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Question Bank</strong></td>
<td>15 Qs / cert (165 total)</td>
<td>260 Qs (1 cert only)</td>
<td><strong>2,860 Qs (All 11 Certs · 44 Mocks)</strong></td>
</tr>
<tr>
<td><strong>Offline & Cheat Sheets</strong></td>
<td>Online preview only</td>
<td>Online Udemy player only</td>
<td><strong>Offline HTML ZIP + Master Hacks PDF</strong></td>
</tr>
<tr>
<td><strong>Price & Access</strong></td>
<td>$0 (No login)</td>
<td>$49.99 per cert ($549+ for 11)</td>
<td><strong>$19.99 One-Time (96% Off)</strong></td>
</tr>
</tbody>
</table>
</div>
<div style="display:flex; gap:0.65rem; flex-wrap:wrap; align-items:center; margin-top:0.85rem;">
<a class="btn btn-primary" href="${CONFIG.CHECKOUT_URL}">
Protect $${examFee} Exam Fee — Unlock 2,860 Qs ($19.99) →
</a>
<button class="btn" type="button" id="btnResultUnlock">Already Have a Key? Activate</button>
<a class="btn btn-ghost" href="exams/cloud-ai-exam-costs-passing-scores-2026/">Compare Exam Costs & Pass Bars</a>
${udemyUrl ? `<a class="btn btn-ghost" href="${escapeHtml(udemyUrl)}" target="_blank" rel="noopener">Or Buy ${escapeHtml(STATE.activeCert.code)} on Udemy ($12.99 Deal) →</a>` : ""}
</div>
<div class="cro-trust-row">
<span>✓ Zero Monthly Subscription</span>
<span>✓ Instant Key Delivery via Gumroad</span>
<span>✓ Lifetime 2026–2027 Updates</span>
</div>
</div>`
: "";
const kdpBanner = `<div class="kdp-cross-sell">
<div>
<span class="badge badge-info">${escapeHtml(kdp.badge)}</span>
<div style="font-weight:700; margin-top:0.3rem;">Companion Study Book: ${escapeHtml(kdp.title)}</div>
<div style="font-size:var(--fs-sm); color:var(--muted);">Prefer offline reading on Kindle, tablet, or paperback alongside the simulator?</div>
</div>
<a class="btn" href="${kdp.url}" target="_blank" rel="noopener">View on Amazon →</a>
</div>`;
$("resultsCard").innerHTML = `
<div style="display:flex; justify-content:space-between; align-items:center; gap:1rem; flex-wrap:wrap;">
<div>
<span class="badge ${passed ? "badge-success" : "badge-danger"}">${passed ? "PASSING SCORE" : "BELOW PASSING BAR"}</span>
<h2 style="margin:0.4rem 0 0.2rem;">${escapeHtml(STATE.examLabel)}</h2>
<div style="color:var(--muted); font-size:var(--fs-sm);">
Score: <strong>${pct}%</strong> (${correctCount}/${total} correct) · Required: ${STATE.activeCert.pass_pct}% · Time: ${formatTime(STATE.elapsedSeconds)}
</div>
</div>
<div style="display:flex; gap:0.5rem; flex-wrap:wrap;">
<button class="btn btn-success" type="button" id="btnDownloadScorecard">Download Readiness Scorecard (PNG)</button>
${missed.length ? `<button class="btn btn-primary" type="button" id="btnRetestMissed">Re-test Missed (${missed.length} Qs) →</button>` : ""}
<button class="btn" type="button" id="btnResultFlashcards">Flip Flashcards</button>
<button class="btn" type="button" id="btnResultCatalog">← All Certifications</button>
<button class="btn" type="button" id="btnResultRetry">Back to ${escapeHtml(STATE.activeCert.code)}</button>
</div>
</div>
${upsellBanner}
${kdpBanner}
<h3 style="margin:1.3rem 0 0.3rem; font-size:1rem;">Domain-Level Diagnostic</h3>
<table class="domain-table">
<thead><tr><th>Exam Domain</th><th>Correct</th><th>Score</th></tr></thead>
<tbody>${domainRows}</tbody>
</table>
<h3 style="margin:1.35rem 0 0.3rem; font-size:1rem;">Missed Questions Review (${missed.length})</h3>
${missedHtml}
`;
recordStudyActivity();
if ($("btnDownloadScorecard")) {
$("btnDownloadScorecard").onclick = () =>
downloadScorecardPng({
cert: STATE.activeCert,
examLabel: STATE.examLabel,
pct,
passed,
correctCount,
total,
elapsedSeconds: STATE.elapsedSeconds,
domainEntries,
});
}
if ($("btnRetestMissed")) {
$("btnRetestMissed").onclick = () => {
const missedQs = missed.map((m) => m.q);
startCustomSession(STATE.activeCert, missedQs, `${STATE.activeCert.code} — Missed Questions Drill (${missedQs.length} Qs)`, "study");
};
}
if ($("btnResultFlashcards")) {
$("btnResultFlashcards").onclick = () => startFlashcards(STATE.activeCert.slug);
}
$("btnResultCatalog").onclick = () => {
renderCatalog();
showView("viewCatalog");
};
$("btnResultRetry").onclick = () => openCertDetail(STATE.activeCert.slug);
if ($("btnResultUnlock")) $("btnResultUnlock").onclick = openProModal;
showView("viewResults");
}
function drawRoundedRect(ctx, x, y, w, h, r) {
const rad = Math.min(r, w / 2, h / 2);
ctx.beginPath();
ctx.moveTo(x + rad, y);
ctx.arcTo(x + w, y, x + w, y + h, rad);
ctx.arcTo(x + w, y + h, x, y + h, rad);
ctx.arcTo(x, y + h, x, y, rad);
ctx.arcTo(x, y, x + w, y, rad);
ctx.closePath();
}
function downloadScorecardPng({ cert, examLabel, pct, passed, correctCount, total, elapsedSeconds, domainEntries }) {
const W = 1000;
const H = 520;
const canvas = document.createElement("canvas");
canvas.width = W;
canvas.height = H;
const ctx = canvas.getContext("2d");
if (!ctx) return;
// Background gradient
const grad = ctx.createLinearGradient(0, 0, 0, H);
grad.addColorStop(0, "#0b1220");
grad.addColorStop(1, "#132038");
ctx.fillStyle = grad;
ctx.fillRect(0, 0, W, H);
// Brand accent bars
const accent = cert.badge_color || "#1c69d4";
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 12, H);
ctx.fillRect(0, 0, W, 6);
// Top header: CC logo + CloudCert Lab + Date
drawRoundedRect(ctx, 44, 34, 46, 46, 10);
ctx.fillStyle = accent;
ctx.fill();
ctx.fillStyle = "#ffffff";
ctx.font = "bold 20px Inter, Arial, sans-serif";
ctx.fillText("CC", 53, 64);
ctx.fillStyle = "#f8fafc";
ctx.font = "bold 22px Inter, Arial, sans-serif";
ctx.fillText("CloudCert Lab", 104, 56);
ctx.fillStyle = "#94a3b8";
ctx.font = "14px Inter, Arial, sans-serif";
ctx.fillText("MULTI-CLOUD & AI READINESS SCORECARD", 104, 76);
const dateStr = new Date().toISOString().slice(0, 10);
ctx.fillStyle = "#94a3b8";
ctx.font = "14px Inter, Arial, sans-serif";
ctx.textAlign = "right";
ctx.fillText(`Completed ${dateStr} · Time ${formatTime(elapsedSeconds)}`, W - 44, 62);
ctx.textAlign = "left";
// Left panel: Cert Code, Score %, Status Pill
drawRoundedRect(ctx, 44, 104, 330, 342, 16);
ctx.fillStyle = "#162238";
ctx.fill();
ctx.strokeStyle = "#293b5c";
ctx.lineWidth = 1.5;
ctx.stroke();
ctx.fillStyle = "#93c5fd";
ctx.font = "bold 14px Inter, Arial, sans-serif";
ctx.fillText(`${(cert.vendor || "").toUpperCase()} · ${(cert.code || "").toUpperCase()}`, 68, 138);
ctx.fillStyle = "#f8fafc";
ctx.font = "bold 76px Inter, Arial, sans-serif";
ctx.fillText(`${pct}%`, 68, 232);
// Status pill
const statusText = passed ? "PASSING SCORE" : "NEEDS PREP";
const pillBg = passed ? "#14532d" : "#7f1d1d";
const pillFg = passed ? "#86efac" : "#fca5a5";
drawRoundedRect(ctx, 68, 254, 190, 36, 18);
ctx.fillStyle = pillBg;
ctx.fill();
ctx.fillStyle = pillFg;
ctx.font = "bold 15px Inter, Arial, sans-serif";
ctx.fillText(statusText, 92, 277);
ctx.fillStyle = "#cbd5e1";
ctx.font = "15px Inter, Arial, sans-serif";
ctx.fillText(`Correct: ${correctCount} / ${total} questions`, 68, 326);
ctx.fillText(`Official Pass Bar: ${cert.pass_pct}%`, 68, 352);
ctx.fillStyle = "#94a3b8";
ctx.font = "13px Inter, Arial, sans-serif";
const shortLabel = (examLabel || cert.code).slice(0, 38);
ctx.fillText(shortLabel, 68, 386);
ctx.fillStyle = "#60a5fa";
ctx.font = "bold 13px Inter, Arial, sans-serif";
ctx.fillText("2026–2027 Official Exam Blueprint", 68, 418);
// Right panel: Domain Breakdown bars
drawRoundedRect(ctx, 396, 104, 560, 342, 16);
ctx.fillStyle = "#162238";
ctx.fill();
ctx.strokeStyle = "#293b5c";
ctx.lineWidth = 1.5;
ctx.stroke();
ctx.fillStyle = "#f8fafc";
ctx.font = "bold 17px Inter, Arial, sans-serif";
ctx.fillText("Domain-Level Diagnostic Breakdown", 422, 138);
const domains = (domainEntries || []).slice(0, 5);
const startY = 166;
const rowStep = domains.length > 4 ? 54 : 64;
domains.forEach((d, idx) => {
const y = startY + idx * rowStep;
const label = d.dom.length > 52 ? `${d.dom.slice(0, 49)}...` : d.dom;
ctx.fillStyle = "#e2e8f0";
ctx.font = "600 13px Inter, Arial, sans-serif";
ctx.fillText(label, 422, y);
ctx.textAlign = "right";
ctx.fillStyle = d.dpct >= cert.pass_pct ? "#86efac" : "#fca5a5";
ctx.font = "bold 13px Inter, Arial, sans-serif";
ctx.fillText(`${d.dpct}% (${d.ok}/${d.total})`, 930, y);
ctx.textAlign = "left";
// Bar track
drawRoundedRect(ctx, 422, y + 10, 508, 14, 7);
ctx.fillStyle = "#0f172a";
ctx.fill();
// Bar fill
const fillW = Math.max(12, Math.round((508 * Math.min(100, d.dpct)) / 100));
drawRoundedRect(ctx, 422, y + 10, fillW, 14, 7);
ctx.fillStyle = d.dpct >= cert.pass_pct ? "#22c55e" : d.dpct >= 50 ? "#f59e0b" : "#ef4444";
ctx.fill();
});
// Bottom footer watermark
ctx.strokeStyle = "#1e293b";
ctx.lineWidth = 1.5;
ctx.beginPath();
ctx.moveTo(44, 468);
ctx.lineTo(W - 44, 468);
ctx.stroke();
ctx.fillStyle = "#60a5fa";
ctx.font = "bold 16px Inter, Arial, sans-serif";
ctx.fillText("gabhack.github.io/cloudcert-lab/", 44, 498);
ctx.textAlign = "right";
ctx.fillStyle = "#94a3b8";
ctx.font = "14px Inter, Arial, sans-serif";
ctx.fillText("165 Free Scenarios · 2,860 Pro Vault Questions · AWS · Azure · GCP", W - 44, 498);
ctx.textAlign = "left";
const link = document.createElement("a");
link.download = `cloudcert-scorecard-${cert.slug}.png`;
link.href = canvas.toDataURL("image/png");
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
function startCustomSession(cert, qs, label, mode) {
if (!cert || !qs || !qs.length) return;
STATE.activeCert = cert;
STATE.activeQuestions = qs;
STATE.mode = mode || "study";
STATE.examLabel = label;
STATE.currentIndex = 0;
STATE.answers = {};
STATE.checked = {};
STATE.flagged = {};
STATE.elapsedSeconds = 0;
STATE.secondsLeft = Math.round((cert.duration_min / 65) * qs.length * 60);
clearInterval(STATE.timerHandle);
STATE.timerHandle = setInterval(() => {
STATE.elapsedSeconds += 1;
$("runnerTimer").textContent = formatTime(STATE.elapsedSeconds);
}, 1000);
$("runnerBadge").textContent = "TARGETED REMEDIATION DRILL";
$("runnerBadge").className = "badge badge-brand";
$("runnerTitle").textContent = STATE.examLabel;
$("runnerTimer").textContent = "00:00";
renderQuestion();
showView("viewRunner");
}
async function startFlashcards(slug) {
const cert = STATE.catalog.certs.find((c) => c.slug === slug);
if (!cert) return;
STATE.activeCert = cert;
const payload = await fetchCertPayload(slug, STATE.isPro ? "pro" : "free");
const deck = (payload.questions || []).slice(0, STATE.isPro ? 40 : 15);
STATE.flashDeck = deck.slice();
STATE.flashTotal = deck.length;