check vocabulary
This commit is contained in:
@@ -73,11 +73,19 @@ const WORD_RECORD_MODES: WordRecordModeKey[] = [
|
||||
'multipleChoice'
|
||||
];
|
||||
|
||||
const getNumericEnv = (names: string[], fallback: number): number => {
|
||||
for (const name of names) {
|
||||
const parsed = Number(process.env[name]);
|
||||
if (Number.isFinite(parsed)) return parsed;
|
||||
}
|
||||
return fallback;
|
||||
};
|
||||
|
||||
const ATTEMPT_TTL_MS = 30 * 60 * 1000;
|
||||
const MIN_STUDY_WORD_COUNT = 10;
|
||||
const MAX_STUDY_WORD_COUNT = 100;
|
||||
const MIN_SECONDS_PER_QUESTION = Number(process.env.VOCABULARY_MIN_SECONDS_PER_QUESTION || 2);
|
||||
const MAX_SECONDS_PER_QUESTION = Number(process.env.VOCABULARY_MAX_SECONDS_PER_QUESTION || 10);
|
||||
const MIN_SECONDS_PER_QUESTION = getNumericEnv(['VOCABULARY_MIN_SECONDS_PER_QUESTION', 'MIN_SECONDS_PER_QUESTION'], 2);
|
||||
const MAX_SECONDS_PER_QUESTION = getNumericEnv(['VOCABULARY_MAX_SECONDS_PER_QUESTION', 'MAX_SECONDS_PER_QUESTION'], 10);
|
||||
const VOCABULARY_ALLOWED_ORIGINS = (process.env.VOCABULARY_ALLOWED_ORIGINS || 'https://d1kt.cn,http://localhost:3000,http://localhost:3001')
|
||||
.split(',')
|
||||
.map(item => item.trim())
|
||||
@@ -1249,7 +1257,9 @@ router.post('/test-record', authMiddleware, async (req, res) => {
|
||||
userAnswer: result.userAnswer,
|
||||
correctAnswer: result.correctAnswer,
|
||||
isCorrect: shouldInvalidateBatch ? false : result.isCorrect
|
||||
}))
|
||||
})),
|
||||
invalidated: shouldInvalidateBatch,
|
||||
riskFlags: attemptAny.riskFlags || []
|
||||
});
|
||||
|
||||
res.status(201).json({
|
||||
|
||||
Reference in New Issue
Block a user