Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for archiving a submission #2411

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

int-y1
Copy link
Contributor

@int-y1 int-y1 commented Mar 2, 2025

fixes #1767

an admin needs judge.archive_submission to archive submissions. there are 2 ways to archive a submission:

  1. go to /problem/<code>/manage/submission, turn on "Archive locked submissions", and click "Rejudge selected submissions"
    • my approach is to include locked submissions in the query, and then let Submissions.judge set is_archived to true
  2. go to /admin/judge/submission/<code>/change/ and toggle "Is archived"

user-facing changes when a submission is archived:

  • during point recalculation (e.g. /admin/judge/profile/ > Action > Recalculate scores): submission is not considered when recalculating points, problems solved, and pp
  • /user/<name>/solved: submission no longer appears in "Points breakdown" and in the problems solved table
  • /problem/<code>/rank/: submission no longer appears as a best solution
  • /submissions/ and /problem/<code>/submissions/: submission becomes partly transparent and gets an archive icon. see screenshot.

Screenshot 2025-03-02 171710

there are no admin-facing changes when a submission is archived

@codecov-commenter
Copy link

codecov-commenter commented Mar 2, 2025

Codecov Report

Attention: Patch coverage is 47.50000% with 21 lines in your changes missing coverage. Please review.

Project coverage is 47.71%. Comparing base (fd7fb05) to head (3e796de).
Report is 69 commits behind head on master.

Files with missing lines Patch % Lines
judge/signals.py 37.50% 5 Missing ⚠️
judge/tasks/submission.py 33.33% 4 Missing ⚠️
judge/views/problem_manage.py 42.85% 4 Missing ⚠️
judge/models/submission.py 25.00% 3 Missing ⚠️
judge/admin/submission.py 33.33% 2 Missing ⚠️
judge/models/profile.py 0.00% 1 Missing ⚠️
judge/utils/problems.py 0.00% 1 Missing ⚠️
judge/views/user.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2411      +/-   ##
==========================================
+ Coverage   46.76%   47.71%   +0.95%     
==========================================
  Files         251      260       +9     
  Lines       13317    13747     +430     
==========================================
+ Hits         6228     6560     +332     
- Misses       7089     7187      +98     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@int-y1 int-y1 force-pushed the sub-quarantine branch 2 times, most recently from ef08bbc to 0c16d2d Compare March 2, 2025 10:44
@int-y1 int-y1 marked this pull request as ready for review March 2, 2025 11:35
@int-y1 int-y1 force-pushed the sub-quarantine branch 2 times, most recently from 4307253 to 89cdf39 Compare March 3, 2025 00:36
@int-y1 int-y1 changed the title Add field to quarantine a submission Add support for archiving a submission Mar 3, 2025
@int-y1 int-y1 force-pushed the sub-quarantine branch 2 times, most recently from 9f55d23 to 553f75e Compare March 3, 2025 01:17
@Riolku
Copy link
Contributor

Riolku commented Mar 3, 2025

Overall ty for working on this, it looks great :)

'verbose_name': 'submission',
'verbose_name_plural': 'submissions',
},
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Err, what does this part of the migration do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is needed so that the permission archive_submission appears under /admin/auth/user/<id>/change/ > Available user permissions

@int-y1 int-y1 force-pushed the sub-quarantine branch 2 times, most recently from 6142a3d to 692f0f3 Compare March 3, 2025 07:47
@int-y1 int-y1 requested review from kiritofeng and Riolku March 3, 2025 07:56
Copy link
Member

@Ninjaclasher Ninjaclasher left a comment

Choose a reason for hiding this comment

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

It would be nice if, in the places where we currently show locked instead of Rejudge, we give the option of Archive. Off the top of my head, this is currently in judge/admin/submission.py's judge_column, the submission row (templates/submission/row.html), and submission status/source (templates/submission/(status|source).html).

This would match the behaviour in other places (e.g. contest problem rejudge) where there is no check for is_locked and thus we go to Submission.judge and automatically archive.

Otherwise LGTM.

@int-y1
Copy link
Contributor Author

int-y1 commented Mar 4, 2025

  • allow access to "Archive locked submissions". don't put this behind the "judge.archive_submission" permission.
  • add is_archived=False to more queries

@int-y1 int-y1 force-pushed the sub-quarantine branch 2 times, most recently from b49ce8e to a2dbc14 Compare March 4, 2025 06:00
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.

Quarantining Submission
5 participants