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

New preview_lesson API #977

Merged
merged 1 commit into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion Stepic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2492,6 +2492,7 @@
2C8BCC2B2486C54400DFB009 /* NewProfileDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewProfileDetailsViewController.swift; sourceTree = "<group>"; };
2C8C17282260EA94008DC7EA /* Model_course_is_certificate_auto_issued.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model_course_is_certificate_auto_issued.xcdatamodel; sourceTree = "<group>"; };
2C8CB0E21FB48F39008CB1AC /* EnrollmentsAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnrollmentsAPI.swift; sourceTree = "<group>"; };
2C8DD7672656777900CE57D8 /* Model_course_preview_unit_v79.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model_course_preview_unit_v79.xcdatamodel; sourceTree = "<group>"; };
2C8E477A258966570084A070 /* GridSimpleCourseListCollectionHeaderContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridSimpleCourseListCollectionHeaderContentView.swift; sourceTree = "<group>"; };
2C8E882B21A2E70F00A27789 /* Model_course_authors_v29.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model_course_authors_v29.xcdatamodel; sourceTree = "<group>"; };
2C8EE76C2604B52E003512BC /* Model_step_needs_plan_v73.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model_step_needs_plan_v73.xcdatamodel; sourceTree = "<group>"; };
Expand Down Expand Up @@ -13001,6 +13002,7 @@
08D1EF6E1BB5618700BE84E6 /* Model.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
2C8DD7672656777900CE57D8 /* Model_course_preview_unit_v79.xcdatamodel */,
2C3A0EF126528A91008D54C5 /* Model_course_default_promo_code_v78.xcdatamodel */,
2C8202BB26385A88002C2C37 /* Model_lesson_finished_steps_v77.xcdatamodel */,
2CDA1AEF26137C8C00E36BF7 /* Model_exams_redesign_v76.xcdatamodel */,
Expand Down Expand Up @@ -13081,7 +13083,7 @@
0802AC531C7222B200C4F3E6 /* Model_v2.xcdatamodel */,
08D1EF6F1BB5618700BE84E6 /* Model.xcdatamodel */,
);
currentVersion = 2C3A0EF126528A91008D54C5 /* Model_course_default_promo_code_v78.xcdatamodel */;
currentVersion = 2C8DD7672656777900CE57D8 /* Model_course_preview_unit_v79.xcdatamodel */;
path = Model.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extension Course {
@NSManaged var managedIsArchived: NSNumber?
@NSManaged var managedLearnersCount: NSNumber?
@NSManaged var managedPreviewLessonId: NSNumber?
@NSManaged var managedPreviewUnitId: NSNumber?
@NSManaged var managedReadiness: NSNumber?

@NSManaged var managedScheduleType: String?
Expand Down Expand Up @@ -119,6 +120,15 @@ extension Course {
}
}

var previewUnitID: Unit.IdType? {
get {
self.managedPreviewUnitId?.intValue
}
set {
self.managedPreviewUnitId = newValue as NSNumber?
}
}

@available(*, deprecated, message: "Use `lessons_count` instead. https://vyahhi.myjetbrains.com/youtrack/issue/EDY-9837#focus=streamItem-74-64368.0-0")
var totalUnits: Int {
get {
Expand Down
16 changes: 4 additions & 12 deletions Stepic/Legacy/Model/Entities/Course/Course.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ final class Course: NSManagedObject, IDFetchable {
self.displayPrice = json[JSONKey.displayPrice.rawValue].string
self.priceTier = json[JSONKey.priceTier.rawValue].int
self.currencyCode = json[JSONKey.currencyCode.rawValue].string
self.previewLessonID = json[JSONKey.previewLesson.rawValue].int
self.previewUnitID = json[JSONKey.previewUnit.rawValue].int

self.certificate = json[JSONKey.certificate.rawValue].stringValue
self.certificateRegularThreshold = json[JSONKey.certificateRegularThreshold.rawValue].int
Expand All @@ -157,15 +159,6 @@ final class Course: NSManagedObject, IDFetchable {
} else {
self.introVideo = Video(json: json[JSONKey.introVideo.rawValue])
}

var previewLessonID: Lesson.IdType?
if let optionsDictionary = json[JSONKey.options.rawValue].dictionary {
if let coursePreviewDictionary = optionsDictionary[JSONKey.coursePreview.rawValue]?.dictionary {
previewLessonID = coursePreviewDictionary[JSONKey.previewLessonID.rawValue]?.int
}
}

self.previewLessonID = previewLessonID
}

func update(json: JSON) {
Expand Down Expand Up @@ -432,9 +425,8 @@ final class Course: NSManagedObject, IDFetchable {
case currencyCode = "currency_code"
case introVideo = "intro_video"
case priceTier = "price_tier"
case options
case coursePreview = "course_preview"
case previewLessonID = "preview_lesson_id"
case previewLesson = "preview_lesson"
case previewUnit = "preview_unit"
case isProctored = "is_proctored"
case defaultPromoCodeName = "default_promo_code_name"
case defaultPromoCodePrice = "default_promo_code_price"
Expand Down
2 changes: 1 addition & 1 deletion Stepic/Legacy/Model/Model.xcdatamodeld/.xccurrentversion
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Model_course_default_promo_code_v78.xcdatamodel</string>
<string>Model_course_preview_unit_v79.xcdatamodel</string>
</dict>
</plist>
Loading