feat: reorder reusable annotations within an annotation category - #8184
Merged
david-yz-liu merged 6 commits intoOct 2, 2026
Merged
david-yz-liu merged 6 commits into
david-yz-liu merged 6 commits into
Conversation
…tegory Adds a nullable `position` column to `annotation_texts` (left null for one-time annotations and existing annotation texts). Instructors and graders with the manage assessments permission can drag and drop the annotations in an annotation category on the assignment Annotations tab, and graders see them in that order in the grading view. Annotation texts without a position are listed last, in creation order. Closes MarkUsProject#7778 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Coverage Report for CI Build 36943506191Coverage increased (+0.02%) to 90.843%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Collaborator
Coverage Report for CI Build 36289784112Coverage decreased (-0.001%) to 90.808%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
david-yz-liu
left a comment
Collaborator
There was a problem hiding this comment.
Nice work, @YheChen! In addition to my inline comments, here are a few general comments (largely in response to your questions):
- In general let's update the codebase to assign position values when new annotation texts are created. I think for backwards compatibility we want to assign position values to all annotation texts within a category when a new annotation text for that category is created.
- In a similar vein, please assign positions when creating/updating categories by annotation upload. We can go with the order in which the annotation texts appear in the upload (overriding any old positions as needed).
- When an annotation text is moved between categories, let's compute a new position for it (after all existing annotation texts)
- The UI for creating a new annotation is a bit awkward as you've described, but I think it's okay for now. We might refresh the UI later.
- New annotation texts (including uploaded ones and those added through the API) and annotation texts moved to another category are placed after the existing annotation texts in their category; existing annotation texts without a position are given one first - Validated that positions are at least 1 and unique within a category - Changed the reorder route to PATCH, saved positions with upsert_all, and rejected requests that don't list each of the category's annotation texts exactly once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
david-yz-liu
approved these changes
Oct 2, 2026
david-yz-liu
left a comment
Collaborator
There was a problem hiding this comment.
Nice work, @YheChen!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Closes #7778.
Instructors (and graders with the "manage assessments" permission) can now reorder the reusable annotations within an annotation category from the assignment's Annotations tab, by dragging the handle next to each annotation, the same way annotation categories are already reordered. Graders see a category's annotations in this order in its drop-down menu in the grading view.
Changes after review
positionis validated to be at least 1 and unique within an annotation category.PATCHinstead ofPOST, saves the positions with a singleupsert_all, and rejects requests that don't list each of the category's annotation texts exactly once (responding with 400 and an error message), so the saved positions are always consecutive and without duplicates.Implementation notes
AnnotationTexthas a new nullablepositioncolumn, which must be an integer that is at least 1 and unique within an annotation category. It isNULLfor one-time only annotations, and for existing annotation texts until their category is reordered or gets a new annotation text.AnnotationCategory#annotation_textsis ordered byposition, id, so annotation texts without a position are listed after positioned ones, in creation order (PostgreSQL sortsNULLs last).AnnotationCategory#annotation_textsassociation (used by the grading view and the annotation CSV/YAML downloads) and in the Annotations tab's query, which previously listed a category's annotations by their creator's user name.PATCH update_annotation_text_positionsmember route on annotation categories uses the existingmanage?rule. It expects the ids of all of the category's annotation texts, each exactly once, in their new order, and otherwise responds with 400 and an error message (e.g. if an annotation was added in another tab). The positions are saved with a singleupsert_all, which skips theAnnotationTextcallbacks, so annotations that have been applied to released results can still be reordered (their order isn't visible to students).#annotation_category_pane_listinstead of.sortable ul, since the annotation list is now also.sortableand its annotations may contain Markdown lists.startcallback.Screenshots of your changes (if applicable)
Type of Change
Checklist
Before opening your pull request:
After opening your pull request:
Questions and Comments