Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion math/grade4/division-remainders.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,21 @@ <h1 style="color: var(--lab-blue);">Remainder Master!</h1>
let currentQ = { q: 0, r: 0 };

auth.onAuthStateChanged(user => {
if (user) { currentUser = user; syncProgress(); }
if (user) {
currentUser = user;
syncProgress();
} else {
currentUser = null;
stepsCompleted = {
step_0: false,
step_1: false,
step_2: false,
step_3: false,
step_4: false,
step_5: false
};
updateSidebar();
}
Comment on lines +167 to +178
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When the user logs out, the application resets currentUser and stepsCompleted, but it does not reset the current lesson progress (practiceCount) or the UI view (currentStep). This can leave the user on a restricted practice page in an unauthenticated state. Calling showPage(0) will reset the view to the introduction and internally trigger updateSidebar(), ensuring a consistent state.

Suggested change
} else {
currentUser = null;
stepsCompleted = {
step_0: false,
step_1: false,
step_2: false,
step_3: false,
step_4: false,
step_5: false
};
updateSidebar();
}
} else {
currentUser = null;
stepsCompleted = {
step_0: false,
step_1: false,
step_2: false,
step_3: false,
step_4: false,
step_5: false
};
practiceCount = 0;
showPage(0);
}

});

async function syncProgress() {
Expand Down Expand Up @@ -244,6 +258,12 @@ <h1 style="color: var(--lab-blue);">Remainder Master!</h1>
const userR = parseInt(document.getElementById('r-input').value);
const fb = document.getElementById('feedback');

if (Number.isNaN(userQ) || Number.isNaN(userR)) {
fb.style.color = "#d63031";
fb.textContent = "Please enter numbers for both quotient and remainder.";
return;
}

if(userQ === currentQ.q && userR === currentQ.r) {
fb.style.color = "var(--success)";
fb.textContent = "Perfectly balanced! ✔️";
Expand Down
Loading