Skip to content

Commit 4e90a77

Browse files
jsb2092claude
andcommitted
Fix section cache clearing and default to all questions
- Clear all caches (hasCachedQuestions, cachedSectionQuestions, cachedFinalQuestions, localStorage) when section settings change - Section count now defaults to null (blank) which uses all questions - Input shows placeholder "All" when count is empty - Increased max questions from 50 to 500 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0833157 commit 4e90a77

1 file changed

Lines changed: 41 additions & 11 deletions

File tree

questionbank/static/js/app.js

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@
17861786
course: defaultCourse,
17871787
tags: [],
17881788
type: '',
1789-
count: 5,
1789+
count: null, // null = use all available questions
17901790
maxPoints: null,
17911791
maxMCPoints: null,
17921792
maxTFPoints: null,
@@ -1858,8 +1858,8 @@
18581858
</div>
18591859
<div>
18601860
<label class="block text-xs text-gray-500 dark:text-slate-400 mb-1"># Questions</label>
1861-
<input type="number" value="${s.count}" min="1" max="50" onchange="updateSectionCount(${s.id}, this.value)"
1862-
class="input-modern w-full px-2 py-1.5 rounded-lg text-sm">
1861+
<input type="number" value="${s.count || ''}" min="1" max="500" onchange="updateSectionCount(${s.id}, this.value)"
1862+
class="input-modern w-full px-2 py-1.5 rounded-lg text-sm" placeholder="All">
18631863
</div>
18641864
<div>
18651865
<label class="block text-xs text-gray-500 dark:text-slate-400 mb-1">Available</label>
@@ -1954,7 +1954,13 @@
19541954
} else {
19551955
section.tags.push(tagName);
19561956
}
1957-
hasCachedQuestions = false; // Clear cache so refresh will re-fetch
1957+
// Clear all caches so refresh will re-fetch
1958+
hasCachedQuestions = false;
1959+
cachedSectionQuestions = {};
1960+
cachedFinalQuestions = null;
1961+
if (currentTemplateId) {
1962+
localStorage.removeItem(`examQuestionIds_${currentTemplateId}`);
1963+
}
19581964
loadSectionTags(sectionId); // Re-render tags
19591965
saveViewState();
19601966
}
@@ -1972,7 +1978,13 @@
19721978
section.tags = []; // Reset tags when course changes
19731979
loadSectionTags(id);
19741980
}
1975-
hasCachedQuestions = false; // Clear cache so refresh will re-fetch
1981+
// Clear all caches so refresh will re-fetch
1982+
hasCachedQuestions = false;
1983+
cachedSectionQuestions = {};
1984+
cachedFinalQuestions = null;
1985+
if (currentTemplateId) {
1986+
localStorage.removeItem(`examQuestionIds_${currentTemplateId}`);
1987+
}
19761988
saveViewState();
19771989
}
19781990

@@ -1982,14 +1994,26 @@
19821994
section.type = value;
19831995
updateSectionAvailable(id);
19841996
}
1985-
hasCachedQuestions = false; // Clear cache so refresh will re-fetch
1997+
// Clear all caches so refresh will re-fetch
1998+
hasCachedQuestions = false;
1999+
cachedSectionQuestions = {};
2000+
cachedFinalQuestions = null;
2001+
if (currentTemplateId) {
2002+
localStorage.removeItem(`examQuestionIds_${currentTemplateId}`);
2003+
}
19862004
saveViewState();
19872005
}
19882006

19892007
function updateSectionCount(id, value) {
19902008
const section = examSections.find(s => s.id === id);
1991-
if (section) section.count = parseInt(value) || 1;
1992-
hasCachedQuestions = false; // Clear cache so refresh will re-fetch
2009+
if (section) section.count = value ? parseInt(value) : null; // null = use all
2010+
// Clear all caches so refresh will re-fetch
2011+
hasCachedQuestions = false;
2012+
cachedSectionQuestions = {};
2013+
cachedFinalQuestions = null;
2014+
if (currentTemplateId) {
2015+
localStorage.removeItem(`examQuestionIds_${currentTemplateId}`);
2016+
}
19932017
updateExamStats();
19942018
saveViewState();
19952019
}
@@ -1999,7 +2023,13 @@
19992023
if (section) {
20002024
section[field] = value ? parseInt(value) : null;
20012025
}
2002-
hasCachedQuestions = false; // Clear cache so refresh will re-fetch
2026+
// Clear all caches so refresh will re-fetch
2027+
hasCachedQuestions = false;
2028+
cachedSectionQuestions = {};
2029+
cachedFinalQuestions = null;
2030+
if (currentTemplateId) {
2031+
localStorage.removeItem(`examQuestionIds_${currentTemplateId}`);
2032+
}
20032033
saveViewState();
20042034
}
20052035

@@ -2191,8 +2221,8 @@
21912221
}
21922222
}
21932223
} else {
2194-
// Simple count-based selection (original behavior)
2195-
sectionQuestions = questions.slice(0, section.count);
2224+
// Simple count-based selection (or all if count is null)
2225+
sectionQuestions = section.count ? questions.slice(0, section.count) : questions;
21962226
}
21972227

21982228
// Cache the selected questions for this section config

0 commit comments

Comments
 (0)