Skip to content

Commit

Permalink
Course info user courses actions (#702)
Browse files Browse the repository at this point in the history
* Parse is_archived

* Persist isFavorite & isArchived

* Add user-courses network service

* Perform user course actions

* Notify about changes

* Fix present actions alert on unenrolled course
  • Loading branch information
ivan-magda authored Apr 26, 2020
1 parent 58c72b1 commit 4b43b14
Show file tree
Hide file tree
Showing 20 changed files with 693 additions and 34 deletions.
8 changes: 7 additions & 1 deletion Stepic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@
2C6E9CDB1FF27543001821A2 /* AdaptiveStorageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C6E9CDA1FF27543001821A2 /* AdaptiveStorageManager.swift */; };
2C7024BA23D00762002A0246 /* SettingsRightDetailSwitchTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7024B923D00762002A0246 /* SettingsRightDetailSwitchTableViewCell.swift */; };
2C7024BC23D00799002A0246 /* SettingsRightDetailSwitchCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7024BB23D00799002A0246 /* SettingsRightDetailSwitchCellView.swift */; };
2C746642245613E900BB0800 /* UserCoursesNetworkService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C746641245613E900BB0800 /* UserCoursesNetworkService.swift */; };
2C79F61821873CD9004CC082 /* NotificationsRequestOnlySettingsAlertPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C79F61721873CD9004CC082 /* NotificationsRequestOnlySettingsAlertPresenter.swift */; };
2C7F641C23B0F5B7006C7648 /* PlayNextCircleControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7F641B23B0F5B7006C7648 /* PlayNextCircleControlView.swift */; };
2C7F641E23B12208006C7648 /* AutoplayStorageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7F641D23B12208006C7648 /* AutoplayStorageManager.swift */; };
Expand Down Expand Up @@ -1730,6 +1731,8 @@
2C6E9CDA1FF27543001821A2 /* AdaptiveStorageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptiveStorageManager.swift; sourceTree = "<group>"; };
2C7024B923D00762002A0246 /* SettingsRightDetailSwitchTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRightDetailSwitchTableViewCell.swift; sourceTree = "<group>"; };
2C7024BB23D00799002A0246 /* SettingsRightDetailSwitchCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsRightDetailSwitchCellView.swift; sourceTree = "<group>"; };
2C7466402456065F00BB0800 /* Model_user_courses_actions_v51.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model_user_courses_actions_v51.xcdatamodel; sourceTree = "<group>"; };
2C746641245613E900BB0800 /* UserCoursesNetworkService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserCoursesNetworkService.swift; sourceTree = "<group>"; };
2C79F61721873CD9004CC082 /* NotificationsRequestOnlySettingsAlertPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsRequestOnlySettingsAlertPresenter.swift; sourceTree = "<group>"; };
2C7F641B23B0F5B7006C7648 /* PlayNextCircleControlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayNextCircleControlView.swift; sourceTree = "<group>"; };
2C7F641D23B12208006C7648 /* AutoplayStorageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoplayStorageManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5305,6 +5308,7 @@
62E98E41865820B1B8F7357D /* UnitsNetworkService.swift */,
2C16495822C10DD300DF18CA /* UserActivitiesNetworkService.swift */,
2CB1C3B024009339001DA83E /* UserCodeRunsNetworkService.swift */,
2C746641245613E900BB0800 /* UserCoursesNetworkService.swift */,
62E98407592112A22E967DE1 /* UsersNetworkService.swift */,
2CB9529B229F29F000A6117A /* ViewsNetworkService.swift */,
2C85C6A422D38A3800FDBAFE /* VotesNetworkService.swift */,
Expand Down Expand Up @@ -7678,6 +7682,7 @@
62E9889E935597A0ED849B0C /* ContentLanguageSwitchViewController.swift in Sources */,
62E982DE03DC1E9967B8B43B /* ContentLanguageSwitchViewModel.swift in Sources */,
62E98561DFB8CBB54B0CA2F7 /* ContentLanguageSwitchButton.swift in Sources */,
2C746642245613E900BB0800 /* UserCoursesNetworkService.swift in Sources */,
62E98C25078CB0ECB000FB71 /* ContentLanguageSwitchView.swift in Sources */,
62E98B25E6C3E23A223DC564 /* ContinueCourseAssembly.swift in Sources */,
62E98E830A3AC918F1CD339F /* ContinueCourseDataFlow.swift in Sources */,
Expand Down Expand Up @@ -8360,6 +8365,7 @@
08D1EF6E1BB5618700BE84E6 /* Model.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
2C7466402456065F00BB0800 /* Model_user_courses_actions_v51.xcdatamodel */,
2C87A7A52446635E00933CA4 /* Model_user_activity_v50.xcdatamodel */,
2C04BA3724058AF100D74D4B /* Model_attempts_caching.xcdatamodel */,
2CB1C3B224009ACB001DA83E /* Model_ is_run_user_code_allowed.xcdatamodel */,
Expand Down Expand Up @@ -8412,7 +8418,7 @@
0802AC531C7222B200C4F3E6 /* Model_v2.xcdatamodel */,
08D1EF6F1BB5618700BE84E6 /* Model.xcdatamodel */,
);
currentVersion = 2C87A7A52446635E00933CA4 /* Model_user_activity_v50.xcdatamodel */;
currentVersion = 2C7466402456065F00BB0800 /* Model_user_courses_actions_v51.xcdatamodel */;
path = Model.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ extension Course {
@NSManaged var managedEnrolled: NSNumber?
@NSManaged var managedFeatured: NSNumber?
@NSManaged var managedPublic: NSNumber?
@NSManaged var managedIsFavorite: NSNumber?
@NSManaged var managedIsArchived: NSNumber?
@NSManaged var managedLearnersCount: NSNumber?
@NSManaged var managedReadiness: NSNumber?

Expand Down Expand Up @@ -208,6 +210,24 @@ extension Course {
}
}

var isFavorite: Bool {
get {
self.managedIsFavorite?.boolValue ?? false
}
set {
self.managedIsFavorite = NSNumber(value: newValue)
}
}

var isArchived: Bool {
get {
self.managedIsArchived?.boolValue ?? false
}
set {
self.managedIsArchived = NSNumber(value: newValue)
}
}

var isPublic: Bool {
set(isPublic) {
self.managedPublic = isPublic as NSNumber?
Expand Down
4 changes: 4 additions & 0 deletions Stepic/Legacy/Model/Entities/Course/Course.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ final class Course: NSManagedObject, IDFetchable {
self.enrolled = json[JSONKey.enrollment.rawValue].int != nil
self.featured = json[JSONKey.isFeatured.rawValue].boolValue
self.isPublic = json[JSONKey.isPublic.rawValue].boolValue
self.isFavorite = json[JSONKey.isFavorite.rawValue].boolValue
self.isArchived = json[JSONKey.isArchived.rawValue].boolValue
self.readiness = json[JSONKey.readiness.rawValue].float

self.summary = json[JSONKey.summary.rawValue].stringValue
Expand Down Expand Up @@ -405,6 +407,8 @@ final class Course: NSManagedObject, IDFetchable {
case enrollment
case isFeatured = "is_featured"
case isPublic = "is_public"
case isFavorite = "is_favorite"
case isArchived = "is_archived"
case readiness
case summary
case workload
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_user_activity_v50.xcdatamodel</string>
<string>Model_user_courses_actions_v51.xcdatamodel</string>
</dict>
</plist>
Loading

0 comments on commit 4b43b14

Please sign in to comment.