Skip to content

Commit

Permalink
Try to fix #9
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyEye-FAST committed Jul 11, 2024
1 parent 4ca3564 commit 0f4462b
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions static/js/quiz.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
$(document).ready(function () {
let currentQuestionIndex = 0;
const questions = questionsData;
const questions = questionsData || {};
const questionKeys = Object.keys(questions);
const delayBetweenQuestions = 800;
const fadeDuration = 300;

if (questionKeys.length === 0) {
console.error("No questions available.");
return;
}

function createBoxes(length) {
const boxesDiv = $("#boxes").empty();
for (let i = 0; i < length; i++) {
Expand All @@ -16,11 +21,6 @@ $(document).ready(function () {
}

function loadQuestion() {
if (currentQuestionIndex >= questionKeys.length) {
showSummary();
return;
}

$("#inputBox").val("");

const currentKey = questionKeys[currentQuestionIndex];
Expand Down Expand Up @@ -91,12 +91,18 @@ $(document).ready(function () {
const correctAnswer = questions[currentKey].translation;

if (input === correctAnswer) {
currentQuestionIndex++;

console.log("当前题目索引:", currentQuestionIndex);
console.log("当前键名:", currentKey);
Sentry.captureMessage(`Quiz, ${currentQuestionIndex}`);

setTimeout(() => {
currentQuestionIndex++;
console.log("当前题目索引:", currentQuestionIndex);
console.log("当前键名:", currentKey);
Sentry.captureMessage(`Quiz, ${currentQuestionIndex}`);
loadQuestion();
if (currentQuestionIndex < questionKeys.length) {
loadQuestion();
} else {
showSummary();
}
}, delayBetweenQuestions);
}
});
Expand Down

0 comments on commit 0f4462b

Please sign in to comment.