fix
This commit is contained in:
@@ -192,8 +192,12 @@ async function getOrGenerateTopicQuestions(topic, count) {
|
|||||||
let bank = await db.getQuizBank(topic.id);
|
let bank = await db.getQuizBank(topic.id);
|
||||||
|
|
||||||
if (bank.length < count) {
|
if (bank.length < count) {
|
||||||
await forceGenerateTopicQuestions(topic, 5);
|
try {
|
||||||
bank = await db.getQuizBank(topic.id);
|
await forceGenerateTopicQuestions(topic, 5);
|
||||||
|
bank = await db.getQuizBank(topic.id);
|
||||||
|
} catch (err) {
|
||||||
|
console.warn(`[quiz] Failed to generate questions for ${topic.label}:`, err.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sample(bank, Math.min(count, bank.length));
|
return sample(bank, Math.min(count, bank.length));
|
||||||
@@ -210,7 +214,7 @@ export async function deleteQuestion(topicId, questionId) {
|
|||||||
export async function generateWeeklyQuiz(userId, weekNumber, force = false) {
|
export async function generateWeeklyQuiz(userId, weekNumber, force = false) {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
const cached = await db.getCachedQuiz(userId, weekNumber);
|
const cached = await db.getCachedQuiz(userId, weekNumber);
|
||||||
if (cached) return cached;
|
if (cached?.questions?.length > 0) return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { primaryTopic, reviewTopics } = await selectTestTopics(userId, weekNumber);
|
const { primaryTopic, reviewTopics } = await selectTestTopics(userId, weekNumber);
|
||||||
@@ -240,6 +244,10 @@ export async function generateWeeklyQuiz(userId, weekNumber, force = false) {
|
|||||||
|
|
||||||
const shuffled = shuffle(questions).slice(0, 5);
|
const shuffled = shuffle(questions).slice(0, 5);
|
||||||
|
|
||||||
|
if (shuffled.length === 0) {
|
||||||
|
throw new Error('Could not assemble enough questions for this week\'s test. Please try again.');
|
||||||
|
}
|
||||||
|
|
||||||
const quiz = {
|
const quiz = {
|
||||||
questions: shuffled,
|
questions: shuffled,
|
||||||
meta: {
|
meta: {
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ function getBuildSha() {
|
|||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
build: {
|
||||||
|
sourcemap: true,
|
||||||
|
},
|
||||||
define: {
|
define: {
|
||||||
__BUILD_SHA__: JSON.stringify(getBuildSha()),
|
__BUILD_SHA__: JSON.stringify(getBuildSha()),
|
||||||
__BUILD_TIME__: JSON.stringify(new Date().toISOString()),
|
__BUILD_TIME__: JSON.stringify(new Date().toISOString()),
|
||||||
|
|||||||
Reference in New Issue
Block a user