## [Bug] Code Reset After Submission in Python Playground #155

Closed
opened 2026-05-17 22:11:55 +00:00 by enjin2310 · 1 comment

Classification

Type: Bug
Priority: Medium
Component: Python Playground / Lesson Persistence

Summary

In the Python Playground, submitting code causes the editor to reset, erasing the user’s written solution. This behavior differs from other playgrounds (e.g., JavaScript, C++) where the code remains visible after submission—whether the result is a pass or fail—allowing users to review and learn from their attempts.

Steps to Reproduce

  1. Navigate to learn.spikersoft.com/tools/python-playground.
  2. Open Lesson 20101 – Greet a Target.
  3. Write any valid code (e.g., return f"Salutations, {name}!").
  4. Click Submit.
  5. Observe that the code editor resets to its initial state with only the placeholder pass.

Expected Behavior

  • After submission, the code should remain in the editor regardless of test results.
  • Users should be able to review, modify, and learn from their previous code attempts.
  • The playground should preserve the last submitted code until the user manually resets or starts a new attempt.

Actual Behavior

  • The code editor resets automatically after submission.
  • The user’s written code disappears, replaced by the default template.
  • This prevents users from analyzing their mistakes or reviewing successful solutions.

Evidence

The attached screenshots show the Python Playground before and after submission:

  • Before: user code visible (return f"Salutations, {name}!").
  • After: editor reset to pass.

Environment

  • Browser: Microsoft Edge
  • OS: Windows 10
  • Lesson ID: 20101
  • Version: v2026.05.17a

Possible Root Cause

  • The submission handler may trigger a full lesson reload instead of preserving the editor state.
  • Missing local storage or session persistence for code data.
  • Incorrect post-submission callback resetting the editor.

Suggested Fix

  • Implement code persistence after submission (store last attempt in session or local storage).
  • Prevent automatic editor reset unless the user explicitly clicks “New attempt.”
  • Align behavior with other playgrounds for consistency across languages.

Additional Notes

This issue disrupts the learning flow by removing user progress and feedback context, reducing the effectiveness of interactive coding lessons.

### Classification **Type:** Bug **Priority:** Medium **Component:** Python Playground / Lesson Persistence ### Summary In the **Python Playground**, submitting code causes the editor to reset, erasing the user’s written solution. This behavior differs from other playgrounds (e.g., JavaScript, C++) where the code remains visible after submission—whether the result is a pass or fail—allowing users to review and learn from their attempts. ### Steps to Reproduce 1. Navigate to [learn.spikersoft.com/tools/python-playground](https://learn.spikersoft.com/tools/python-playground). 2. Open **Lesson 20101 – Greet a Target**. 3. Write any valid code (e.g., `return f"Salutations, {name}!"`). 4. Click **Submit**. 5. Observe that the code editor resets to its initial state with only the placeholder `pass`. ### Expected Behavior - After submission, the code should remain in the editor regardless of test results. - Users should be able to review, modify, and learn from their previous code attempts. - The playground should preserve the last submitted code until the user manually resets or starts a new attempt. ### Actual Behavior - The code editor resets automatically after submission. - The user’s written code disappears, replaced by the default template. - This prevents users from analyzing their mistakes or reviewing successful solutions. ### Evidence The attached screenshots show the **Python Playground** before and after submission: - Before: user code visible (`return f"Salutations, {name}!"`). - After: editor reset to `pass`. ### Environment - **Browser:** Microsoft Edge - **OS:** Windows 10 - **Lesson ID:** 20101 - **Version:** v2026.05.17a ### Possible Root Cause - The submission handler may trigger a full lesson reload instead of preserving the editor state. - Missing local storage or session persistence for code data. - Incorrect post-submission callback resetting the editor. ### Suggested Fix - Implement code persistence after submission (store last attempt in session or local storage). - Prevent automatic editor reset unless the user explicitly clicks “New attempt.” - Align behavior with other playgrounds for consistency across languages. ### Additional Notes This issue disrupts the learning flow by removing user progress and feedback context, reducing the effectiveness of interactive coding lessons.
Owner

Root cause found and fixed in spikersoft-angular PR #19.

On a passing submission the runner pre-fetches a fresh attempt (the backend purges the cached attempt after a successful grade, so re-submitting would otherwise fail with "attempt expired"). That pre-fetch was re-seeding the editor with the lesson starter — which for Python is pass — wiping the solution the student just wrote.

The pre-fetch now preserves the editor contents, so your code stays visible after a pass for review. Selecting a different lesson still loads that lesson's starter as expected. Regression test added; will close once PR #19 merges.

Root cause found and fixed in spikersoft-angular PR #19. On a passing submission the runner pre-fetches a fresh attempt (the backend purges the cached attempt after a successful grade, so re-submitting would otherwise fail with "attempt expired"). That pre-fetch was re-seeding the editor with the lesson starter — which for Python is `pass` — wiping the solution the student just wrote. The pre-fetch now preserves the editor contents, so your code stays visible after a pass for review. Selecting a different lesson still loads that lesson's starter as expected. Regression test added; will close once PR #19 merges.
Sign in to join this conversation.