Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with assignments without grading period not being shown on Assignment List #2969

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ndrsszsz
Copy link
Contributor

@ndrsszsz ndrsszsz commented Nov 14, 2024

refs: MBL-18023
affects: Student, Teacher
release note: Fixed an issue where assignments that don't belong to any of the available grading periods were not shown at Assignments.
test plan: Log in with an account that has multiple grading periods and assignments that don't belong to any of those grading periods, and check Assignment List if they are showing all of the assignments properly.

Details

  • Updated AssignmentListViewModel to have the currently active grading period as the default one.
  • Fixed GetAssignmentsByGroup UseCase (all credit goes to Attila on this one).
  • Modified AssignmentListViewModel to get all assignment groups (independently from the grading periods) and apply the grading period filtering on them after. To achieve this I needed to append the stored properties of a Submission entity with grading_period_id which we always get from the API (but we didn't use it until now).

Test

Attila's account is a good one for this. File Upload 4 Copy is one of the assignments that weren't shown previously. You can see it in the screenshots.
See ticket for account info.

Screenshots

Assignment List

BeforeAfter

Checklist

  • Follow-up e2e test ticket created
  • A11y checked
  • Tested on phone
  • Tested on tablet
  • Tested in dark mode
  • Tested in light mode
  • Approve from product

@inst-danger
Copy link
Contributor

inst-danger commented Nov 14, 2024

Fails
🚫 Build failed, skipping coverage check

Release Note:

Fixed an issue where assignments that don't belong to any of the available grading periods were not shown at Assignments.

Affected Apps: Student, Teacher

MBL-18023

❌ XCTest failed: CoreTests/CourseSyncGradesInteractorLiveTests/testSuccessfulSync
failed - Unexpected failure while waiting on finish event: Error Domain=com.instructure Code=0 "No response or error received." UserInfo={NSLocalizedDescription=No response or error received.}
❌ XCTest failed: CoreTests/GetAssignmentsByGroupTests/testFetchesAssignmentsForEachGradingPeriod
XCTAssertEqual failed: ("0") is not equal to ("2")
XCTAssertEqual failed: throwing "NSRangeException: *** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty array"
failed
❌ XCTest failed: CoreTests/GetAssignmentsByGroupTests/testFetchesAssignmentsForEachGradingPeriodAndReturnsAssignmentsForAGradingPeriod
XCTAssertEqual failed: ("0") is not equal to ("1")
XCTAssertEqual failed: throwing "NSRangeException: *** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty array"
failed
❌ XCTest failed: CoreTests/GetAssignmentsByGroupTests/testFetchesAssignmentsForEachGradingPeriodWhenHideGradeIsFalse
XCTAssertEqual failed: ("0") is not equal to ("1")

Generated by 🚫 dangerJS against 300de1f

@inst-danger
Copy link
Contributor

inst-danger commented Nov 14, 2024

Teacher Build QR Code:

@inst-danger
Copy link
Contributor

inst-danger commented Nov 14, 2024

Student Build QR Code:

affects: Student, Teacher
release note: Fixed an issue where assignments that don't belong to any of the available grading periods were not shown at Assignments.
test plan: See ticket.
Copy link
Contributor

@suhaibabsi-inst suhaibabsi-inst left a comment

Choose a reason for hiding this comment

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

Code +1

@suhaibabsi-inst
Copy link
Contributor

suhaibabsi-inst commented Nov 18, 2024

For the intended change, it seems working good. But current period selection is always set to a specific value (here it is Spring) on screen appearance. So, if you change the viewed period to different one, and went into seeing an assignment details, when backing to the assignments list screen you'd always reset to that default period. Which doesn't seem intuitive.

See record below:

current_period_selection_reset_issue.mp4

@ndrsszsz
Copy link
Contributor Author

@suhaibabsi-inst I have addressed your suggestions. Please check again.

Copy link
Contributor

@rh12 rh12 left a comment

Choose a reason for hiding this comment

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

Code review + 1 (minus the tests that need updating)

Comment on lines +79 to +81
if self?.selectedGradingPeriod == nil {
self?.defaultGradingPeriod = self?.currentGradingPeriod
self?.selectedGradingPeriod = self?.defaultGradingPeriod
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a guard let self else { return } before all this nil comparisons and assignments, even it is not strictly needed.

Comment on lines +123 to +124
isFilterIconSolid = (1 ..< AssignmentFilterOption.allCases.count).contains(selectedFilterOptions.count)
|| selectedGradingPeriod != defaultGradingPeriod
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is different then the one in filterOptionsDidUpdate().
Is it intentional? Why is this logic needed here if the value is set just before it (at the end of that method)

Regardless I would extract two pieces of logic, because they are used in multiple places:

private var isFilteringCustom: Bool {
    // all filters selected is the same as no filter selected
    selectedFilterOptions.isNotEmpty && selectedFilterOptions.count != AssignmentFilterOption.allCases.count
}

private func updateFilterIcon() {
   isFilterIconSolid = ...
}

}
assignmentGroups.forEach { group in
let groupAssignments: [Assignment] = assignments.filter { $0.assignmentGroup == group }
if !groupAssignments.isEmpty {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if !groupAssignments.isEmpty {
guard groupAssignments.isNotEmpty else { return }

@@ -189,6 +194,12 @@ public class AssignmentListViewModel: ObservableObject {
}

private func filterAssignments(_ assignments: [Assignment]) -> [Assignment] {
// Filtering by grading period except if all is selected (nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Filtering by grading period except if all is selected (nil)
// Filtering by grading period except if "All" is selected (nil)

to clarify (without needing to check elsewhere) that All is an option, not all of the options

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.

4 participants