-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresources.js
More file actions
1808 lines (1644 loc) · 94.1 KB
/
Copy pathresources.js
File metadata and controls
1808 lines (1644 loc) · 94.1 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
// Resources page functionality
document.addEventListener('DOMContentLoaded', () => {
renderResources();
setupFilters();
setupDBQTool();
setupSAQPractice();
setupTimeline();
setupLEQOutline();
setupDBQPractice();
setupLEQPractice();
setupStudyGuide();
setupQuestionBankActions();
});
const PERIOD_NUMBERS = Object.keys((window.APUSH_DATA && window.APUSH_DATA.periods) || {})
.map(Number)
.filter(Number.isFinite)
.sort((a, b) => a - b);
function promptBank() {
return window.APUSHPromptBank || null;
}
function rawPromptBank() {
const helper = promptBank();
if (helper && typeof helper.bank === 'function') return helper.bank();
return window.APUSH_PROMPT_BANK || null;
}
function isRealDbqSourceSet(sources) {
if (!Array.isArray(sources) || sources.length === 0) return false;
return sources.some(source => {
const title = String(source && source.title || '');
const excerpt = String(source && source.excerpt || '');
return !/^Document\s+\d+/i.test(title) && !/Evidence excerpt/i.test(excerpt);
});
}
function resolveDbqForPeriod(period, seed) {
const pb = promptBank();
if (pb) {
const item = pb.getDbq(period, seed);
if (item && isRealDbqSourceSet(item.sources)) {
return {
prompt: item.prompt,
sources: (item.sources || []).slice(0, 6),
fullTexts: pb.buildLegacySourceTexts(item.sources || []),
meta: item
};
}
if (item && item.prompt) {
const p = String(period === 'all' ? item.period : period);
const sources = (DBQ_SOURCE_SETS[p] || DBQ_SOURCE_SETS[item.period] || DBQ_SOURCE_SETS[3] || DBQ_SOURCE_SETS[2] || []).slice(0, 6);
return {
prompt: item.prompt,
sources,
fullTexts: DBQ_SOURCE_FULL_TEXTS,
meta: item
};
}
}
const p = String(period);
const prompt = p !== 'all' && DBQ_PROMPTS[p] ? DBQ_PROMPTS[p] : DBQ_PROMPTS.all;
const sources = (DBQ_SOURCE_SETS[p] || DBQ_SOURCE_SETS[3] || DBQ_SOURCE_SETS[2] || DBQ_SOURCE_SETS[1] || []).slice(0, 6);
return { prompt, sources, fullTexts: DBQ_SOURCE_FULL_TEXTS, meta: null };
}
function buildDbqPack(resource) {
const period = resource?.period ?? 'all';
const resolved = resolveDbqForPeriod(period, resource?.id || period);
if (!resource?.customPrompt) return resolved;
const sources = Array.isArray(resource.customSources) && resource.customSources.length
? resource.customSources
: resolved.sources;
return {
prompt: resource.customPrompt,
sources,
fullTexts: resolved.fullTexts,
meta: resource.meta || resolved.meta || null
};
}
function normalizeSaqBankItem(item) {
if (!item) return null;
const period = item.period;
const pd = window.APUSH_DATA && window.APUSH_DATA.periods ? window.APUSH_DATA.periods[period] : null;
const firstEvent = pd && Array.isArray(pd.timeline) ? pd.timeline[0] : null;
const defaultSample = firstEvent
? `Sample: ${firstEvent.title} (${firstEvent.date}) — ${firstEvent.description}. Connect this evidence directly to the question and explain significance.`
: `Cite a specific person, law, or event from Period ${period} and explain its significance in 2–4 sentences.`;
return {
question: item.question || item.prompt || 'Short Answer Question',
prompt: item.question ? (item.prompt || 'Answer in 2–4 sentences with specific evidence.') : 'Answer in 2–4 sentences with specific evidence.',
sampleAnswer: item.sampleAnswer || item.answerHint || defaultSample
};
}
function resolveLeqPromptForPeriod(period, seed) {
const pb = promptBank();
if (pb) {
const text = pb.leqPrompt(period, seed);
if (text) return text;
}
const p = String(period);
return p !== 'all' && LEQ_PROMPTS[p] ? LEQ_PROMPTS[p] : LEQ_PROMPTS.all;
}
function buildPeriodResourceSuite(period) {
const pd = window.APUSH_DATA && window.APUSH_DATA.periods ? window.APUSH_DATA.periods[period] : null;
const periodName = pd && pd.name ? pd.name : `Period ${period}`;
const dates = pd && pd.dates ? pd.dates : '';
const timelineFocus = pd && pd.timeline && pd.timeline[0] ? pd.timeline[0].title : periodName;
return [
{
title: `SAQ Practice Set: Period ${period}`,
type: "practice",
period,
skill: "saq",
format: "practice",
description: `10 focused SAQ reps for ${periodName}${dates ? ` (${dates})` : ''} with quick rubric feedback`
},
{
title: `Period ${period} Timeline: ${timelineFocus}`,
type: "timeline",
period,
skill: "all",
format: "timeline",
description: `Interactive event sequence for ${periodName}${dates ? ` (${dates})` : ''}`
},
{
title: `Study Guide: Period ${period}`,
type: "guide",
period,
skill: "all",
format: "guide",
description: `Rapid-recall guide for key concepts, themes, and exam moves in ${periodName}`
},
{
title: `LEQ Practice: Period ${period}`,
type: "practice",
period,
skill: "leq",
format: "practice",
description: `Targeted LEQ prompt and planning flow for ${periodName}`
},
{
title: `DBQ Practice: Period ${period}`,
type: "practice",
period,
skill: "dbq",
format: "practice",
description: `Period-specific DBQ prompt + document-analysis workflow for ${periodName}`
}
];
}
const BASE_RESOURCES = [
{
title: "DBQ Annotation Tool",
type: "tool",
period: "all",
skill: "dbq",
format: "tool",
description: "Interactive tool for annotating and scoring DBQ responses"
},
{
title: "LEQ Outline Generator",
type: "tool",
period: "all",
skill: "leq",
format: "tool",
description: "Generate structured outlines for Long Essay Questions"
},
{
title: "SAQ Drills: All Periods",
type: "practice",
period: "all",
skill: "saq",
format: "practice",
description: "Timed SAQ practice covering all APUSH periods"
}
];
const PERIOD_RESOURCES = PERIOD_NUMBERS.flatMap(period => buildPeriodResourceSuite(period));
const RESOURCES = [...BASE_RESOURCES, ...PERIOD_RESOURCES].map((resource, index) => ({
id: index + 1,
...resource
}));
function isFeaturedResource(resource) {
if (!resource || !resource.title) return false;
return (
resource.title.startsWith('SAQ Practice Set: Period ') ||
resource.title.startsWith('Study Guide: Period ') ||
resource.title.startsWith('Period ') && resource.title.includes('Timeline:') ||
resource.title === 'SAQ Drills: All Periods'
);
}
let currentFilters = {
period: 'all',
skill: 'all',
format: 'all'
};
function isAuthenticatedUser() {
return !!(window.AuthManager && typeof window.AuthManager.isAuthenticated === 'function' && window.AuthManager.isAuthenticated());
}
function trackResourceMetric(updateFn) {
if (!isAuthenticatedUser() || typeof APUSH === 'undefined' || !APUSH.getUserProgress || !APUSH.saveUserProgress) return;
const progress = APUSH.getUserProgress();
if (!progress.metrics) progress.metrics = {};
updateFn(progress.metrics);
APUSH.saveUserProgress(progress);
}
/** Select value is always a string; resource.period may be a number — normalize for comparison */
function periodFilterMatches(filterVal, resourcePeriod) {
if (filterVal === 'all') return true;
if (resourcePeriod === 'all') return true;
return String(resourcePeriod) === String(filterVal);
}
const PORTFOLIO_SECTIONS = [
{
id: 'saq',
title: 'SAQ',
subtitle: 'Short Answer Question drills with rubric-style feedback and period-specific sets.',
accent: 'saq'
},
{
id: 'dbq',
title: 'DBQ',
subtitle: 'Document-Based Question tools, annotation workflow, and period practice prompts.',
accent: 'dbq'
},
{
id: 'study-guides',
title: 'Study Guides',
subtitle: 'Rapid-recall guides and interactive timelines organized by APUSH period.',
accent: 'guide'
}
];
function getPortfolioCategory(resource) {
if (!resource) return 'study-guides';
if (resource.format === 'guide') return 'study-guides';
if (resource.format === 'timeline' || resource.type === 'timeline') return 'study-guides';
if (resource.skill === 'saq') return 'saq';
if (resource.skill === 'dbq' || resource.skill === 'leq') return 'dbq';
return 'study-guides';
}
function resourceMatchesFilters(resource) {
if (!periodFilterMatches(currentFilters.period, resource.period)) {
return false;
}
if (currentFilters.skill !== 'all' && resource.skill !== currentFilters.skill && resource.skill !== 'all') {
return false;
}
if (currentFilters.format !== 'all' && resource.format !== currentFilters.format) {
return false;
}
return true;
}
function getFilteredResources() {
return RESOURCES.filter(resourceMatchesFilters);
}
function filtersAreActive() {
return currentFilters.period !== 'all' || currentFilters.skill !== 'all' || currentFilters.format !== 'all';
}
function syncResourcesLayout() {
const bank = document.getElementById('question-bank');
if (bank) {
bank.hidden = filtersAreActive();
}
}
function renderResources() {
const portfolio = document.getElementById('resources-portfolio');
if (!portfolio) return;
portfolio.innerHTML = '';
const filtered = getFilteredResources();
if (filtered.length === 0) {
portfolio.innerHTML = '<p class="resources-portfolio-empty">No resources match your filters. Try changing period, skill, or format.</p>';
return;
}
PORTFOLIO_SECTIONS.forEach(section => {
const sectionItems = filtered.filter(resource => getPortfolioCategory(resource) === section.id);
if (sectionItems.length === 0) return;
const block = document.createElement('section');
block.className = `portfolio-section portfolio-section--${section.accent}`;
block.setAttribute('data-portfolio', section.id);
block.setAttribute('aria-labelledby', `portfolio-heading-${section.id}`);
const featuredCount = sectionItems.filter(isFeaturedResource).length;
const countLabel = `${sectionItems.length} resource${sectionItems.length === 1 ? '' : 's'}`;
const featuredNote = featuredCount > 0 ? ` · ${featuredCount} featured` : '';
block.innerHTML = `
<header class="portfolio-section-header">
<div class="portfolio-section-heading">
<span class="portfolio-section-label">${section.title}</span>
<h2 id="portfolio-heading-${section.id}" class="portfolio-section-title">${section.title} Portfolio</h2>
<p class="portfolio-section-subtitle">${section.subtitle}</p>
</div>
<p class="portfolio-section-count" aria-label="${countLabel}">${countLabel}${featuredNote}</p>
</header>
<div class="portfolio-section-grid" role="list"></div>
`;
const grid = block.querySelector('.portfolio-section-grid');
sectionItems.forEach(resource => {
grid.appendChild(createResourceCard(resource));
});
portfolio.appendChild(block);
});
if (typeof window.applyLiquidGlassTargets === 'function') {
window.applyLiquidGlassTargets();
}
syncResourcesLayout();
}
function createResourceCard(resource) {
const card = document.createElement('div');
const isFeatured = isFeaturedResource(resource);
card.className = `resource-card${isFeatured ? ' resource-card-featured' : ''}`;
card.setAttribute('role', 'listitem');
card.setAttribute('tabindex', '0');
const typeLabels = {
tool: 'Tool',
practice: 'Practice',
guide: 'Guide',
timeline: 'Timeline'
};
const skillLabels = {
saq: 'SAQ',
dbq: 'DBQ',
leq: 'LEQ',
all: 'All Skills'
};
const cta = resource.format === 'timeline'
? 'Explore Timeline'
: resource.skill === 'saq'
? 'Start SAQ Drill'
: resource.type === 'guide'
? 'Open Study Guide'
: 'Open Resource';
card.innerHTML = `
<div class="resource-tags">
<span class="resource-type resource-type--${resource.type}">${typeLabels[resource.type] || resource.type}</span>
${isFeatured ? '<span class="resource-featured-badge">Featured</span>' : ''}
</div>
<h3 class="resource-title">${resource.title}</h3>
<p class="resource-description">${resource.description}</p>
<div class="resource-meta">
${resource.period !== 'all' ? `<span>Period ${resource.period}</span>` : '<span>All Periods</span>'}
<span>${skillLabels[resource.skill] || resource.skill}</span>
</div>
<div class="resource-cta-row">
<span class="resource-cta">${cta} →</span>
</div>
`;
card.addEventListener('click', () => {
handleResourceClick(resource);
});
card.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
handleResourceClick(resource);
}
});
return card;
}
function handleResourceClick(resource) {
if (!resource) {
console.error('No resource provided to handleResourceClick');
return;
}
if (resource.format === 'timeline' || resource.type === 'timeline') {
openTimeline(resource);
return;
}
if (resource.type === 'tool' && resource.skill === 'dbq') {
loadDBQPromptForTool(resource);
APUSH.openModal('dbq-modal');
return;
}
if (resource.type === 'tool' && resource.skill === 'leq') {
openLEQOutlineGenerator(resource);
return;
}
if (resource.type === 'guide') {
openStudyGuide(resource);
return;
}
if (resource.format === 'practice' && resource.skill === 'saq') {
openSAQPractice(resource);
return;
}
if (resource.format === 'practice' && resource.skill === 'dbq') {
openDBQPractice(resource);
return;
}
if (resource.format === 'practice' && resource.skill === 'leq') {
openLEQPractice(resource);
return;
}
}
function setupFilters() {
const periodFilter = document.getElementById('period-filter-resources');
const skillFilter = document.getElementById('skill-filter');
const formatFilter = document.getElementById('format-filter');
if (periodFilter && typeof window.populatePeriodFilterOptions === 'function') {
window.populatePeriodFilterOptions(periodFilter);
}
if (periodFilter) {
periodFilter.addEventListener('change', (e) => {
currentFilters.period = e.target.value;
renderResources();
});
}
if (skillFilter) {
skillFilter.addEventListener('change', (e) => {
currentFilters.skill = e.target.value;
renderResources();
});
}
if (formatFilter) {
formatFilter.addEventListener('change', (e) => {
currentFilters.format = e.target.value;
renderResources();
});
}
}
let currentAnnotationType = null;
let currentDBQToolResource = { period: 'all' };
function setupDBQTool() {
const dbqModal = document.getElementById('dbq-modal');
if (!dbqModal) return;
const dbqDocument = document.getElementById('dbq-document');
const annotationsList = document.getElementById('annotations-list');
const clearBtn = document.getElementById('clear-annotations-btn');
const draftInput = document.getElementById('dbq-essay-draft');
const estimateBtn = document.getElementById('dbq-estimate-btn');
const estimateResult = document.getElementById('dbq-estimate-result');
const advancedToggle = document.getElementById('dbq-advanced-estimate');
if (dbqDocument) {
dbqDocument.addEventListener('click', (event) => {
const trigger = event.target.closest('.dbq-open-doc-btn');
if (!trigger) return;
event.preventDefault();
openDbqDocumentModal({
title: trigger.getAttribute('data-doc-title') || 'DBQ Document',
source: trigger.getAttribute('data-doc-source') || 'Primary source',
excerpt: trigger.getAttribute('data-doc-excerpt') || '',
fullText: trigger.getAttribute('data-doc-full') || ''
});
});
}
const annotationBtns = document.querySelectorAll('.annotation-btn');
annotationBtns.forEach(btn => {
btn.addEventListener('click', () => {
if (btn.id === 'clear-annotations-btn') return;
const type = btn.dataset.type;
currentAnnotationType = type;
annotationBtns.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
if (dbqDocument) {
dbqDocument.setAttribute('data-annotation-mode', type);
dbqDocument.focus();
}
});
});
if (clearBtn) {
clearBtn.addEventListener('click', () => {
currentAnnotationType = null;
annotationBtns.forEach(b => b.classList.remove('active'));
if (annotationsList) annotationsList.innerHTML = '';
loadDBQPromptForTool(currentDBQToolResource || { period: 'all' });
});
}
const applyInlineAnnotation = (className) => {
const sel = window.getSelection();
if (!sel || sel.rangeCount === 0) return '';
const range = sel.getRangeAt(0);
const selectedText = sel.toString().trim();
if (!selectedText || !dbqDocument.contains(range.commonAncestorContainer)) return '';
const span = document.createElement('span');
span.className = className;
try {
range.surroundContents(span);
} catch (e) {
const fragment = range.extractContents();
span.appendChild(fragment);
range.insertNode(span);
}
sel.removeAllRanges();
return selectedText;
};
if (dbqDocument) {
dbqDocument.addEventListener('mouseup', () => {
if (!currentAnnotationType) return;
let text = '';
if (currentAnnotationType === 'highlight') {
text = applyInlineAnnotation('annotation-highlight');
} else if (currentAnnotationType === 'underline') {
text = applyInlineAnnotation('annotation-underline');
} else if (currentAnnotationType === 'note') {
const sel = window.getSelection();
text = sel && sel.toString ? sel.toString().trim() : '';
if (!text) return;
} else {
text = applyInlineAnnotation(`annotation-${currentAnnotationType}-mark`);
}
if (!text || !annotationsList) return;
const label = currentAnnotationType.charAt(0).toUpperCase() + currentAnnotationType.slice(1);
let noteBody = '';
if (currentAnnotationType === 'note') {
const note = prompt('Add a note for this passage:');
if (note === null) return;
noteBody = `<div class="annotation-note-body">${escapeHtml(note)}</div>`;
}
const tag = document.createElement('div');
tag.className = `annotation-tag annotation-${currentAnnotationType}`;
tag.innerHTML = `<strong>${label}:</strong> "${escapeHtml(text)}"${noteBody}`;
annotationsList.appendChild(tag);
trackResourceMetric(metrics => {
metrics.dbq = metrics.dbq || {};
metrics.dbq.annotations = (metrics.dbq.annotations || 0) + 1;
metrics.dbq.lastAnnotationType = currentAnnotationType;
metrics.dbq.lastUsedAt = new Date().toISOString();
});
});
}
if (estimateBtn && estimateResult && draftInput) {
estimateBtn.addEventListener('click', () => {
const draft = draftInput.value.trim();
if (!draft) {
alert('Write your DBQ response first, then estimate your score.');
return;
}
const period = currentDBQToolResource && currentDBQToolResource.period;
const prompt = period !== 'all' && DBQ_PROMPTS[period] ? DBQ_PROMPTS[period] : DBQ_PROMPTS.all;
const annotationCount = annotationsList ? annotationsList.children.length : 0;
const result = estimateDbqFromDraft(prompt, draft, annotationCount, !!(advancedToggle && advancedToggle.checked));
estimateResult.style.display = 'block';
const percent = Math.round((result.total / 7) * 100);
estimateResult.innerHTML = `
<div class="essay-estimate-header">
<h4 class="essay-estimate-title">Estimated score: ${result.total} / 7 (${result.band})</h4>
<span class="essay-estimate-confidence">Confidence: ~${result.confidence}%</span>
</div>
<div class="essay-estimate-meter" aria-hidden="true"><span style="width:${percent}%"></span></div>
<div class="essay-estimate-grid">
<div class="essay-estimate-tile"><strong>Thesis</strong><span>${result.thesis} / 1</span></div>
<div class="essay-estimate-tile"><strong>Context</strong><span>${result.context} / 1</span></div>
<div class="essay-estimate-tile"><strong>Evidence</strong><span>${result.evidence} / 3</span></div>
<div class="essay-estimate-tile"><strong>Analysis</strong><span>${result.analysis} / 2</span></div>
</div>
<ul class="essay-rubric-hints">${result.tips.map(tip => `<li>${escapeHtml(tip)}</li>`).join('')}</ul>
`;
trackResourceMetric(metrics => {
metrics.dbq = metrics.dbq || {};
metrics.dbq.attempts = (metrics.dbq.attempts || 0) + 1;
metrics.dbq.totalEstimated = (metrics.dbq.totalEstimated || 0) + result.total;
metrics.dbq.maxPossible = 7;
metrics.dbq.avgEstimated = Number((metrics.dbq.totalEstimated / metrics.dbq.attempts).toFixed(2));
metrics.dbq.lastConfidence = result.confidence;
metrics.dbq.lastEstimatedAt = new Date().toISOString();
});
});
}
}
function estimateDbqFromDraft(promptText, draftText, annotationCount, advanced) {
const text = draftText.toLowerCase();
const firstSentences = text.split(/[.!?]/).slice(0, 2).join(' ');
const words = draftText.split(/\s+/).filter(Boolean).length;
const yearMatches = draftText.match(/\b(1[6-9]\d{2}|20\d{2})s?\b/g) || [];
const docRefs = (text.match(/\b(doc|document)\s*\d*/g) || []).length;
const reasoningSignals = (text.match(/\b(because|therefore|however|although|thus|as a result|led to|resulted in)\b/g) || []).length;
const contextSignals = (text.match(/\b(before|earlier|long[- ]term|broader context|continuity)\b/g) || []).length;
const promptTerms = String(promptText || '').toLowerCase().replace(/[^a-z0-9\s]/g, ' ').split(/\s+/).filter(t => t.length > 5).slice(0, 8);
const promptHits = promptTerms.filter(term => text.includes(term)).length;
let thesis = 0;
if (words >= 90 && (promptHits >= 2 || /\b(although|while|extent|overall)\b/.test(firstSentences))) thesis = 1;
let context = 0;
if (words >= 130 && (contextSignals >= 1 || yearMatches.length >= 2)) context = 1;
let evidence = 0;
const evidenceRaw = yearMatches.length + docRefs + Math.floor(annotationCount / 2);
if (evidenceRaw >= 2) evidence = 1;
if (evidenceRaw >= 4) evidence = 2;
if (evidenceRaw >= 6 || docRefs >= 3) evidence = 3;
let analysis = 0;
if (reasoningSignals >= 2) analysis = 1;
if (reasoningSignals >= 4) analysis = 2;
if (advanced) {
if (annotationCount >= 4 && evidence < 3) evidence += 1;
if (promptHits >= 4 && analysis < 2) analysis += 1;
}
const total = Math.min(7, thesis + context + evidence + analysis);
const confidence = Math.max(45, Math.min(95, Math.round(42 + (words / 10) + (reasoningSignals * 4))));
const band = total >= 6 ? 'Strong' : total >= 4 ? 'Developing' : total >= 2 ? 'Emerging' : 'Starting';
const tips = [];
if (!thesis) tips.push('Make your first 1-2 sentences a defensible claim that directly answers the prompt.');
if (!context) tips.push('Add broader context from events that happened before the period in question.');
if (evidence < 2) tips.push('Use more specific evidence: laws, events, dates, and explicit document references.');
if (analysis < 2) tips.push('After each evidence point, explain why it proves your argument.');
if (advanced && annotationCount < 3) tips.push('Use the annotation tools on at least 3 passages before drafting to improve evidence coverage.');
return { thesis, context, evidence, analysis, total, confidence, band, tips };
}
const DBQ_PROMPTS = {
all: "Evaluate the extent to which the United States developed a national identity in the period 1800-1855.",
1: "Evaluate the extent to which European colonization transformed Native American societies in North America in the period 1491-1607.",
2: "Evaluate the extent to which regional economic differences shaped British North American colonial society in the period 1607-1754.",
3: "Evaluate the extent to which the American Revolution changed American society in the period 1763-1800.",
4: "Evaluate the extent to which the Market Revolution changed the American economy in the period 1800-1848.",
5: "Evaluate the extent to which sectional conflict over slavery led to the Civil War in the period 1844-1861.",
6: "Evaluate the extent to which industrialization changed American society in the period 1865-1898.",
7: "Evaluate the extent to which the Progressive movement was successful in achieving its goals in the period 1890-1920.",
8: "Evaluate the extent to which the Civil Rights movement achieved its goals in the period 1945-1980.",
9: "Evaluate the extent to which globalization transformed United States foreign and domestic policy in the period 1980 to the present."
};
const DBQ_SOURCE_SETS = {
1: [
{ title: "Bartolomé de las Casas, 'A Short Account of the Destruction of the Indies' (1542)", source: "Primary account", excerpt: "Las Casas described violence and forced labor imposed on Indigenous peoples after European contact." },
{ title: "Columbian Exchange summary (1492 onward)", source: "Historical synthesis", excerpt: "New World crops and Old World diseases reshaped population, diet, and labor systems across continents." },
{ title: "Encomienda system description (1500s)", source: "Colonial institution", excerpt: "Spanish colonizers claimed authority over Indigenous labor in exchange for nominal protection and conversion." },
{ title: "Joint-stock company charter for Virginia (1606)", source: "Corporate charter", excerpt: "Investors funded colonization expecting profit through land, trade, and resource extraction." },
{ title: "Powhatan diplomacy account (early 1600s)", source: "Indigenous-colonial relations", excerpt: "Algonquian leaders negotiated, resisted, and adapted as English settlement expanded in the Chesapeake." },
{ title: "African labor in early Atlantic colonies (1600s)", source: "Labor history", excerpt: "Enslaved Africans and indentured servants became central to colonial production and social hierarchy." }
],
2: [
{ title: "John Winthrop, 'A Modell of Christian Charity' (1630)", source: "Sermon, Puritan migration", excerpt: "We shall be as a city upon a hill. The eyes of all people are upon us." },
{ title: "Virginia House of Burgesses law on tobacco labor (1670s)", source: "Colonial legal record", excerpt: "The increase of tobacco plantations required a dependable labor force and stronger social controls." },
{ title: "Pennsylvania promotional broadside (1680s)", source: "Colonial advertisement", excerpt: "Land, trade, and religious toleration invite industrious settlers to Pennsylvania." },
{ title: "Benjamin Franklin, 'Join, or Die' cartoon (1754)", source: "Pennsylvania Gazette", excerpt: "Franklin's segmented snake urged intercolonial unity against French and Native power." },
{ title: "Olaudah Equiano autobiography (1789)", source: "Enslavement narrative", excerpt: "The passage and sale system exposed the brutality at the center of Atlantic labor markets." },
{ title: "Navigation Act framework (1660s)", source: "British imperial statute", excerpt: "Colonial trade was tied to English ships and ports to reinforce imperial mercantilism." }
],
3: [
{ title: "Thomas Paine, 'Common Sense' (1776)", source: "Political pamphlet", excerpt: "In America THE LAW IS KING; for as in absolute governments the King is law, so in free countries the law ought to be king." },
{ title: "Declaration of Independence (1776)", source: "Continental Congress", excerpt: "All men are created equal... they are endowed... with certain unalienable Rights." },
{ title: "The Federalist No. 10 (1787)", source: "James Madison", excerpt: "The latent causes of faction are thus sown in the nature of man." },
{ title: "Abigail Adams to John Adams (1776)", source: "Private correspondence", excerpt: "Remember the ladies, and be more generous and favorable to them than your ancestors." },
{ title: "George Washington Farewell Address (1796)", source: "Presidential address", excerpt: "Avoid permanent alliances and sectional parties that divide republican unity." },
{ title: "Judith Sargent Murray, 'On the Equality of the Sexes' (1790)", source: "Essay", excerpt: "Intellectual capacity is not naturally unequal between men and women." }
],
4: [
{ title: "Lowell Mill worker testimony (1840s)", source: "Labor account", excerpt: "Factory discipline and the clock regulated every hour of the day." },
{ title: "Canal and railroad promotion (1830s)", source: "Economic pamphlet", excerpt: "Internal improvements unite markets and accelerate national prosperity." },
{ title: "Seneca Falls Declaration (1848)", source: "Women's rights convention", excerpt: "He has compelled her to submit to laws, in the formation of which she had no voice." },
{ title: "Andrew Jackson veto message on Bank recharter (1832)", source: "Presidential message", excerpt: "The Bank concentrated power and privilege beyond the will of ordinary citizens." },
{ title: "Cherokee Nation v. Georgia context (1831)", source: "Supreme Court era summary", excerpt: "Federal policy and removal pressure challenged Native sovereignty in the Southeast." },
{ title: "Frederick Douglass, Narrative (1845)", source: "Autobiography", excerpt: "Literacy became a path to resistance and an indictment of slavery's violence." }
],
5: [
{ title: "Abraham Lincoln, Second Inaugural (1865)", source: "Presidential address", excerpt: "Yet, if God wills that it continue... until every drop of blood drawn with the lash shall be paid by another drawn with the sword..." },
{ title: "Freedmen's Bureau report (1866)", source: "Federal agency report", excerpt: "Schools and labor contracts became central instruments of postwar transition." },
{ title: "Mississippi Black Codes (1865)", source: "State legislation", excerpt: "Civil freedom was narrowly defined and labor mobility constrained." },
{ title: "Emancipation Proclamation excerpt (1863)", source: "Executive order", excerpt: "Enslaved persons in rebelling states were declared forever free as a war measure." },
{ title: "13th Amendment ratification text (1865)", source: "Constitutional amendment", excerpt: "Neither slavery nor involuntary servitude shall exist within the United States." },
{ title: "Sharecropping labor contract (1867)", source: "Postwar labor agreement", excerpt: "Freed families exchanged crop shares for land access under restrictive debt terms." }
],
6: [
{ title: "Andrew Carnegie, 'Gospel of Wealth' (1889)", source: "Essay", excerpt: "The man who dies rich dies disgraced." },
{ title: "Henry George, 'Progress and Poverty' (1879)", source: "Economic critique", excerpt: "Material progress has not relieved labor from want." },
{ title: "Jacob Riis, 'How the Other Half Lives' (1890)", source: "Urban reform text", excerpt: "The tenements became dark, crowded spaces where disease spread rapidly." },
{ title: "Homestead Strike reporting (1892)", source: "Labor conflict coverage", excerpt: "Violence at Carnegie steel works highlighted corporate-labor confrontation." },
{ title: "Booker T. Washington, Atlanta Exposition Address (1895)", source: "Speech", excerpt: "Economic self-help was framed as the practical route toward Black advancement." },
{ title: "Plessy v. Ferguson ruling excerpt (1896)", source: "Supreme Court decision", excerpt: "The Court upheld 'separate but equal,' entrenching segregation in public life." }
],
7: [
{ title: "Theodore Roosevelt, New Nationalism speech (1910)", source: "Campaign speech", excerpt: "Human welfare, not property, should be the first consideration of government." },
{ title: "Triangle Shirtwaist Factory fire coverage (1911)", source: "Newspaper reporting", excerpt: "Public outrage linked industrial safety failures to demands for reform." },
{ title: "Clayton Antitrust Act summary (1914)", source: "Congressional act", excerpt: "Labor organizations were exempted from prosecution as unlawful combinations." },
{ title: "Jane Addams on Hull House mission (1910)", source: "Settlement-house writing", excerpt: "Urban reform connected immigrant services to broader democratic participation." },
{ title: "Woodrow Wilson Fourteen Points excerpt (1918)", source: "War aims speech", excerpt: "Self-determination and collective security were offered as postwar principles." },
{ title: "19th Amendment text (1920)", source: "Constitutional amendment", excerpt: "Voting rights could not be denied on account of sex." }
],
8: [
{ title: "George Kennan, 'Long Telegram' (1946)", source: "Diplomatic cable", excerpt: "Soviet power is impervious to the logic of reason, and highly sensitive to the logic of force." },
{ title: "Martin Luther King Jr., 'Letter from Birmingham Jail' (1963)", source: "Civil rights letter", excerpt: "Injustice anywhere is a threat to justice everywhere." },
{ title: "Lyndon B. Johnson, Great Society speech (1964)", source: "Presidential speech", excerpt: "The Great Society rests on abundance and liberty for all." },
{ title: "Brown v. Board of Education (1954)", source: "Supreme Court opinion", excerpt: "Separate educational facilities are inherently unequal." },
{ title: "Gulf of Tonkin Resolution (1964)", source: "Congressional resolution", excerpt: "Congress authorized broad presidential military action in Southeast Asia." },
{ title: "Rachel Carson, 'Silent Spring' excerpt (1962)", source: "Environmental text", excerpt: "Unchecked chemical use threatened ecological balance and public health." }
],
9: [
{ title: "Ronald Reagan, first inaugural address (1981)", source: "Presidential address", excerpt: "Government is not the solution to our problem; government is the problem." },
{ title: "NAFTA debate statement (1993)", source: "Congressional record", excerpt: "Continental free trade will reshape labor and manufacturing patterns across North America." },
{ title: "September 20 Address to Congress (2001)", source: "Presidential address", excerpt: "Our war on terror begins with al Qaeda, but it does not end there." },
{ title: "George H.W. Bush 'New World Order' speech (1991)", source: "Presidential address", excerpt: "Post-Cold War policy emphasized coalition security and global cooperation." },
{ title: "USA PATRIOT Act findings (2001)", source: "Federal statute", excerpt: "National-security surveillance powers were significantly expanded after 9/11." },
{ title: "Obergefell v. Hodges ruling excerpt (2015)", source: "Supreme Court opinion", excerpt: "The Constitution protects the right of same-sex couples to marry." }
]
};
const DBQ_SOURCE_FULL_TEXTS = {
"John Winthrop, 'A Modell of Christian Charity' (1630)": "For we must consider that we shall be as a city upon a hill. The eyes of all people are upon us. So that if we shall deal falsely with our God in this work we have undertaken, and so cause Him to withdraw His present help from us, we shall be made a story and a by-word through the world.",
"Virginia House of Burgesses law on tobacco labor (1670s)": "Whereas the planting of tobacco and the increase of trade requires a constant and orderly laboring population, the Assembly establishes regulations governing service, status, and discipline. These laws reveal how colonial elites linked economic expansion to labor control.",
"Pennsylvania promotional broadside (1680s)": "This province offers liberty of conscience, fertile lands, and access to Atlantic trade. Industrious families may improve their estate by farming and commerce under a frame of government that protects property and toleration.",
"Thomas Paine, 'Common Sense' (1776)": "In America THE LAW IS KING. For as in absolute governments the King is law, so in free countries the law ought to be king; and there ought to be no other. A government of our own is our natural right.",
"Declaration of Independence (1776)": "We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness. That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed.",
"The Federalist No. 10 (1787)": "The latent causes of faction are thus sown in the nature of man. The regulation of these various and interfering interests forms the principal task of modern legislation. A large republic provides a remedy by extending the sphere.",
"Lowell Mill worker testimony (1840s)": "The bell rings at dawn, and we enter the mills where the machinery and overseers govern the rhythm of the day. Though wages are paid in cash, the discipline of factory labor transforms family life and social customs.",
"Canal and railroad promotion (1830s)": "Internal improvements bind distant regions into one market and lower transportation costs for farmers and merchants. Canals and railroads accelerate circulation of goods, people, and information across the republic.",
"Seneca Falls Declaration (1848)": "He has compelled her to submit to laws, in the formation of which she had no voice. He has taken from her all right in property, even to the wages she earns. Therefore, women demand equal civil and political rights.",
"Abraham Lincoln, Second Inaugural (1865)": "Yet, if God wills that it continue until all the wealth piled by the bondman's two hundred and fifty years of unrequited toil shall be sunk, still it must be said, 'the judgments of the Lord are true and righteous altogether.'",
"Freedmen's Bureau report (1866)": "The Bureau has supervised labor contracts, established schools, and arbitrated disputes in districts where civil authority is unsettled. Educational access and labor negotiation became central to Reconstruction policy.",
"Mississippi Black Codes (1865)": "Freed people are declared free, yet restrictions on movement, labor contracts, and vagrancy penalties bind them to dependent labor. The codes demonstrate attempts to preserve racial hierarchy after emancipation.",
"Andrew Carnegie, 'Gospel of Wealth' (1889)": "The man who dies rich dies disgraced. Wealth accumulated by exceptional ability should be administered for the community's benefit through institutions that improve civilization.",
"Henry George, 'Progress and Poverty' (1879)": "Material progress has not relieved labor from want. The growth of productive power and the concentration of land value can deepen inequality unless public policy addresses structural causes.",
"Jacob Riis, 'How the Other Half Lives' (1890)": "In tenement districts, overcrowded rooms, poor ventilation, and unsafe streets produce disease and hardship. Reform requires exposing these conditions to middle-class readers and policymakers.",
"Theodore Roosevelt, New Nationalism speech (1910)": "The object of government is the welfare of the people. Human welfare, not property, must be the first concern of statesmanship. Powerful corporations require public supervision.",
"Triangle Shirtwaist Factory fire coverage (1911)": "The factory fire killed workers trapped by locked doors and unsafe exits. Public outrage transformed workplace tragedy into demands for inspections, fire codes, and labor reform.",
"Clayton Antitrust Act summary (1914)": "The Act strengthens antitrust enforcement while clarifying that labor is not a commodity and labor organizations are not unlawful combinations. It reflects Progressive efforts to regulate corporate power.",
"George Kennan, 'Long Telegram' (1946)": "Soviet power is impervious to the logic of reason, but highly sensitive to the logic of force. U.S. policy should contain expansion through patient, firm, and vigilant pressure.",
"Martin Luther King Jr., 'Letter from Birmingham Jail' (1963)": "Injustice anywhere is a threat to justice everywhere. We are caught in an inescapable network of mutuality, tied in a single garment of destiny. Direct action seeks to create tension that compels negotiation.",
"Lyndon B. Johnson, Great Society speech (1964)": "The Great Society rests on abundance and liberty for all. It demands an end to poverty and racial injustice, while building cities, schools, and institutions worthy of national ideals.",
"Ronald Reagan, first inaugural address (1981)": "In this present crisis, government is not the solution to our problem; government is the problem. Americans look to renewal through markets, federal restraint, and revived confidence.",
"NAFTA debate statement (1993)": "Continental free trade will reshape investment, labor competition, and manufacturing supply chains across North America. Supporters and critics alike expect long-term structural change.",
"September 20 Address to Congress (2001)": "Our war on terror begins with al Qaeda, but it does not end there. It will not end until every terrorist group of global reach has been found, stopped, and defeated.",
"Benjamin Franklin, 'Join, or Die' cartoon (1754)": "Published during imperial conflict, Franklin's segmented snake image argued that disunited colonies would fail against external threats and internal disorder.",
"Olaudah Equiano autobiography (1789)": "Equiano described kidnapping, the Middle Passage, and sale into Atlantic slavery, highlighting violence and commodification in imperial labor systems.",
"Navigation Act framework (1660s)": "The Navigation Acts routed most colonial exports and imports through English ships and customs structures, strengthening mercantilist control over colonial economies.",
"Abigail Adams to John Adams (1776)": "Remember the ladies, and be more generous and favorable to them than your ancestors. This appeal exposed limits of revolutionary equality.",
"George Washington Farewell Address (1796)": "Washington warned against entrenched partisan factions and long-term foreign entanglements that could undermine republican self-government.",
"Judith Sargent Murray, 'On the Equality of the Sexes' (1790)": "Murray challenged assumptions of female inferiority, arguing that unequal education—not nature—produced unequal outcomes.",
"Andrew Jackson veto message on Bank recharter (1832)": "Jackson argued concentrated financial privilege threatened democratic equality and presented himself as defender of the common citizen.",
"Cherokee Nation v. Georgia context (1831)": "The era's legal conflicts over Cherokee sovereignty demonstrated how federal expansion and state pressure displaced Native nations.",
"Frederick Douglass, Narrative (1845)": "Douglass connected literacy to freedom, exposing slavery's dependence on violence and ignorance while framing abolition as a moral and political imperative.",
"Emancipation Proclamation excerpt (1863)": "Lincoln declared enslaved people in rebelling states free, transforming Union war aims and opening the door to Black military service.",
"13th Amendment ratification text (1865)": "The amendment constitutionally abolished slavery across the United States, marking a foundational legal shift in national citizenship and labor.",
"Sharecropping labor contract (1867)": "Contracts often locked freed families into debt cycles and crop-lien dependence, limiting the economic independence promised by emancipation.",
"Homestead Strike reporting (1892)": "News coverage of the strike linked private security violence and strikebreaking to national debates over labor rights and corporate power.",
"Booker T. Washington, Atlanta Exposition Address (1895)": "Washington emphasized vocational advancement and economic cooperation while accepting segregation as a temporary political reality.",
"Plessy v. Ferguson ruling excerpt (1896)": "By upholding segregation under 'separate but equal,' the Court provided constitutional cover for Jim Crow systems.",
"Jane Addams on Hull House mission (1910)": "Addams argued settlement work should integrate immigrants into civic life while addressing structural poverty and urban inequality.",
"Woodrow Wilson Fourteen Points excerpt (1918)": "Wilson's program framed open diplomacy, national self-determination, and collective security as principles for a stable postwar order.",
"19th Amendment text (1920)": "Ratification nationalized women's suffrage and redefined democratic participation in federal and state elections.",
"Brown v. Board of Education (1954)": "The Court rejected legal school segregation and energized direct-action civil rights campaigns across the South and beyond.",
"Gulf of Tonkin Resolution (1964)": "The resolution granted broad executive war authority, accelerating U.S. intervention in Vietnam with limited congressional constraint.",
"Rachel Carson, 'Silent Spring' excerpt (1962)": "Carson linked pesticide overuse to ecological harm and public risk, helping spark modern environmental regulation and activism.",
"George H.W. Bush 'New World Order' speech (1991)": "Bush framed post-Cold War leadership around coalition warfare, international law, and multilateral security institutions.",
"USA PATRIOT Act findings (2001)": "The law expanded federal surveillance and intelligence coordination, intensifying debates over liberty, privacy, and national security.",
"Obergefell v. Hodges ruling excerpt (2015)": "The Court held that same-sex couples have a constitutional right to marry under due process and equal protection principles."
};
function loadDBQPromptForTool(resource) {
const doc = document.getElementById('dbq-document');
if (!doc) return;
currentDBQToolResource = resource || { period: 'all' };
const pack = buildDbqPack(currentDBQToolResource);
const prompt = pack.prompt;
const sourceSet = pack.sources;
const fullTexts = pack.fullTexts;
const bankNote = pack.meta
? `<p class="dbq-source-help dbq-source-help--bank">Pre-built set: <strong>${escapeHtml(pack.meta.id)}</strong> · ${escapeHtml(pack.meta.label || '')} · 6 documents</p>`
: '';
doc.innerHTML = `
<div class="dbq-source-pack">
<p><strong>DBQ Prompt:</strong></p>
<p>${escapeHtml(prompt)}</p>
${bankNote}
<hr>
${sourceSet.map((source, idx) => `
<details class="dbq-source-accordion" data-doc="${idx + 1}" ${idx === 0 ? 'open' : ''}>
<summary>Document ${idx + 1}: ${escapeHtml(source.title)}</summary>
<article class="dbq-source-card">
<p class="dbq-source-meta">${escapeHtml(source.source)}</p>
<p class="dbq-source-text"><strong>Key excerpt:</strong> ${escapeHtml(source.excerpt)}</p>
<p class="dbq-source-text">${escapeHtml(fullTexts[source.title] || source.fullText || source.excerpt)}</p>
<button type="button" class="submit-btn dbq-open-doc-btn"
data-doc-title="${escapeHtml(source.title)}"
data-doc-source="${escapeHtml(source.source)}"
data-doc-excerpt="${escapeHtml(source.excerpt)}"
data-doc-full="${escapeHtml(fullTexts[source.title] || source.fullText || source.excerpt)}">Open full document</button>
</article>
</details>
`).join('')}
<p class="dbq-source-help">Tip: select text, then choose Highlight / Underline / Notepad / rubric tag.</p>
</div>
`;
}
function openDbqDocumentModal(documentData) {
const titleEl = document.getElementById('dbq-doc-modal-title');
const bodyEl = document.getElementById('dbq-doc-modal-body');
if (!titleEl || !bodyEl) return;
titleEl.textContent = documentData.title || 'DBQ Document';
bodyEl.innerHTML = `
<p class="dbq-doc-modal-source"><strong>Source:</strong> ${escapeHtml(documentData.source || 'Primary source')}</p>
<p class="dbq-doc-modal-excerpt"><strong>Excerpt:</strong> ${escapeHtml(documentData.excerpt || '')}</p>
<p class="dbq-doc-modal-text">${escapeHtml(documentData.fullText || documentData.excerpt || '')}</p>
`;
APUSH.openModal('dbq-doc-modal');
}
// SAQ Practice Questions Data
const SAQ_QUESTIONS = {
all: [
{
question: "Briefly explain ONE way in which the development of the Atlantic economy in the seventeenth and eighteenth centuries contributed to the development of regional identities in the British North American colonies.",
prompt: "a) Explain ONE way in which the development of the Atlantic economy contributed to regional identities.",
sampleAnswer: "The Atlantic economy fostered regional specialization: New England focused on shipbuilding and trade, the Middle Colonies on grain production, and the Southern Colonies on cash crops like tobacco and rice. This economic specialization created distinct regional cultures and social structures."
},
{
question: "Briefly explain ONE specific historical development that represents an accomplishment of the national government under the Articles of Confederation.",
prompt: "b) Explain ONE accomplishment of the Articles of Confederation government.",
sampleAnswer: "The Articles of Confederation successfully established the Northwest Ordinance of 1787, which created a process for admitting new states, prohibited slavery in the Northwest Territory, and set aside land for public education."
},
{
question: "Briefly explain ONE way in which the market revolution changed women's roles in society from 1800 to 1848.",
prompt: "c) Explain ONE way the market revolution changed women's roles.",
sampleAnswer: "The market revolution created the \"cult of domesticity,\" which idealized women as moral guardians of the home while men worked in the market economy. This separated public and private spheres, limiting women's economic participation outside the home."
},
{
question: "Briefly explain ONE specific historical effect of the Civil War on the economy of the United States.",
prompt: "d) Explain ONE economic effect of the Civil War.",
sampleAnswer: "The Civil War accelerated industrialization in the North, as the Union needed mass-produced weapons, uniforms, and supplies. This led to increased factory production and consolidated economic power in the Northeast."
},
{
question: "Briefly explain ONE way in which the Progressive Era reforms represented a response to the problems created by industrialization and urbanization.",
prompt: "e) Explain ONE Progressive Era response to industrialization problems.",
sampleAnswer: "Progressive reformers pushed for workplace safety regulations and labor laws, such as limiting working hours and improving factory conditions, in response to dangerous and exploitative industrial working conditions."
},
{
question: "Briefly explain ONE argument used by supporters of Manifest Destiny in the 1840s.",
prompt: "f) Explain ONE pro-Manifest Destiny argument.",
sampleAnswer: "Supporters argued the United States had a providential mission to expand westward, spreading republican institutions and economic opportunity across the continent."
},
{
question: "Briefly explain ONE way in which immigration changed American cities in the late nineteenth century.",
prompt: "g) Explain ONE urban impact of immigration.",
sampleAnswer: "Immigration fueled rapid urban growth and created ethnic neighborhoods, while also expanding factory labor and shaping political machines in major cities."
},
{
question: "Briefly explain ONE cause of U.S. entry into World War I.",
prompt: "h) Explain ONE cause of U.S. entry into WWI.",
sampleAnswer: "Germany's unrestricted submarine warfare, including attacks on ships with American passengers and cargo, pushed the U.S. toward war."
},
{
question: "Briefly explain ONE way the New Deal changed the role of the federal government.",
prompt: "i) Explain ONE New Deal shift in federal power.",
sampleAnswer: "The New Deal expanded federal responsibility for economic stability and social welfare through agencies, relief programs, and regulations."
},
{
question: "Briefly explain ONE reason the Civil Rights Movement gained momentum after World War II.",
prompt: "j) Explain ONE postwar factor behind Civil Rights activism.",
sampleAnswer: "African American veterans returned from WWII demanding equal rights, and Cold War pressure highlighted contradictions between segregation and U.S. democratic ideals."
}
],
3: [
{
question: "Briefly explain ONE specific cause of the American Revolution.",
prompt: "a) Explain ONE cause of the American Revolution.",
sampleAnswer: "The British imposition of taxes without colonial representation, such as the Stamp Act and Townshend Acts, violated the colonists' understanding of their rights as Englishmen and led to widespread resistance."
},
{
question: "Briefly explain ONE way in which the American Revolution changed political ideas about government.",
prompt: "b) Explain ONE political idea changed by the Revolution.",
sampleAnswer: "The Revolution popularized the concept of republicanism, emphasizing that government authority derives from the consent of the governed rather than divine right or hereditary monarchy."
},
{
question: "Briefly explain ONE reason why the Articles of Confederation were replaced by the Constitution.",
prompt: "c) Explain ONE reason for replacing the Articles of Confederation.",
sampleAnswer: "The Articles gave the national government insufficient power to regulate commerce and tax, leading to economic chaos and inability to address issues like Shays' Rebellion, which convinced leaders a stronger central government was needed."
},
{
question: "Briefly explain ONE way in which the Revolutionary War affected women.",
prompt: "d) Explain ONE effect of the Revolution on women.",
sampleAnswer: "The Revolution encouraged the idea of Republican Motherhood, assigning women a civic role in raising virtuous citizens even as most legal and political rights remained limited."
},
{
question: "Briefly explain ONE challenge faced by the Continental Army during the war.",
prompt: "e) Explain ONE wartime challenge for the Continental Army.",
sampleAnswer: "The Continental Army struggled with supply shortages and inconsistent state support, which made sustaining troops and morale difficult."
},
{
question: "Briefly explain ONE way in which the Constitution addressed a weakness of the Articles.",
prompt: "f) Explain ONE constitutional fix to the Articles.",
sampleAnswer: "The Constitution gave Congress power to tax, solving the Articles-era problem of a national government that could not reliably raise revenue."
},
{
question: "Briefly explain ONE argument made by Anti-Federalists during ratification.",
prompt: "g) Explain ONE Anti-Federalist argument.",
sampleAnswer: "Anti-Federalists argued the Constitution created a central government too powerful and demanded a Bill of Rights to protect individual liberties."
},
{
question: "Briefly explain ONE foreign-policy issue the new republic faced in the 1790s.",
prompt: "h) Explain ONE diplomatic issue in the 1790s.",
sampleAnswer: "Tensions between Britain and France forced U.S. leaders to define neutrality, balancing trade interests while avoiding entanglement in European wars."
},
{
question: "Briefly explain ONE economic debate that shaped early U.S. politics.",
prompt: "i) Explain ONE early national economic debate.",
sampleAnswer: "Hamilton's proposal for a national bank divided leaders over constitutional interpretation and the proper scope of federal economic power."
},
{
question: "Briefly explain ONE way political parties emerged in the 1790s.",
prompt: "j) Explain ONE cause of first-party system emergence.",
sampleAnswer: "Disagreements over the national bank, federal authority, and foreign policy split leaders into Federalists and Democratic-Republicans."
}
]
};
function generatePeriodSAQQuestions(periodNum) {
const pd = window.APUSH_DATA && window.APUSH_DATA.periods ? window.APUSH_DATA.periods[periodNum] : null;
if (!pd) return shuffledCopy(SAQ_QUESTIONS.all).slice(0, 10);
const timeline = Array.isArray(pd.timeline) ? pd.timeline : [];
const concepts = Array.isArray(pd.keyConcepts) ? pd.keyConcepts : [];
const themes = Array.isArray(pd.themes) ? pd.themes : [];
const generated = [];
timeline.slice(0, 4).forEach((event, idx) => {
generated.push({
question: `Briefly explain ONE way the development around "${event.title}" shaped ${pd.name}.`,
prompt: `${String.fromCharCode(97 + idx)}) Explain ONE historical effect of "${event.title}" in ${pd.dates}.`,
sampleAnswer: `One important effect of ${event.title} was that ${event.description}. This mattered because it influenced the broader trajectory of ${pd.name}.`
});
});
concepts.slice(0, 3).forEach((concept, idx) => {
generated.push({
question: `Briefly explain ONE specific historical example that supports this idea: ${concept}`,
prompt: `${String.fromCharCode(101 + idx)}) Provide ONE specific piece of evidence for this concept.`,
sampleAnswer: `A strong example is [specific event/person/law] from ${pd.dates}, which supports the concept by showing how ${concept.toLowerCase()}.`
});
});
themes.slice(0, 3).forEach((theme, idx) => {
generated.push({
question: `Briefly explain ONE way the theme of ${theme} appears in Period ${periodNum}.`,
prompt: `${String.fromCharCode(104 + idx)}) Explain ONE example of ${theme} in this period.`,
sampleAnswer: `The theme of ${theme} appears in [specific example], which demonstrates how historical actors responded to conditions of the era.`
});
});
return generated.length ? generated.slice(0, 10) : shuffledCopy(SAQ_QUESTIONS.all).slice(0, 10);
}
let currentSAQIndex = 0;
let currentSAQSet = [];
let currentSAQScore = 0;
let currentSAQChecked = false;