Skip to content

Fix: save sections and widgets when saving homework as draft#107

Merged
siscia merged 1 commit into
mainfrom
fix/draft-save-saves-sections
May 17, 2026
Merged

Fix: save sections and widgets when saving homework as draft#107
siscia merged 1 commit into
mainfrom
fix/draft-save-saves-sections

Conversation

@siscia
Copy link
Copy Markdown
Member

@siscia siscia commented May 17, 2026

The draft save path in HomeworkEditView only persisted the homework metadata (title, description, type) but completely ignored sections and widgets from the POST data. When a teacher wrote exercises and clicked 'Save Draft', the exercises were lost.

Fix: Parse sections and widgets directly from POST data (bypassing formset validation since drafts should be lenient), then delegate to HomeworkService.update_homework() to persist everything.

Tests added:

  • test_save_draft_creates_new_sections — verifies new sections created via draft save
  • test_save_draft_updates_existing_sections — verifies existing sections updated via draft save
  • test_save_draft_deletes_sections — verifies sections deleted via draft save

Fixes the issue where teachers lose exercises when saving a homework as draft.

@siscia siscia force-pushed the fix/draft-save-saves-sections branch from eac2a31 to caa3a6b Compare May 17, 2026 20:49
The draft save path in HomeworkEditView only persisted the homework
metadata fields (title, description, type) but ignored all section
and widget data from the POST request. This meant exercises written
by the teacher were lost when clicking 'Save Draft'.

Now the draft save path parses sections and widgets directly from
POST data (bypassing formset validation), then delegates to
HomeworkService.update_homework() to persist everything.

Added tests for creating, updating, and deleting sections via save_draft.
@siscia siscia force-pushed the fix/draft-save-saves-sections branch from caa3a6b to 94b332f Compare May 17, 2026 20:50
@siscia siscia merged commit bc31ab2 into main May 17, 2026
2 of 3 checks passed
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.

1 participant