public static void UpdateLesson(InteractiveLesson lesson, Action <InteractiveLesson> onComplete) { Dictionary <string, object> body = new Dictionary <string, object>() { { "name", lesson.name }, { "description", lesson.description }, { "type", "Video" }, { "data", lesson.data }, { "team", User.current.selectedMembership.team._id }, { "onComplete", lesson.onComplete } }; ServerRequest.CallAPI("/interactive/lessons/" + lesson._id, HTTPMethod.PUT, body, (response) => ServerRequest.ResponseHandler(response, null, onComplete), true); }
public static void CompleteLesson(InteractiveCourse course, InteractiveLesson lesson, bool complete, Action <CourseProgress[]> onComplete) { //PUT /api/interactive/progress Dictionary <string, object> body = new Dictionary <string, object>() { { "type", "lesson" }, { "id", lesson._id }, { "course", course._id }, { "complete", complete }, { "member", User.current.selectedMembership._id } }; ServerRequest.CallAPI("/interactive/progress", HTTPMethod.PUT, body, (r) => ServerRequest.ResponseHandler(r, "userProgress", onComplete), true); }
public static void DeleteLesson(InteractiveLesson lesson, Action <bool> onComplete) { ServerRequest.CallAPI("/interactive/lessons/" + lesson._id, HTTPMethod.DELETE, null, (response) => { ServerRequest.ResponseHandler <Dictionary <string, object> >(response, null, (dict) => { if (dict != null && dict.ContainsKey("ok") && System.Convert.ToInt32(dict["ok"]) == 1) { onComplete?.Invoke(true); //success == true } else { onComplete?.Invoke(false); } }); }, true); }
//HELPER FUNCTIONS public bool isLessonComplete(string lessonId) { InteractiveLesson lesson = this.lessonsComplete.ToList().FirstOrDefault((x) => x._id == lessonId); return(!(lesson == null)); }