Skip to content

Auto-clear saved code in Drill Mode when a submission is CORRECT or ACCEPTABLE #70

@ArchILLtect

Description

@ArchILLtect

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:

  1. Identify the relevant storage key:

    • cf.challenge.{id}.code
  2. Immediately delete it before or after redirecting back to the next drill, depending on UX.

  3. 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

No one assigned

    Labels

    area:ui/uxUI layout, styling, accessibility, and UX flows (client-side behavior and visual polish).area:webControllers, JSP/JSTL, view models, and UI wiring.enhancementNew feature or requestfeature:drill-modeDrill queue, scheduling (nextDueAt), streak/timesSeen, and related UI.feature:practice-modePractice flow, challenge prompts, and basic submission behavior.post-mvpUse for all issues/PRs that do not belong to the MVP release. Will be implement post-MVP.priority:P2-normalNormal priority; plan within the current milestone.status:triageNewly filed or uncategorized. Needs initial review, labeling, and priority assignment.

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions