Skip to content

SAK-52547 Assignments preserve Gradebook category on import - #14607

Merged
ottenhoff merged 3 commits into
sakaiproject:masterfrom
ottenhoff:SAK-52547-c
May 19, 2026
Merged

SAK-52547 Assignments preserve Gradebook category on import#14607
ottenhoff merged 3 commits into
sakaiproject:masterfrom
ottenhoff:SAK-52547-c

Conversation

@ottenhoff

@ottenhoff ottenhoff commented May 18, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Improved import/copy behavior so draft and imported assignments preserve, remap, or remove gradebook category associations correctly when gradebook integration or source category origins vary.
  • Tests

    • Added tests covering draft import/copy scenarios with external gradebook categories to prevent regressions and validate category mapping/removal logic.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dd706582-9ec8-44f0-ac76-4ed776438178

📥 Commits

Reviewing files that changed from the base of the PR and between e898810 and 4b67404.

📒 Files selected for processing (1)
  • assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java

Walkthrough

Adds a new public constant NEW_ASSIGNMENT_CATEGORY and implements logic in transferCopyEntities to remap or create destination gradebook categories from source category IDs when importing assignments; includes tests covering draft assignment category storage, remapping to destination IDs, and removal when integration is disabled.

Changes

Assignment Category Remapping During Transfer/Import

Layer / File(s) Summary
NEW_ASSIGNMENT_CATEGORY constant definition
assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentConstants.java
Public constant NEW_ASSIGNMENT_CATEGORY with value "new_assignment_category" is added.
Category remapping during assignment transfer/import
assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java
transferCopyEntities now conditionally remaps NEW_ASSIGNMENT_CATEGORY when NEW_ASSIGNMENT_ADD_TO_GRADEBOOK is GRADEBOOK_INTEGRATION_ADD, handles draft external-assessment cases by setting/clearing related props, and adds private helpers to parse source category IDs, resolve/create destination categories, and update or remove the property.
Test coverage for category remapping transfer
assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentTransferCopyEntitiesTest.java
Adds GradingService imports and injection, three new tests verifying destination-category storage for imported drafts, remapping of NEW_ASSIGNMENT_CATEGORY to destination IDs, and removal when destination integration is "no", plus a stubCategoryImport(...) helper to stub grading/category data.

Possibly related PRs

  • sakaiproject/sakai#13968: Also touches the NEW_ASSIGNMENT_CATEGORY draft property—this PR remaps it during transfer/import while #13968 persists/restores it in save/edit flows.
  • sakaiproject/sakai#14538: Modifies transferCopyEntities gradebook-integration handling and related assignment-gradebook properties; both PRs alter adjacent transfer/import wiring.
  • sakaiproject/sakai#14589: Parses and clears/uses NEW_ASSIGNMENT_CATEGORY during publish flows; related to how the property is handled end-to-end.

Suggested reviewers

  • ern
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding functionality to preserve Gradebook category properties during assignment import operations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.2)
assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java`:
- Around line 4707-4711: The category remapping
(remapImportedAssignmentCategoryProperty) runs too early using
assignmentAddToGradebookChoice; remove that early call and instead perform the
remap (or removal of NEW_ASSIGNMENT_CATEGORY from nProperties) after the code
that finalizes NEW_ASSIGNMENT_ADD_TO_GRADEBOOK (the switch/logic that can change
ADD→ASSOCIATE/NO). Concretely: delete the current invocation that uses
fromContext/toContext at the top, and add a conditional after the final
gradebook-mode decision that calls
remapImportedAssignmentCategoryProperty(nProperties, fromContext, toContext)
only when NEW_ASSIGNMENT_ADD_TO_GRADEBOOK == GRADEBOOK_INTEGRATION_ADD,
otherwise ensure nProperties.remove(NEW_ASSIGNMENT_CATEGORY) is executed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1d41ea41-0c90-4dfd-934b-b3f39dc302ba

📥 Commits

Reviewing files that changed from the base of the PR and between 1d3fc59 and cd9d182.

📒 Files selected for processing (3)
  • assignment/api/src/java/org/sakaiproject/assignment/api/AssignmentConstants.java
  • assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java
  • assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentTransferCopyEntitiesTest.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java`:
- Around line 5689-5694: The code calls
gradingService.getCategoryDefinitions(fromGradebookId, fromGradebookId).stream()
which can return null and throw NPE; in AssignmentServiceImpl locate the
sourceCategory creation (variable sourceCategory) and first retrieve the list
into a local variable (e.g., categoryDefs) or wrap the call with
Optional.ofNullable, guard against null before streaming/filtering, and if null
treat it as empty collection so the subsequent Optional logic returns
Optional.empty() rather than throwing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1c428aa5-bb0b-4abd-83e7-8f243c6b27b5

📥 Commits

Reviewing files that changed from the base of the PR and between cd9d182 and e898810.

📒 Files selected for processing (2)
  • assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java
  • assignment/impl/src/test/org/sakaiproject/assignment/impl/AssignmentTransferCopyEntitiesTest.java

@ottenhoff
ottenhoff merged commit d5a2583 into sakaiproject:master May 19, 2026
4 checks passed
ern pushed a commit that referenced this pull request May 28, 2026
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.

1 participant