Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 1, 2025

When creating a new submission, starting files were being copied incorrectly. The code was using substr(1) to remove the first character from all starting file names, assuming they all had special prefixes like ^. However, some starting files are meant to be regular files without prefixes.

This caused issues where regular files like helper_functions.py would be corrupted to elper_functions.py in the student workspace.

Changes Made

  • Modified src/blockpy.js to import the existing chompSpecialFile function from files.js
  • Replaced file.filename().substr(1) with chompSpecialFile(file.filename()) in the file reset logic
  • The chompSpecialFile function correctly handles both cases:
    • Files with special prefixes (!^?&$*#) have their prefix removed
    • Regular files without prefixes are preserved unchanged

Before and After

Before (broken):

// Always removes first character
let filename = file.filename().substr(1);
// "^starting_code.py" → "starting_code.py" ✓ 
// "helper_functions.py" → "elper_functions.py" ✗

After (fixed):

// Only removes special prefixes
let filename = chompSpecialFile(file.filename());
// "^starting_code.py" → "starting_code.py" ✓
// "helper_functions.py" → "helper_functions.py" ✓

The fix ensures that starting files are properly copied to the student workspace with correct filenames, resolving the issue where files prepended with ^ appeared verbatim in the student space when they should have been processed appropriately.

Fixes #105.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Copilot AI changed the title [WIP] Starting files doesn't work Fix starting files copying to preserve filenames without special prefixes Sep 1, 2025
Copilot AI requested a review from acbart September 1, 2025 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Starting files doesn't work

2 participants