Add submission invalidation#1534
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new “invalidated” submission status that course teachers can toggle to exclude selected submissions from point totals and related reporting, addressing the “invalidate graded submission” request in #1479.
Changes:
- Extends
Submissionstatus withINVALIDATEDand updates relevant queryset/export/reporting filters to exclude invalidated submissions. - Adds teacher-only staff endpoints to invalidate/revalidate a submission and exposes corresponding buttons in the staff submission inspection UI.
- Adds migration and UI/status translations (en/fi) for the new status and buttons.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| locale/fi/LC_MESSAGES/django.po | Adds Finnish translations for new status + UI strings (needs additional staff flash message translations). |
| locale/en/LC_MESSAGES/django.po | Adds English translations for new status + UI strings (needs additional staff flash message translations). |
| exercise/urls.py | Registers new invalidate/revalidate staff endpoints for submissions. |
| exercise/tests.py | Adds unit test coverage for invalidate/revalidate permissions and status transitions. |
| exercise/templates/exercise/staff/_assessment_panel.html | Adds teacher-only invalidate/revalidate buttons in the staff assessment panel. |
| exercise/submission_models.py | Introduces INVALIDATED status and setters; excludes invalidated from exclude_errors() filtering. |
| exercise/staff_views.py | Adds teacher-only POST views to invalidate/revalidate submissions with user feedback messages. |
| exercise/migrations/0052_alter_submission_status.py | Alters DB field choices to include invalidated. |
| exercise/management/commands/export_submissions.py | Excludes invalidated submissions from the export query. |
| exercise/api/csv/views.py | Excludes invalidated submissions from CSV aggregation/counting logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
84b9f97 to
5935fe5
Compare
| return self.exclude(status__in=( | ||
| Submission.STATUS.ERROR, | ||
| Submission.STATUS.REJECTED, | ||
| Submission.STATUS.INVALIDATED, | ||
| )) |
| return self.exclude(status__in=( | ||
| Submission.STATUS.ERROR, | ||
| Submission.STATUS.REJECTED, | ||
| Submission.STATUS.INVALIDATED, | ||
| )) |
5935fe5 to
42a08b4
Compare
|
We should figure out if we want to remove the invalidated status from The following explains the ramifications of keeping the new invalidated status in
In the current code, it affects:
It does not affect callers that use the default I would avoid putting it in def exclude_errors(self):
return self.exclude(status__in=(
Submission.STATUS.ERROR,
Submission.STATUS.REJECTED,
))
def exclude_invalidated(self):
return self.exclude(status=Submission.STATUS.INVALIDATED)Then use both filters where appropriate. If the intended rule is that invalidation voids the attempt and permits a replacement submission, keep |
Description
What?
Add a new 'invalidated' status for submissions. Teachers can manually set this status, and invalidated submissions do not count towards point totals.
Why?
This was requested by teachers, as it is useful for e.g. invalidating AI submissions.
How?
Updated the submission database schema to include the new status. This includes a Django migration.
Also created two new API endpoints to invalidate the submission from status Ready and re-validate the submission back to status Ready. These endpoints are only accessible by teachers and only work if the submission status is initially Ready or Invalidated (respectively.
Also created buttons in the Inspect submission view where this endpoint can be accessed. The buttons also only show if the user is a teacher and the submission has correct status.
Fixes #1479
Testing
Remember to add or update unit tests for new features and changes.
What type of test did you run?
Added a couple new unit tests for the invalidations. Also tested in the UI that invalidation and re-validation works and affects the points totals correctly.
Did you test the changes in
Think of what is affected by these changes and could become broken
Translation
Programming style
Have you updated the README or other relevant documentation?
Is it Done?
Clean up your git commit history before submitting the pull request!