diff --git a/Stepic.xcodeproj/project.pbxproj b/Stepic.xcodeproj/project.pbxproj index e1640ce6ab..495e163ed8 100644 --- a/Stepic.xcodeproj/project.pbxproj +++ b/Stepic.xcodeproj/project.pbxproj @@ -2492,6 +2492,7 @@ 2C8BCC2B2486C54400DFB009 /* NewProfileDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewProfileDetailsViewController.swift; sourceTree = ""; }; 2C8C17282260EA94008DC7EA /* Model_course_is_certificate_auto_issued.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model_course_is_certificate_auto_issued.xcdatamodel; sourceTree = ""; }; 2C8CB0E21FB48F39008CB1AC /* EnrollmentsAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnrollmentsAPI.swift; sourceTree = ""; }; + 2C8DD7672656777900CE57D8 /* Model_course_preview_unit_v79.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model_course_preview_unit_v79.xcdatamodel; sourceTree = ""; }; 2C8E477A258966570084A070 /* GridSimpleCourseListCollectionHeaderContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GridSimpleCourseListCollectionHeaderContentView.swift; sourceTree = ""; }; 2C8E882B21A2E70F00A27789 /* Model_course_authors_v29.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model_course_authors_v29.xcdatamodel; sourceTree = ""; }; 2C8EE76C2604B52E003512BC /* Model_step_needs_plan_v73.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model_step_needs_plan_v73.xcdatamodel; sourceTree = ""; }; @@ -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 */, @@ -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 = ""; versionGroupType = wrapper.xcdatamodel; diff --git a/Stepic/Legacy/Model/Entities/Course/Course+CoreDataProperties.swift b/Stepic/Legacy/Model/Entities/Course/Course+CoreDataProperties.swift index faccb58c44..a9795a2cc0 100644 --- a/Stepic/Legacy/Model/Entities/Course/Course+CoreDataProperties.swift +++ b/Stepic/Legacy/Model/Entities/Course/Course+CoreDataProperties.swift @@ -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? @@ -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 { diff --git a/Stepic/Legacy/Model/Entities/Course/Course.swift b/Stepic/Legacy/Model/Entities/Course/Course.swift index a87032ef49..54104a0e58 100644 --- a/Stepic/Legacy/Model/Entities/Course/Course.swift +++ b/Stepic/Legacy/Model/Entities/Course/Course.swift @@ -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 @@ -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) { @@ -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" diff --git a/Stepic/Legacy/Model/Model.xcdatamodeld/.xccurrentversion b/Stepic/Legacy/Model/Model.xcdatamodeld/.xccurrentversion index 6f8dcd80ea..787370528b 100644 --- a/Stepic/Legacy/Model/Model.xcdatamodeld/.xccurrentversion +++ b/Stepic/Legacy/Model/Model.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - Model_course_default_promo_code_v78.xcdatamodel + Model_course_preview_unit_v79.xcdatamodel diff --git a/Stepic/Legacy/Model/Model.xcdatamodeld/Model_course_preview_unit_v79.xcdatamodel/contents b/Stepic/Legacy/Model/Model.xcdatamodeld/Model_course_preview_unit_v79.xcdatamodel/contents new file mode 100644 index 0000000000..acc85fad77 --- /dev/null +++ b/Stepic/Legacy/Model/Model.xcdatamodeld/Model_course_preview_unit_v79.xcdatamodel/contents @@ -0,0 +1,490 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file