Skip to content

Conversation

@st-manu
Copy link
Contributor

@st-manu st-manu commented Dec 10, 2025

https://sakaiproject.atlassian.net/browse/SAK-52238

Summary by CodeRabbit

  • Bug Fixes
    • Prevented blank questions during linear assessment navigation by preserving existing answers.
    • Avoided duplicate placeholder entries for file upload and audio question types.
    • Better retention of student responses when moving between questions to reduce data loss.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Walkthrough

Adjusted SubmitToGradingActionListener to change when placeholder ItemGradingData is created during linear navigation by checking for existing ItemGradingData, ActionEvent presence, and item types; replaced string-concatenated logs with parameterized logging and reorganized imports.

Changes

Cohort / File(s) Summary
Linear navigation and logging updates
samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/SubmitToGradingActionListener.java
Modified logic for creating or reusing placeholder ItemGradingData in linear navigation: retrieve existing data, add existing record when appropriate, avoid duplicate placeholders for File Upload (6) and Audio (7), and only add when itemTextId != -1. Replaced string concatenation in logs with parameterized logging and reorganized imports (added ItemTextIfc).

Suggested reviewers

  • ottenhoff
  • jesusmmp

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly references the Jira issue (SAK-52238) and clearly describes the specific problem being fixed: first question accessibility in linear navigation when parts and questions are timed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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: 0

🧹 Nitpick comments (2)
samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/SubmitToGradingActionListener.java (2)

56-57: Logging/import setup and debug conversions look good; one small log-message nit

  • The added imports and class-level logger wiring are consistent with the existing usage of the log field in this class.
  • The converted debug calls in submitToGradingService, the EMI section, the ActionEvent handling, and identifyOrphanedEMIAnswers all use {} placeholders with the correct number and order of arguments, so they should behave as intended and avoid string concatenation overhead.
  • Minor nit: the message at line 811 reads "adding new answer answer: {}"; consider simplifying it to "adding new answer: {}" for clarity.

Also applies to: 81-82, 94-95, 325-339, 788-812, 895-897, 902-903, 914-914, 969-973


889-940: Linear-navigation placeholder logic looks correct; consider guarding itemTextId against null / -1

The new block for linear navigation when adds is empty and the action is not showFeedback appears to address SAK-52238 as intended:

  • It now runs even when ae is null, ensuring a fake ItemGradingData is created or reused in linear access for timed/tracked questions.
  • It avoids recreating placeholders when an ItemGradingData already exists, and for ae == null explicitly adds the existing grading to adds to prevent a “blank” question.
  • It skips creating extra empty records for File Upload/Audio when a grading already exists.

One robustness improvement I’d suggest:

  • ItemService.getItemTextId(publishedItemId) returns a Long, and the subsequent if(itemTextId != -1) relies on auto‑unboxing and assumes the value is never null. If the service ever returns null for an unusual item, this comparison would NPE, and even when non‑null you’re comparing a boxed value to a primitive sentinel.
  • To make this path safer without changing behavior, you can explicitly guard for null and the sentinel -1L before using the value:
-                ItemService itemService = new ItemService();
-                Long itemTextId = itemService.getItemTextId(publishedItemId);
-                log.debug("itemTextId = {}", itemTextId);
-                if(itemTextId != -1){
-                    itemGrading.setPublishedItemTextId(itemTextId);
-                    adds.add(itemGrading);
-                }
+                ItemService itemService = new ItemService();
+                Long itemTextId = itemService.getItemTextId(publishedItemId);
+                log.debug("itemTextId = {}", itemTextId);
+                if (itemTextId != null && itemTextId.longValue() != -1L) {
+                    itemGrading.setPublishedItemTextId(itemTextId);
+                    adds.add(itemGrading);
+                }

If the current ItemService#getItemTextId contract guarantees a non‑null return, this is mostly defensive, but it would harden the code against future changes.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 644e74f and 543b965.

📒 Files selected for processing (1)
  • samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/SubmitToGradingActionListener.java (8 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.java

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

**/*.java: Use SLF4J parameterized logging (logger.info("Value is: {}", value)) instead of string concatenation (logger.info("Value is: " + value))
Log messages and code comments should be in English. Log messages should never be translated.

**/*.java: Java: Never use local variable type inference (var). Always declare explicit types. Yes: Map<String, Integer> counts = new HashMap<>(); No: var counts = new HashMap<String, Integer>();
When proposing Java code, spell out full types in local variable declarations, for loops, and try-with-resources
When editing Java, prefer clarity over brevity; avoid introducing language features that aren't widely used in the repo
Treat any PR or suggestion containing Java var as non-compliant. Recommend replacing with explicit types before merge

**/*.java: Use Java 17 for trunk development (Java 11 was used for Sakai 22 and Sakai 23)
Do not use local variable type inference (var) in Java code. Always declare explicit types (e.g., List<String> names = new ArrayList<>(); not var names = new ArrayList<String>();). Enforced by Checkstyle rule during mvn validate

Files:

  • samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/SubmitToGradingActionListener.java
🧠 Learnings (2)
📓 Common learnings
Learnt from: ottenhoff
Repo: sakaiproject/sakai PR: 0
File: :0-0
Timestamp: 2025-10-07T15:11:27.298Z
Learning: In samigo’s Total Scores view (samigo/samigo-app/src/webapp/jsf/evaluation/totalScores.jsp), mailto links were hidden after commit dee05746 (PR #12312, SAK-49674) added a render check requiring email.fromEmailAddress to be non-empty; PR #14154 (SAK-52058) restores visibility by checking only description.email.
📚 Learning: 2025-10-07T15:11:27.298Z
Learnt from: ottenhoff
Repo: sakaiproject/sakai PR: 0
File: :0-0
Timestamp: 2025-10-07T15:11:27.298Z
Learning: In samigo’s Total Scores view (samigo/samigo-app/src/webapp/jsf/evaluation/totalScores.jsp), mailto links were hidden after commit dee05746 (PR #12312, SAK-49674) added a render check requiring email.fromEmailAddress to be non-empty; PR #14154 (SAK-52058) restores visibility by checking only description.email.

Applied to files:

  • samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/SubmitToGradingActionListener.java
⏰ 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

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 (1)
samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/SubmitToGradingActionListener.java (1)

906-933: Add explicit else clause to clarify linear navigation logic for non-File Upload/Audio question types.

The code structure for existingItemGrading != null in linear navigation mode (lines 920-932) intentionally handles File Upload (typeId 6) and Audio (typeId 7) separately from other question types, but lacks documentation for the implicit fallthrough. To improve maintainability, add an explicit else clause explaining why other question types (1-5, 8-9, 11-16) do not add existingItemGrading when ae != null:

} else {
  // For other question types, ItemGradingData is handled within the switch statement above.
  // If adds is empty here, the question was unanswered or only marked for review; we don't
  // create a placeholder ItemGradingData when user navigates via button clicks.
}

This clarifies that the logic is intentional and complete, with File Upload/Audio being special cases because they auto-create ItemGradingData upon user upload/record actions.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 644e74f and 543b965.

📒 Files selected for processing (1)
  • samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/SubmitToGradingActionListener.java (8 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.java

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

**/*.java: Use SLF4J parameterized logging (logger.info("Value is: {}", value)) instead of string concatenation (logger.info("Value is: " + value))
Log messages and code comments should be in English. Log messages should never be translated.

**/*.java: Java: Never use local variable type inference (var). Always declare explicit types. Yes: Map<String, Integer> counts = new HashMap<>(); No: var counts = new HashMap<String, Integer>();
When proposing Java code, spell out full types in local variable declarations, for loops, and try-with-resources
When editing Java, prefer clarity over brevity; avoid introducing language features that aren't widely used in the repo
Treat any PR or suggestion containing Java var as non-compliant. Recommend replacing with explicit types before merge

**/*.java: Use Java 17 for trunk development (Java 11 was used for Sakai 22 and Sakai 23)
Do not use local variable type inference (var) in Java code. Always declare explicit types (e.g., List<String> names = new ArrayList<>(); not var names = new ArrayList<String>();). Enforced by Checkstyle rule during mvn validate

Files:

  • samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/SubmitToGradingActionListener.java
🧠 Learnings (2)
📓 Common learnings
Learnt from: ottenhoff
Repo: sakaiproject/sakai PR: 0
File: :0-0
Timestamp: 2025-10-07T15:11:27.298Z
Learning: In samigo’s Total Scores view (samigo/samigo-app/src/webapp/jsf/evaluation/totalScores.jsp), mailto links were hidden after commit dee05746 (PR #12312, SAK-49674) added a render check requiring email.fromEmailAddress to be non-empty; PR #14154 (SAK-52058) restores visibility by checking only description.email.
📚 Learning: 2025-10-07T15:11:27.298Z
Learnt from: ottenhoff
Repo: sakaiproject/sakai PR: 0
File: :0-0
Timestamp: 2025-10-07T15:11:27.298Z
Learning: In samigo’s Total Scores view (samigo/samigo-app/src/webapp/jsf/evaluation/totalScores.jsp), mailto links were hidden after commit dee05746 (PR #12312, SAK-49674) added a render check requiring email.fromEmailAddress to be non-empty; PR #14154 (SAK-52058) restores visibility by checking only description.email.

Applied to files:

  • samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/SubmitToGradingActionListener.java
🔇 Additional comments (3)
samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/listener/delivery/SubmitToGradingActionListener.java (3)

56-56: LGTM: Lombok logging annotation introduced correctly.

The addition of ItemTextIfc import and Lombok's @Slf4j annotation aligns with modern Java logging practices and is used consistently throughout the file.

Also applies to: 81-81, 94-94


324-324: LGTM: Parameterized logging implemented correctly.

All log statements have been properly converted from string concatenation to SLF4J parameterized logging with {} placeholders, improving performance and following the coding guidelines.

Also applies to: 338-338, 799-799, 802-802, 811-811, 894-894, 902-902, 914-914, 968-969, 973-973


905-905: > Likely an incorrect or invalid review comment.

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

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

@github-actions github-actions bot added the stale label Jan 2, 2026
@st-manu st-manu removed the stale label Jan 7, 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