|
1786 | 1786 | course: defaultCourse, |
1787 | 1787 | tags: [], |
1788 | 1788 | type: '', |
1789 | | - count: 5, |
| 1789 | + count: null, // null = use all available questions |
1790 | 1790 | maxPoints: null, |
1791 | 1791 | maxMCPoints: null, |
1792 | 1792 | maxTFPoints: null, |
|
1858 | 1858 | </div> |
1859 | 1859 | <div> |
1860 | 1860 | <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"> |
1863 | 1863 | </div> |
1864 | 1864 | <div> |
1865 | 1865 | <label class="block text-xs text-gray-500 dark:text-slate-400 mb-1">Available</label> |
|
1954 | 1954 | } else { |
1955 | 1955 | section.tags.push(tagName); |
1956 | 1956 | } |
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 | + } |
1958 | 1964 | loadSectionTags(sectionId); // Re-render tags |
1959 | 1965 | saveViewState(); |
1960 | 1966 | } |
|
1972 | 1978 | section.tags = []; // Reset tags when course changes |
1973 | 1979 | loadSectionTags(id); |
1974 | 1980 | } |
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 | + } |
1976 | 1988 | saveViewState(); |
1977 | 1989 | } |
1978 | 1990 |
|
|
1982 | 1994 | section.type = value; |
1983 | 1995 | updateSectionAvailable(id); |
1984 | 1996 | } |
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 | + } |
1986 | 2004 | saveViewState(); |
1987 | 2005 | } |
1988 | 2006 |
|
1989 | 2007 | function updateSectionCount(id, value) { |
1990 | 2008 | 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 | + } |
1993 | 2017 | updateExamStats(); |
1994 | 2018 | saveViewState(); |
1995 | 2019 | } |
|
1999 | 2023 | if (section) { |
2000 | 2024 | section[field] = value ? parseInt(value) : null; |
2001 | 2025 | } |
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 | + } |
2003 | 2033 | saveViewState(); |
2004 | 2034 | } |
2005 | 2035 |
|
|
2191 | 2221 | } |
2192 | 2222 | } |
2193 | 2223 | } 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; |
2196 | 2226 | } |
2197 | 2227 |
|
2198 | 2228 | // Cache the selected questions for this section config |
|
0 commit comments