Skip to content

Conversation

@kunaljaykam
Copy link
Member

@kunaljaykam kunaljaykam commented Nov 7, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Assignment creation now handles gradebook naming conflicts gracefully: when a name collision occurs the system automatically generates a unique title and retries gradebook integration. If the retry succeeds the assignment is linked; if it fails the assignment is saved as a draft with gradebook integration disabled for manual review. This reduces failed integrations and preserves instructor work.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 7, 2025

Walkthrough

Wraps the call to gradingService.addExternalAssessment in try/catch. On success, preserves existing linking behavior. On ConflictingAssignmentNameException, logs the conflict, generates a unique title via a new private helper, retries adding the external assessment, and on retry failure marks the assignment draft and clears gradebook association. Adds logging around success/failure. The new helper appears duplicated in the diff.

Changes

Cohort / File(s) Summary
External gradebook handling with conflict resolution
assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java
Added try/catch around gradingService.addExternalAssessment to catch ConflictingAssignmentNameException; on conflict, log old/new IDs, call new private helper generateUniqueAssignmentTitle(String originalTitle, String context) to produce a non‑conflicting title and retry; on retry success associate the new gradebook item and log; on retry failure mark assignment as draft, clear/disable gradebook association, update assignment, and log. Note: helper method appears duplicated in the diff.

Suggested reviewers

  • ern
  • jesusmmp

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: implementing unique title generation for assignments to resolve gradebook conflicts (SAK-52134).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.40.0)
assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java (1)

5184-5199: Consider Gradebook names when generating uniques

generateUniqueAssignmentTitle only filters against existing assignment titles. If the Gradebook already has manual items named Foo, Foo-1, etc., we’ll still hit the same ConflictingAssignmentNameException on retry and fall back to disabling integration. Could we extend the uniqueness check to include existing Gradebook item names (via gradingService) so we keep searching until we find a name that actually clears the Gradebook collision?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e059ce9 and 7ca6120.

📒 Files selected for processing (1)
  • assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.java

📄 CodeRabbit inference engine (.cursor/rules/logging-rule.mdc)

**/*.java: Use SLF4J parameterized logging (e.g., logger.info("Value is: {}", value)) instead of string concatenation in log statements
Write log messages and code comments in English; never translate log messages

**/*.java: Java: Never use local variable type inference (var). Always declare explicit types.
When proposing or writing Java code, spell out full types in local variable declarations, for-loops, and try-with-resources.
If Java code uses var, replace it with an explicit type.
Review gate: Treat any PR or suggestion containing Java var as non-compliant; require explicit types before merge.

Files:

  • assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: sakaiproject/sakai PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-07T16:11:33.008Z
Learning: Commit messages should follow: <issue key> <component> <brief description> (e.g., SAK-12345 Assignments add option x)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: maven-build
  • GitHub Check: maven-build
  • GitHub Check: sakai-deploy

@github-actions
Copy link

This PR has been automatically marked as stale due to 10 days of inactivity. It will be closed in 4 days unless there is new activity.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java (2)

4559-4622: Graceful conflict handling looks solid; consider making rename logic gradebook‑aware

Wrapping gradingService.addExternalAssessment in a try/catch for ConflictingAssignmentNameException and then renaming + retrying is a good improvement, and switching to assignmentRepository.merge(nAssignment) in this path avoids the previous double updateAssignment side‑effects.

One behavioural gap: generateUniqueAssignmentTitle currently only checks against existing Assignment titles in the site. If the conflict originates from a gradebook‑only item (a column created directly in Gradebook with no corresponding Assignment), the first retry will still use the same title (because it’s not in the assignment list), leading immediately to the fallback path (draft + GRADEBOOK_INTEGRATION_NO) instead of resolving via a suffixed title. To fully meet the intent of SAK‑52134, you might want to extend the uniqueness check to also include gradebook assignment names in that context (internal + external) via gradingService, so the renamed title is highly likely to be non‑conflicting on the Gradebook side as well.

Additionally, if the retry fails again specifically with another ConflictingAssignmentNameException, we currently do not attempt a second suffix (e.g. -2) but instead disable gradebook integration. That’s acceptable as a safe fallback, but if you expect frequent name clashes, a small loop with a capped number of attempts (probing Gradebook names per candidate) would avoid unnecessarily dropping the link.


5182-5206: Defensively handle null/blank titles in generateUniqueAssignmentTitle

The helper will throw a NullPointerException if originalTitle is ever null (e.g. via bad import data), since uniqueTitle starts as null and the loop concatenates originalTitle + "-" + suffix. While callers should normally guarantee a non‑blank title, a small guard would make this more robust against malformed input:

-    private String generateUniqueAssignmentTitle(String originalTitle, String context) {
-        Collection<Assignment> existingAssignments = getAssignmentsForContext(context);
+    private String generateUniqueAssignmentTitle(String originalTitle, String context) {
+        if (StringUtils.isBlank(originalTitle)) {
+            return originalTitle;
+        }
+        Collection<Assignment> existingAssignments = getAssignmentsForContext(context);
@@
-        while (existingTitles.contains(uniqueTitle)) {
-            uniqueTitle = originalTitle + "-" + suffix;
+        while (existingTitles.contains(uniqueTitle)) {
+            uniqueTitle = originalTitle + "-" + suffix;
             suffix++;
         }

(Optionally, you could also switch to the already‑imported Collectors.toSet() instead of the fully‑qualified java.util.stream.Collectors.toSet() for consistency with the rest of the class.)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ca6120 and 428de15.

📒 Files selected for processing (1)
  • assignment/impl/src/java/org/sakaiproject/assignment/impl/AssignmentServiceImpl.java (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: sakaiproject/sakai PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-07T16:11:33.008Z
Learning: Commit messages should follow: <issue key> <component> <brief description> (e.g., SAK-12345 Assignments add option x)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: maven-build
  • GitHub Check: sakai-deploy
  • GitHub Check: maven-build

@kunaljaykam kunaljaykam marked this pull request as ready for review November 20, 2025 17:55
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