Fix: save sections and widgets when saving homework as draft#107
Merged
Conversation
eac2a31 to
caa3a6b
Compare
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.
caa3a6b to
94b332f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Fixes the issue where teachers lose exercises when saving a homework as draft.