Skip to content

Add submission invalidation#1534

Open
reppuli92 wants to merge 1 commit into
apluslms:masterfrom
reppuli92:invalidate-submission
Open

Add submission invalidation#1534
reppuli92 wants to merge 1 commit into
apluslms:masterfrom
reppuli92:invalidate-submission

Conversation

@reppuli92

Copy link
Copy Markdown
Contributor

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?

  • Accessibility test using the WAVE extension.
  • Django unit tests.
  • Playwright tests.
  • Other test. (Add a description below)
  • Manual testing.

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

  • Chrome
  • Firefox
  • This pull request cannot be tested in the browser.

Think of what is affected by these changes and could become broken

Translation

Programming style

  • Did you follow our style guides?
  • Did you use Python type hinting in all functions that you added or edited? (type hints for function parameters and return values)

Have you updated the README or other relevant documentation?

  • documents inside the doc directory.
  • README.md.
  • Aplus Manual.
  • Other documentation (mention below which documentation).

Is it Done?

  • Reviewer has finished the code review
  • After the review, the developer has made changes accordingly
  • Customer/Teacher has accepted the implementation of the feature

Clean up your git commit history before submitting the pull request!

@ihalaij1
ihalaij1 requested a review from Copilot July 17, 2026 06:50
@ihalaij1 ihalaij1 self-assigned this Jul 17, 2026
@ihalaij1 ihalaij1 moved this from Todo to Under review in A+ sprints Jul 17, 2026

Copilot AI 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.

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 Submission status with INVALIDATED and 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.

Comment thread exercise/templates/exercise/staff/_assessment_panel.html Outdated
Comment thread locale/en/LC_MESSAGES/django.po
Comment thread locale/fi/LC_MESSAGES/django.po

Copilot AI 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.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Comment on lines 46 to 50
return self.exclude(status__in=(
Submission.STATUS.ERROR,
Submission.STATUS.REJECTED,
Submission.STATUS.INVALIDATED,
))
Comment on lines 286 to 290
return self.exclude(status__in=(
Submission.STATUS.ERROR,
Submission.STATUS.REJECTED,
Submission.STATUS.INVALIDATED,
))
Comment thread locale/en/LC_MESSAGES/django.po Outdated
Comment thread locale/en/LC_MESSAGES/django.po Outdated
@ihalaij1
ihalaij1 force-pushed the invalidate-submission branch from 5935fe5 to 42a08b4 Compare July 17, 2026 09:18
@ihalaij1

Copy link
Copy Markdown
Contributor

We should figure out if we want to remove the invalidated status from exclude_errors() and make a separate exclude_invalidated() method. The main concern is if invalidating a submission should refund a submission attempt to the student.

The following explains the ramifications of keeping the new invalidated status in exclude_errors() (from Copilot):

INVALIDATED should be included only if an invalidated submission is meant to be treated as a non-counting attempt. It is not technically an error, and adding it to exclude_errors() has wider effects than just hiding it from results.

In the current code, it affects:

  • get_submissions_for_student(..., exclude_errors=True): invalidated submissions disappear.
  • Submission limits in one_has_submissions() and no_submissions_left(): an invalidated attempt does not consume a submission slot, so the student may submit again.
  • ordinal_number(): invalidated submissions are not counted when generating the attempt number sent to the grader.
  • Batch approval: invalidated submissions are excluded from the submissions eligible for approval.
  • Any future caller of exclude_errors(): it will silently treat invalidation like a grader error or rejected submission.

It does not affect callers that use the default get_submissions_for_student() or query Submission directly. The CSV/API result queries already explicitly exclude INVALIDATED independently.

I would avoid putting it in exclude_errors() because the name is now misleading. Prefer separate semantics:

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 INVALIDATED in a separately named “non-counting submissions” filter. If invalidation is disciplinary and must still consume the attempt limit, it should not be part of the filter used by submission-limit calculations. The relevant shared filter is in submission_models.py, and the limit logic is in exercise_models.py.

@ihalaij1
ihalaij1 self-requested a review July 17, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Under review

Development

Successfully merging this pull request may close these issues.

Invalidating a graded submission

3 participants