Skip to content

SG Refactor #3 - Extract submission grader logic to view model #3311

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

Merged
merged 38 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
424d271
Reorganize files.
vargaat Mar 27, 2025
96e5a04
Merge branch 'master' into feature/MBL-18708-Speedgrader-architecture
vargaat Mar 28, 2025
f85ae25
Extract rubric circle view.
vargaat Mar 28, 2025
422d4f8
Reorder tests.
vargaat Mar 28, 2025
5b2940b
Further split views into subviews. Extract logic into viewmodel.
vargaat Apr 1, 2025
2144948
Merge branch 'master' into chore/MBL-18708-Speedgrader-business-logic…
vargaat Apr 1, 2025
c180abe
WIP: Continue extracting logic to view models.
vargaat Apr 2, 2025
950134c
Further break down views into smaller views.
vargaat Apr 2, 2025
3f558ee
Fix rubric comments not displayed.
vargaat Apr 2, 2025
ebc9d4c
Extract rubric save related logic to interactor.
vargaat Apr 2, 2025
f9c9026
Extract rubric score calculation logic to interactor.
vargaat Apr 2, 2025
9f1ce3a
Use interactor directly instead of publisher.
vargaat Apr 3, 2025
51d582d
Encapsulate rubric assessment mutation logic into interactor.
vargaat Apr 3, 2025
aef808b
Rename API entity.
vargaat Apr 3, 2025
40bbb51
Rename CoreData Rubric entity.
vargaat Apr 3, 2025
ed1a410
More renaming.
vargaat Apr 3, 2025
5f10741
Add test for string extension.
vargaat Apr 3, 2025
73c70af
Extract rubric interactor protocol for easier mocking.
vargaat Apr 4, 2025
c2e71b6
Add support for ReactiveStore to use custom environment other than sh…
vargaat Apr 4, 2025
2e61d63
Extract submission loading logic into interactor.
vargaat Apr 4, 2025
40acf21
Update tests, add more granularity to errors.
vargaat Apr 7, 2025
18b3254
Merge branch 'master' into chore/MBL-18708-SpeedGraderViewController-…
vargaat Apr 9, 2025
f936fc6
Switch errors.
vargaat Apr 10, 2025
cee3fc9
Fix predicate not working properly when excusedRaw field is nil.
vargaat Apr 11, 2025
59f175e
Revert unintentional change.
vargaat Apr 11, 2025
1d81b01
Fix webview triggering refresh for the initially focused user and not…
vargaat Apr 15, 2025
cda6e9b
WIP: Extract logic into view model.
vargaat Apr 11, 2025
c2a5270
Clean up logic in view model.
vargaat Apr 11, 2025
9780431
Extract landscape and portait layouts to different methods.
vargaat Apr 14, 2025
c0c9fa0
Add better name to views
vargaat Apr 14, 2025
cbea226
Implement code review suggestions.
vargaat Apr 15, 2025
e60ab1b
Merge branch 'chore/MBL-18708-SpeedGraderViewController-refactor' int…
vargaat Apr 15, 2025
18b8c10
Implement code review suggestions.
vargaat Apr 15, 2025
abcad3b
Update test.
vargaat Apr 15, 2025
18515c6
Merge branch 'chore/MBL-18708-SpeedGraderViewController-refactor' int…
vargaat Apr 15, 2025
37f72fb
Merge branch 'master' into chore/MBL-18708-SpeedGraderViewController-…
vargaat Apr 15, 2025
7468a41
Merge branch 'chore/MBL-18708-SpeedGraderViewController-refactor' int…
vargaat Apr 15, 2025
7edd0e1
Merge branch 'master' into chore/MBL-18708-SubmissionGrader-refactor
vargaat Apr 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 40 additions & 28 deletions Teacher/Teacher.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct CommentLibrarySheet: View {
CommentLibraryList(viewModel: viewModel, comment: $comment) {
presentationMode.wrappedValue.dismiss()
}
CommentEditor(
CommentEditorView(
text: $comment,
shouldShowCommentLibrary: false,
showCommentLibrary: .constant(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import SwiftUI
import Core

struct CommentEditor: View {
struct CommentEditorView: View {
@Environment(\.viewController) var controller

@Binding var text: String
Expand Down Expand Up @@ -77,7 +77,7 @@ struct CommentEditor: View {
struct CommentEditor_Previews: PreviewProvider {
static var previews: some View {
@State var showCommentLibrary = false
CommentEditor(text: .constant("Sample Text"),
CommentEditorView(text: .constant("Sample Text"),
shouldShowCommentLibrary: true,
showCommentLibrary: $showCommentLibrary,
action: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct SubmissionCommentListCell: View {
let submission: Submission
let comment: SubmissionComment

@Binding var attempt: Int?
@Binding var attempt: Int
@Binding var fileID: String?

@Environment(\.appEnvironment.currentSession?.userID) var currentUserID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,38 @@ import SwiftUI
import Core
import Combine

struct SubmissionCommentList: View {
struct SubmissionCommentListView: View {
let assignment: Assignment
let submission: Submission
let filePicker = FilePicker(env: .shared)
@Binding var attempt: Int?
@Binding var attempt: Int
@Binding var fileID: String?
@Binding var showRecorder: MediaCommentType?
@Binding var comment: String

@Environment(\.appEnvironment) var env
@Environment(\.viewController) var controller

@ObservedObject var attempts: Store<LocalUseCase<Submission>>
var attempts: [Submission]
@ObservedObject var commentLibrary: SubmissionCommentLibraryViewModel

@StateObject private var viewModel: SubmissionCommentListViewModel
@State var error: Text?
@State var showMediaOptions = false
@State var showCommentLibrary = false

@AccessibilityFocusState private var focusedTab: SubmissionGrader.GraderTab?
@AccessibilityFocusState private var focusedTab: SubmissionGraderView.GraderTab?

init(
assignment: Assignment,
submission: Submission,
attempts: Store<LocalUseCase<Submission>>,
attempt: Binding<Int?>,
attempts: [Submission],
attempt: Binding<Int>,
fileID: Binding<String?>,
showRecorder: Binding<MediaCommentType?>,
enteredComment: Binding<String>,
commentLibrary: SubmissionCommentLibraryViewModel,
focusedTab: AccessibilityFocusState<SubmissionGrader.GraderTab?>
focusedTab: AccessibilityFocusState<SubmissionGraderView.GraderTab?>
) {
self.assignment = assignment
self.submission = submission
Expand Down Expand Up @@ -159,7 +159,7 @@ struct SubmissionCommentList: View {
.cancel()
])
}
CommentEditor(
CommentEditorView(
text: $comment,
shouldShowCommentLibrary: commentLibrary.shouldShow,
showCommentLibrary: $showCommentLibrary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct SubmissionGrades: View {
}

private func commentEditor() -> some View {
CommentEditor(
CommentEditorView(
text: $rubricsViewModel.criterionComment,
shouldShowCommentLibrary: false,
showCommentLibrary: .constant(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum DrawerState {
}

// Place after the main content in a ZStack(alignment: .bottom)
struct Drawer<Content: View>: View {
struct DrawerContainer<Content: View>: View {
let content: Content
let minHeight: CGFloat
let maxHeight: CGFloat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import SwiftUI
import Core

struct SimilarityScore: View {
struct SimilarityScoreView: View {
let status: String
let score: Double
let url: URL?
Expand Down
Loading