Skip to content

feat: add backend support for saving draft submissions#284

Merged
Nabeelahh merged 1 commit into
BlockDash-Studios:mainfrom
edrizxabdulganiyu-blip:feat/draft-submissions
Jun 30, 2026
Merged

feat: add backend support for saving draft submissions#284
Nabeelahh merged 1 commit into
BlockDash-Studios:mainfrom
edrizxabdulganiyu-blip:feat/draft-submissions

Conversation

@edrizxabdulganiyu-blip

Copy link
Copy Markdown
Contributor

feat: Add backend support for saving draft submissions

Summary

Adds a complete draft submission workflow to the submissions module, allowing learners to save
work-in-progress code before formally submitting it for review.

Changes

New status & fields

  • Added DRAFT to SubmissionStatus enum
  • Added isDraft: boolean and draftSavedAt?: Date to SubmissionEntity and ISubmission interface

New DTO

  • SaveDraftDto — accepts taskId, userId (required) and optional content, fileUrl

Service methods

  • saveDraft(dto) — creates a new draft or upserts an existing one for the same userId + taskId
    pair
  • findDraftsByUserId(userId) — returns all drafts for a given user
  • publishDraft(id) — promotes a draft to PENDING, entering the normal review workflow; throws
    400 if the submission is not a draft, 404 if not found

New endpoints

┌────────┬────────────────────┬─────────────┐
│ Method │ Route │ Description │
├────────┼────────────────────┼────────────────────────┤
│ POST │ /submissions/draft │ Save or update a draft │
├────────┼──────────────────────────────────┼────────────────────────────┤
│ GET │ /submissions/user/:userId/drafts │ List all drafts for a user │
├────────┼──────────────────────────────────┼────────────────────────────┤
│ POST │ /submissions/:id/publish │ Publish a draft for review │
└────────┴──────────────────────────────────┴────────────────────────────┘

Tests

  • 19 unit tests covering all three draft service methods (all passing)

How it works

A draft is an upsert — if a draft already exists for the same userId + taskId, calling POST
/submissions/draft again updates the content in-place rather than creating a duplicate.
Publishing transitions the draft to PENDING and clears all draft metadata, so it flows into the
existing tutor/AI review pipeline unchanged.

close #249

- Add DRAFT status to SubmissionStatus enum
- Add isDraft and draftSavedAt fields to SubmissionEntity and ISubmission
- Add SaveDraftDto for create/update draft requests
- Add saveDraft (upsert), findDraftsByUserId, and publishDraft to SubmissionService
- Add POST /submissions/draft, GET /submissions/user/:userId/drafts,
  and POST /submissions/:id/publish endpoints to SubmissionController
- Export SaveDraftDto from submissions index
- Add 19 unit tests covering all draft methods (all passing)
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@edrizxabdulganiyu-blip Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Nabeelahh Nabeelahh merged commit 1a77512 into BlockDash-Studios:main Jun 30, 2026
1 check 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.

Add support for code editor autosave

2 participants