Skip to content

Conversation

@kristofnemere
Copy link
Contributor

Test plan:

  1. As a teacher, create a New Quiz assignment in a course
  2. Set an "until date" that is in the past (e.g., yesterday)
  3. As a student enrolled in the course, submit the quiz before the until date expires
  4. After the until date has passed, log in as the student in the Canvas Android app
  5. Navigate to the course grades and tap on the quiz assignment
  6. Verify that an error toast is displayed instead of the app attempting to navigate with a null LTI tool
  7. Expected: Error message "An unexpected error occurred." should appear as a toast
  8. Verify the app doesn't crash and remains functional

refs: MBL-19559
affects: Student
release note: Fixed issue where students couldn't view New Quizzes submissions after the assignment's until date had passed

Checklist

  • Follow-up e2e test ticket created or not needed
  • Run E2E test suite
  • Tested in dark mode
  • Tested in light mode
  • Test in landscape mode and/or tablet
  • A11y checked
  • Approve from product

Fixed issue where New Quizzes with past until dates would fail to load
properly. Changed getExternalToolLaunchUrl to return null on failure
instead of throwing exception, and added proper error handling in the
ViewModel to show a user-friendly error message.

Changes:
- AssignmentDetailsNetworkDataSource: Return null instead of throwing
  exception when getExternalToolLaunchUrl API call fails
- AssignmentDetailsViewModel: Check for null externalLTITool and show
  error toast instead of attempting navigation
- Added comprehensive test coverage for both success and failure cases

Test plan:
- Create a New Quiz assignment with an until date in the past
- As a student, try to view the assignment submission
- Verify error toast is displayed instead of app crash

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Review Summary

This PR improves error handling for external tool launch URLs by changing from exception-based error handling to nullable return values. This is a good architectural improvement that makes error handling more explicit and prevents crashes.

Key Changes

  • Changed getExternalToolLaunchUrl return type from LTITool to LTITool? in the repository interface and network data source
  • Updated error handling from dataOrThrow to dataOrNull in AssignmentDetailsNetworkDataSource
  • Added null check in AssignmentDetailsViewModel to gracefully handle failures with a user-friendly error message
  • Updated tests to reflect the new behavior (returns null instead of throwing exception)
  • Added new test case for the null LTI tool scenario in the ViewModel

Positive Aspects

Consistent with existing code: The LocalDataSource already returns null for this method, so this change makes the network implementation consistent
Better user experience: Users now see a friendly error message instead of a crash
Proper test coverage: Both the data source test and ViewModel test were updated to cover the new null-handling behavior
Follows Kotlin idioms: Using nullable types is more idiomatic than throwing exceptions for expected failure cases
Clean implementation: The null check is straightforward and handles the error case appropriately

Suggestions for Improvement

  • Consider adding error logging: Track when this failure occurs to understand its frequency in production (see inline comment on AssignmentDetailsViewModel.kt:691)
  • Consider more specific error message: The generic "unexpected error" message could be replaced with something more specific like "Unable to load external tool" (see inline comment on AssignmentDetailsViewModel.kt:691)

Code Quality Assessment

  • Architecture: ✅ Good - follows repository pattern correctly
  • Error Handling: ✅ Good - graceful degradation instead of crashes
  • Test Coverage: ✅ Good - both unit tests updated appropriately
  • Code Style: ✅ Good - follows Kotlin conventions and project patterns
  • Performance: ✅ No concerns
  • Security: ✅ No concerns

Overall, this is a solid improvement to error handling. The suggestions above are minor enhancements and not blocking issues.

@github-actions
Copy link

📊 Code Coverage Report

✅ Student

  • PR Coverage: 42.80%
  • Master Coverage: 42.80%
  • Delta: +0.00%

✅ Teacher

  • PR Coverage: 25.44%
  • Master Coverage: 25.44%
  • Delta: +0.00%

✅ Pandautils

  • PR Coverage: 22.63%
  • Master Coverage: 22.61%
  • Delta: +0.02%

📈 Overall Average

  • PR Coverage: 30.29%
  • Master Coverage: 30.29%
  • Delta: +0.01%

@github-actions
Copy link

Teacher Install Page

@github-actions
Copy link

Student Install Page

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.

3 participants