Skip to content

feat: stickers v2 & my submission overview#63

Open
FelyCZ wants to merge 31 commits into
masterfrom
feat/stickers-improvement-stacked
Open

feat: stickers v2 & my submission overview#63
FelyCZ wants to merge 31 commits into
masterfrom
feat/stickers-improvement-stacked

Conversation

@FelyCZ

@FelyCZ FelyCZ commented Mar 5, 2026

Copy link
Copy Markdown
Member

Objective

This PR introduces the ability to limit sticker assignments (e.g., "Once per grade" or "Once in a lifetime") and adds a new "My Submissions" overview page for participants. It also includes several optimizations for the sticker engine and ranking calculations, as well as minor bug fixes and dependency updates.

Key Features & Changes

1. Sticker Assignment Limits

  • Model Updates:
    • Added assignment_limit field to the Sticker model with choices: UNLIMITED, ONCE_PER_GRADE, and ONCE_IN_LIFETIME.
    • Refactored sticker-to-submission relationships by moving away from a simple M2M field (TaskSolutionSubmission.stickers) to explicit StickerAssignment tracking.
    • Added database-level constraints on StickerAssignment to enforce uniqueness per series/submission/event based on the context.
  • Scoring Form Overhaul:
    • Optimized ScoringForm by replacing ModelMultipleChoiceField with a TypedMultipleChoiceField to eliminate N+1 query problems during validation.
    • Customized the save() method in ScoringForm to correctly create/update StickerAssignment instances with the proper series and timing context.
  • Sticker Engine Optimization:
    • Optimized _grade_details in ksicht/core/stickers/engine.py to pre-calculate max scores and group queries in-memory for bulk processing.
  • Fixtures: Updated fixtures/stickers.json to assign limits to all existing stickers (e.g., "Poslední zvonění" is now once_in_lifetime, "Řešitel" is once_per_grade). This need further review later.

2. My Submissions View

  • Introduced a new user-facing "My Submissions" overview page to allow participants to easily see all their submitted solutions and scores.
  • Added URLs, views (ksicht/core/views/submissions.py), and a new template (my_submissions.html).
  • Aded a "My Submissions" button within the current grade view.
  • Combines feat(submissions): all submissions overview #56

3. UI/UX & Bug Fixes

  • Stickers Styling: Improved sticker table spacing, tag layout, and outline borders in stickers.scss.
  • Scoring View & Submissions View: Bottom bar with saving button made sticky.

Testing & Verification

  • Added/updated test cases for the new sticker assignment logic and limits:
    • tests/test_core/test_sticker_assignment_limit.py
    • tests/test_core/test_sticker_services.py

Usage/Deployment Notes

  • This PR includes data model migrations for Sticker and StickerAssignment. You will need to run python manage.py migrate after checkout.
  • The fixtures/stickers.json has been modified; consider reloading fixtures if testing on a fresh database.

FelyCZ added 14 commits March 2, 2026 01:15
	modified:   assets/sass/components/stickers.scss
	new file:   ksicht/core/sticker_utils.py
	modified:   ksicht/core/stickers/engine.py
	new file:   ksicht/core/stickers/services.py
	modified:   ksicht/core/templates/core/includes/sticker.html
	modified:   ksicht/core/templates/core/manage/series_detail.html
	modified:   ksicht/core/templates/core/manage/sticker_assignment_overview.html
	modified:   ksicht/core/templatetags/stickers.py
	modified:   ksicht/core/views/series.py
	new file:   tests/test_core/test_sticker_assignment_limit.py
	new file:   tests/test_core/test_sticker_services.py
	modified:   ksicht/core/models.py
FelyCZ added 11 commits March 5, 2026 02:53
	modified:   assets/sass/components/stickers.scss
	new file:   ksicht/core/sticker_utils.py
	modified:   ksicht/core/stickers/engine.py
	new file:   ksicht/core/stickers/services.py
	modified:   ksicht/core/templates/core/includes/sticker.html
	modified:   ksicht/core/templates/core/manage/series_detail.html
	modified:   ksicht/core/templates/core/manage/sticker_assignment_overview.html
	modified:   ksicht/core/templatetags/stickers.py
	modified:   ksicht/core/views/series.py
	new file:   tests/test_core/test_sticker_assignment_limit.py
	new file:   tests/test_core/test_sticker_services.py
	modified:   ksicht/core/models.py
…-org/ksicht into feat/stickers-improvement-stacked
@FelyCZ FelyCZ linked an issue Mar 5, 2026 that may be closed by this pull request

@antivirak antivirak left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not test the changes, did not go into deep details, just some minor suggestions

Comment thread ksicht/core/views/submissions.py Outdated
Comment thread ksicht/core/sticker_utils.py Outdated
Comment thread ksicht/core/sticker_utils.py Outdated
Comment thread ksicht/core/views/series.py Outdated
Comment thread ksicht/core/stickers/services.py Outdated
Comment thread ksicht/core/stickers/engine.py Outdated
Comment thread ksicht/core/stickers/engine.py
Comment thread ksicht/core/views/series.py Outdated
@FelyCZ

FelyCZ commented Mar 19, 2026

Copy link
Copy Markdown
Member Author

Many thanks for the review, @antivirak!
I will take a look at the comments once I finish some other projects.

Comment thread ksicht/core/stickers/services.py
Comment thread ksicht/core/views/submissions.py Outdated
}

# Fetch all assignments for this participant
all_assignments = list(StickerAssignment.objects.filter(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This query can be moved up outside of the for loop - participant is not dependent on current application iteration

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.

Stickers Enhancement

2 participants