-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
194 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
CanvasPlusPlayground/Common/Network/API Requests/GetAssignmentGroupsRequest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// GetAssignmentGroupsRequest.swift | ||
// CanvasPlusPlayground | ||
// | ||
// Created by Rahul on 12/26/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct GetAssignmentGroupsRequest: ArrayAPIRequest { | ||
typealias Subject = AssignmentGroup | ||
|
||
let courseId: String | ||
|
||
// Path for the request | ||
var path: String { "courses/\(courseId)/assignment_groups" } | ||
|
||
// Query parameters | ||
var queryParameters: [QueryParameter] { | ||
[ | ||
("override_assignment_dates", overrideAssignmentDates), | ||
("grading_period_id", gradingPeriodId), | ||
("scope_assignments_to_student", scopeAssignmentsToStudent) | ||
] | ||
+ include.map { ("include[]", $0) } | ||
+ assignmentIds.map { ("assignment_ids[]", $0) } | ||
+ excludeAssignmentSubmissionTypes.map { ("exclude_assignment_submission_types[]", $0) } | ||
} | ||
|
||
// MARK: Query Params | ||
let include: [String] | ||
let assignmentIds: [String] | ||
let excludeAssignmentSubmissionTypes: [String] | ||
let overrideAssignmentDates: Bool? | ||
let gradingPeriodId: Int? | ||
let scopeAssignmentsToStudent: Bool? | ||
|
||
// Initializer | ||
init( | ||
courseId: String, | ||
include: [String] = [], | ||
assignmentIds: [String] = [], | ||
excludeAssignmentSubmissionTypes: [String] = [], | ||
overrideAssignmentDates: Bool? = nil, | ||
gradingPeriodId: Int? = nil, | ||
scopeAssignmentsToStudent: Bool? = nil | ||
) { | ||
self.courseId = courseId | ||
self.include = include | ||
self.assignmentIds = assignmentIds | ||
self.excludeAssignmentSubmissionTypes = excludeAssignmentSubmissionTypes | ||
self.overrideAssignmentDates = overrideAssignmentDates | ||
self.gradingPeriodId = gradingPeriodId | ||
self.scopeAssignmentsToStudent = scopeAssignmentsToStudent | ||
} | ||
|
||
/* MARK: Request Caching (Optional Implementation) | ||
var requestId: Int? { courseId.asInt } | ||
var requestIdKey: ParentKeyPath<AssignmentGroup, Int?> { .createReadable(\.courseId) } | ||
var idPredicate: Predicate<AssignmentGroup> { | ||
#Predicate<AssignmentGroup> { group in | ||
group.courseId == requestId | ||
} | ||
} | ||
|
||
var customPredicate: Predicate<AssignmentGroup> { | ||
let ids = assignmentIds.compactMap(\.?.asInt) | ||
let assignmentIdsPred = assignmentIds.isEmpty ? .true : #Predicate<AssignmentGroup> { group in | ||
ids.contains(group.id) | ||
} | ||
return assignmentIdsPred | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// AssignmentGroup.swift | ||
// CanvasPlusPlayground | ||
// | ||
// Created by Rahul on 12/18/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct AssignmentGroup: Codable, Identifiable { | ||
let id: Int? | ||
let name: String? | ||
let position: Int? | ||
let groupWeight: Int? | ||
let sisSourceID: String? | ||
let integrationData: [String: String]? | ||
let assignments: [Assignment]? | ||
let rules: GradingRules? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case id | ||
case name | ||
case position | ||
case groupWeight = "group_weight" | ||
case sisSourceID = "sis_source_id" | ||
case integrationData = "integration_data" | ||
case assignments | ||
case rules | ||
} | ||
} | ||
|
||
struct GradingRules: Codable { | ||
let dropLowest: Int? | ||
let dropHighest: Int? | ||
let neverDrop: [Int]? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case dropLowest = "drop_lowest" | ||
case dropHighest = "drop_highest" | ||
case neverDrop = "never_drop" | ||
} | ||
} |