-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem / context
In Drill and Practice Modes, Monaco-powered solutions are persisted in localStorage so a user doesn’t lose work between attempts.
However, when a user solves a challenge (CORRECT or ACCEPTABLE), this persistence becomes counterproductive:
- The correct answer remains stored, causing the next appearance to autofill the editor with the solved solution.
- This undermines spaced repetition, removes difficulty, and encourages skipping.
- Clearing manually is possible but breaks flow and isn’t intuitive.
We need a mechanism to automatically clear the saved attempt when the user successfully solves a challenge.
Proposed solution
When a submission receives an Outcome of CORRECT or ACCEPTABLE, the client should:
-
Identify the relevant storage key:
cf.challenge.{id}.code
-
Immediately delete it before or after redirecting back to the next drill, depending on UX.
-
Ensure the editor loads only the default template next time.
Implementation Options (any are acceptable):
Option A — Clear via JSP-rendered Inline Script
Server detects a correct outcome and injects:
<script>
localStorage.removeItem('cf.challenge.${challenge.id}.code');
</script>Option B — Clear Inside the Submission Script
Modify the client-side JS in drill/solve.jsp (and practice/solve.jsp?):
if (['CORRECT', 'ACCEPTABLE'].includes('${outcome}')) {
localStorage.removeItem(storageKey);
}Option C — Hybrid
Server sets a flag → JS reads flag → clears storage.
Expected Behavior
After solving a challenge, the next time it appears in the drill queue, the editor is empty or template-filled, NOT showing the past correct solution.
Users cannot accidentally “cheat themselves” using leftover saved code.
In scope / Out of scope
In scope:
- Automatically clearing the localStorage entry cf.challenge.{id}.code when a submission receives an ACCEPTABLE or CORRECT outcome.
- Updating client-side logic in Drill (And Practice?) Mode to prevent solved answers from reappearing on the next repetition.
- Injecting or using server-side flags to trigger a one-time client-side storage clear.
- Ensuring Monaco → hidden input synchronization continues to work normally after the storage reset.
- Keeping incorrect or failed attempts fully persistent as they are today.
Out of scope:
- Changing evaluation logic, streak logic, or spaced-repetition scheduling.
- Adding new UI components or modifying the existing editor layout.
- Synchronizing code storage across devices or accounts.
- Server-side storage of user submissions (beyond what already exists in the app).
Acceptance criteria
- Correct/Acceptable outcomes remove the saved code entirely
- Reloading /drill/{id}/solve no longer restores a solved answer
- No changes to incorrect submission behavior
- No regression in Monaco → hidden synchronization
- Works for both MVP Drill Mode and future languages
Area
area:ui/ux
Dependencies / related issues
No response
Checklist
- I’ve checked existing issues for duplicates.
- I can help implement this and open a PR.
Metadata
Metadata
Assignees
Labels
Projects
Status