Skip to content

fix: preserve tag filter after toggling assignment status#117

Open
Gasg10 wants to merge 3 commits intodrop-project-edu:v1.0.0-beta.5from
Gasg10:fix/89-tag-filter-lost
Open

fix: preserve tag filter after toggling assignment status#117
Gasg10 wants to merge 3 commits intodrop-project-edu:v1.0.0-beta.5from
Gasg10:fix/89-tag-filter-lost

Conversation

@Gasg10
Copy link
Copy Markdown

@Gasg10 Gasg10 commented Apr 21, 2026

Fixes #89

Problem

When a tag filter was applied in the Current Assignments page and the teacher toggled the Active? checkbox, the tag filter was lost after the redirect. The page returned to the default state showing all assignments.

Root Cause

The toggleAssignmentStatus controller did not receive or preserve the active tag filter. After toggling, it always redirected to /assignment/my without any query parameters, discarding the selected tags.

Fix

Three changes were made:

1. AssignmentController.kt — Added tags as a @RequestParam to toggleAssignmentStatus and used it in the redirect:

fun toggleAssignmentStatus(@PathVariable assignmentId: String,
                           @RequestParam(name = "tags", required = false) tags: String?,
                           ...): String {
    ...
    return if (tags != null) "redirect:/assignment/my?tags=$tags" else "redirect:/assignment/my"
}

2. AssignmentController.kt — Added currentTags to the model in listMyFilteredAssignments:

model["currentTags"] = tags ?: ""

3. teacher-assignments-list.html — Added a hidden input to pass the current tags when the toggle form is submitted:

<form th:action="@{'/assignment/toggle-status/' + ${assignment.id}}" method="post">
    <input type="hidden" name="tags" th:value="${currentTags}"/>
    ...
</form>

Testing

  1. Start the application locally
  2. Log in as teacher
  3. Navigate to Assignments → Current Assignments
  4. Select a tag filter (e.g. kotlin) — only filtered assignments are shown
  5. Toggle the Active? checkbox of an assignment
  6. The tag filter is now preserved after the redirect
image

@Gasg10 Gasg10 changed the base branch from master to v1.0.0-beta.5 April 21, 2026 20:32
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.

Tag filter is lost after activating an assignment

2 participants