Example #1
0
        public async static Task <List <Course> > GetAllStudentActiveCourses(UserCredential credential)
        {
            var service = new ClassroomService(new BaseClientService.Initializer
            {
                HttpClientInitializer = credential,

                ApplicationName = "UbiGrade"
            });

            CoursesResource.ListRequest request = service.Courses.List();
            // Restricts returned courses to those in one of the specified states
            // The default value is ACTIVE, ARCHIVED, PROVISIONED, DECLINED.
            request.CourseStates = CoursesResource.ListRequest.CourseStatesEnum.ACTIVE;
            // Restricts returned courses to those having a teacher with the specified identifier. The identifier can be one of the following:
            // - the numeric identifier for the user
            // - the email address of the user
            // - the string literal "me", indicating the requesting user
            //request.TeacherId = "me";

            // List courses.
            List <Course>       courses  = new List <Course>();
            ListCoursesResponse response = await request.ExecuteAsync();

            courses.AddRange(response.Courses);
            return(courses);
        }
Example #2
0
        public async static Task <List <Course> > GetAllStudentActiveCoursesByAccesstoken(UserCredential credential)
        {
            var service = new ClassroomService(new BaseClientService.Initializer
            {
                HttpClientInitializer = credential,
                ApplicationName       = "UbiGrade"
            });

            CoursesResource.ListRequest request = service.Courses.List();
            request.CourseStates = CoursesResource.ListRequest.CourseStatesEnum.ACTIVE;
            List <Course>       courses  = new List <Course>();
            ListCoursesResponse response = await request.ExecuteAsync();

            courses.AddRange(response.Courses);
            return(courses);
        }