Exemplo n.º 1
0
        public static void ListQuestions(string teamId, Action <InteractiveQuestion[]> onComplete)
        {
            //GET /api/interactive/questions/list/:teamId
            //Returns: {"questions": []}

            ServerRequest.CallAPI("/interactive/questions/list/" + teamId, HTTPMethod.GET, null, (response) => { ServerRequest.ResponseHandler(response, "questions", onComplete); }, true);
        }
        /// <summary>
        /// Returns all leaderboard entries with shortCode but only if they belong to a team member from teamId
        /// </summary>
        public static void GetLeaderboardEntries(string shortCode, string teamId, Action <LeaderboardEntry[]> onComplete)
        {
            ServerRequest.CallAPI("/leaderboard/" + shortCode + "/" + teamId, HTTPMethod.GET, null, (response) =>
            {
                if (response.hasError)
                {
                    Debug.LogError("GetLeaderboardEntries Error: " + response.Error);
                    onComplete?.Invoke(null);
                    return;
                }

                Dictionary <string, object> responseData = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.text);

                if (responseData != null && responseData.ContainsKey("entries"))
                {
                    LeaderboardEntry[] entries = JsonConvert.DeserializeObject <LeaderboardEntry[]>(JsonConvert.SerializeObject(responseData["entries"]));

                    onComplete?.Invoke(entries);
                    return;
                }

                Debug.LogWarning("GetLeaderboardEntries failed somehow. Server Response was: " + response.text);
                onComplete?.Invoke(null);
            }, true);
        }
        public static void UpdateCourse(InteractiveCourse course, Action <InteractiveCourse> onComplete)
        {
            // PUT /api/interactive/courses/:courseId
            //Body = { "name": "", "description": "", "theme": "theme id", "levels": [levelIds]}
            List <string> levelIds = new List <string>();

            for (int i = 0; i < course.levels.Length; i++)
            {
                levelIds.Add(course.levels[i]._id);
            }

            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "name", course.name },
                { "description", course.description },
                { "levels", levelIds }
            };

            if (course.theme != null)
            {
                body.Add("theme", course.theme._id);
            }
            else
            {
                body.Add("theme", null);
            }

            ServerRequest.CallAPI("/interactive/courses/" + course._id, HTTPMethod.PUT, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
Exemplo n.º 4
0
        public static void StoreTeamFileRecord(ImportedFileData file, Action <Dictionary <string, object> > onComplete)
        {
            // POST /teams/files/:teamId/storeRecord

            /*
             *  {
             *      "file": {
             *          "originalname": "",
             *          "mimetype": "",
             *          "encoding": ""
             *      }
             *  }
             */


            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "file", new Dictionary <string, string>()
                  {
                      { "originalname", file.name },
                      { "mimetype", file.type },
                      { "encoding", "7bit" }
                  } }
            };

            ServerRequest.CallAPI("/teams/files/" + User.current.selectedMembership.team._id + "/storeRecord", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
Exemplo n.º 5
0
        public static void DeleteFile(string fileId, Action <Dictionary <string, object> > onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "fileId", fileId }
            };

            ServerRequest.CallAPI("/teams/files/" + User.current.selectedMembership.team._id + "/delete", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
Exemplo n.º 6
0
        public static void InviteMember(string email, Action <TeamInvitationResponse> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>();

            body.Add("email", email);


            ServerRequest.CallAPI("/teams/invite", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
Exemplo n.º 7
0
        public static void ForgotPassword(string email, Action <Dictionary <string, object> > onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "email", email }
            };

            ServerRequest.CallAPI("/forgot", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, false);
        }
        public static void DeleteInstructorDeck(string id, Action <InstructorDeckResponse> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "team", User.current.selectedMembership.team._id }
            };

            ServerRequest.CallAPI("/interactive/instructor/decks/delete/" + id, HTTPMethod.POST, body, (response) => ServerRequest.ResponseHandler(response, null, onComplete), true);
        }
Exemplo n.º 9
0
        public static void ListQuestionsByIds(string[] questionIds, Action <InteractiveQuestion[]> onComplete)
        {
            string teamId = User.current.selectedMembership.team._id;
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "questions", questionIds }
            };

            ServerRequest.CallAPI("/interactive/questions/list/byId/" + teamId, HTTPMethod.POST, body, (response) => { ServerRequest.ResponseHandler(response, "questions", onComplete); }, true);
        }
        public static void SubmitMetrics(MetricEvent[] metrics, System.Action <MetricsResponse> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "metrics", metrics }
            };


            ServerRequest.CallAPI("/metrics", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, false);
        }
Exemplo n.º 11
0
        public static void UpdateTeam(string id, string name, string logo, Action <Team> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>();

            body.Add("team", id);
            body.Add("name", name);
            body.Add("logo", logo);

            ServerRequest.CallAPI("/teams/update", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, "team", onComplete); }, true);
        }
Exemplo n.º 12
0
        public static void UpdateMemberRank(string memberId, int rank, Action <Dictionary <string, object> > onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "id", memberId },
                { "rank", rank }
            };

            ServerRequest.CallAPI("/teams/members/rank", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
        public static void AwardBadge(string badgeId, System.Action <string[]> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "user", User.current._id },
                { "badgeId", badgeId }
            };

            ServerRequest.CallAPI("/interactive/badges/user", HTTPMethod.PUT, body, (r) => ServerRequest.ResponseHandler(r, "badges", onComplete), true);
        }
Exemplo n.º 14
0
        public static void GroupAddAssignment(TeamGroup group, string courseId, Action <TeamGroup> onComplete)
        {
            //POST /api/teams/groups/:groupId/assignment

            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "course", courseId }
            };

            ServerRequest.CallAPI("/teams/groups/" + group._id + "/assignment", HTTPMethod.PUT, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
Exemplo n.º 15
0
        public static void ResetPassword(string email, string code, string password, Action <Dictionary <string, object> > onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "code", code },
                { "email", email },
                { "password", password }
            };

            ServerRequest.CallAPI("/reset", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, false);
        }
Exemplo n.º 16
0
        public static void RemoveMember(TeamMember member, Action <Dictionary <string, object> > onComplete)
        {
            //POST /api/teams/members/remove

            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "member", member._id }
            };

            ServerRequest.CallAPI("/teams/members/remove", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
Exemplo n.º 17
0
        public static void GetSignedUploadURL(string filename, string filetype, Action <Dictionary <string, object> > onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "filename", filename },
                { "filetype", filetype },
                { "team", User.current.selectedMembership.team._id }
            };

            ServerRequest.CallAPI("/aws/getSignedUrl", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
Exemplo n.º 18
0
        public static void SubmitQuizScore(InteractiveQuizScore quizScore, Action <CourseProgress[]> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>();

            body.Add("score", quizScore.score);
            body.Add("didPass", quizScore.didPass);
            body.Add("quiz", quizScore.quiz);
            body.Add("member", User.current.selectedMembership._id);
            body.Add("course", InteractiveCourse.current._id);

            ServerRequest.CallAPI("/interactive/progress/quiz", HTTPMethod.PUT, body, (response) => ServerRequest.ResponseHandler(response, "userProgress", onComplete), true);
        }
        public static void GetMetrics(string teamId, string startDate, string endDate, System.Action <MetricsResponse> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "teamId", teamId },
                { "startDate", startDate },
                { "endDate", endDate }
            };


            ServerRequest.CallAPI("/metrics/list", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, false);
        }
Exemplo n.º 20
0
        public static void MemberAddAssignment(TeamMember member, string courseId, Action <string[]> onComplete)
        {
            //POST /api/teams/groups/:groupId/assignment

            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "course", courseId },
                { "member", member._id }
            };

            ServerRequest.CallAPI("/teams/members/assignments", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, "courses", onComplete); }, true);
        }
Exemplo n.º 21
0
        public static void AddGroupToMember(TeamMember member, TeamGroup group, Action <TeamMember> onComplete)
        {
            //POST /api/teams/members/addGroup

            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "member", member._id },
                { "group", group._id }
            };

            ServerRequest.CallAPI("/teams/members/addGroup", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
Exemplo n.º 22
0
        public static void ListTeamEvents(string teamId, Action <ListTeamEventsResponse> onComplete)
        {
            if (string.IsNullOrEmpty(teamId))
            {
                Debug.LogError("INVALID TEAM ID");
                return;
            }

            //GET /api/teams/members/:teamId

            ServerRequest.CallAPI("/teams/" + teamId + "/events/list", HTTPMethod.GET, null, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
Exemplo n.º 23
0
        public static void CreateGroup(TeamGroup group, Action <TeamGroup> onComplete)
        {
            //POST /api/teams/groups/create

            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "name", group.name },
                { "team", User.current.selectedMembership.team._id }
            };

            ServerRequest.CallAPI("/teams/groups/create", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
        public static void UpdateBadge(InteractiveBadge badge, Action <InteractiveBadge> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "name", badge.name },
                { "description", badge.description },
                { "iconType", badge.iconType },
                { "icon", badge.icon }
            };

            ServerRequest.CallAPI("/interactive/badges/" + badge._id, HTTPMethod.PUT, body, (r) => ServerRequest.ResponseHandler(r, null, onComplete), true);
        }
        public static void CreateInstructorDeck(Action <InstructorDeckResponse> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "team", User.current.selectedMembership.team._id },
                { "deck", new InteractiveInstructorDeck()
                  {
                      name = "NEW INSTRUCTOR DECK"
                  } }
            };

            ServerRequest.CallAPI("/interactive/instructor/decks/create", HTTPMethod.POST, body, (response) => ServerRequest.ResponseHandler(response, null, onComplete), true);
        }
        public static void CreateBadge(InteractiveBadge badge, Action <InteractiveBadge> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "team", User.current.selectedMembership.team._id },
                { "name", badge.name },
                { "description", badge.description },
                { "icon", badge.icon },
                { "iconType", badge.iconType }
            };

            ServerRequest.CallAPI("/interactive/badges/create", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, "badge", onComplete); }, true);
        }
        public static void UpdateTheme(InteractiveTheme theme, Action <InteractiveTheme> onComplete)
        {
            Debug.Log("Updating theme: " + theme.name);
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "name", theme.name },
                { "bgURL", theme.bgURL },
                { "levelSelectStyle", theme.levelSelectStyle },
                { "lessonAreaStyle", theme.lessonAreaStyle }
            };

            ServerRequest.CallAPI("/interactive/themes/" + theme._id, HTTPMethod.PUT, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
        public static void CreateTheme(InteractiveTheme theme, Action <InteractiveTheme> onComplete)
        {
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "name", theme.name },
                { "bgURL", theme.bgURL },
                { "levelSelectStyle", theme.levelSelectStyle },
                { "lessonAreaStyle", theme.lessonAreaStyle },
                { "team", User.current.selectedMembership.team._id }
            };

            ServerRequest.CallAPI("/interactive/themes/create", HTTPMethod.POST, body, (r) => { ServerRequest.ResponseHandler(r, null, onComplete); }, true);
        }
Exemplo n.º 29
0
        public static void CompleteCourse(InteractiveCourse course, bool complete, Action <CourseProgress[]> onComplete)
        {
            //PUT /api/interactive/progress
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
                { "type", "course" },
                { "course", course._id },
                { "complete", complete },
                { "member", User.current.selectedMembership._id }
            };

            ServerRequest.CallAPI("/interactive/progress", HTTPMethod.PUT, body, (r) => ServerRequest.ResponseHandler(r, "userProgress", onComplete), true);
        }
Exemplo n.º 30
0
        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);
        }