从谷歌课堂课程获得课程作业

时间:2017-02-14 00:15:23

标签: c# c#-4.0 google-classroom

我试图从课程列表中获取CourseWork对象列表,并将每个课程对象添加到列表中。但是我不知道如何获得Coursework对象,我认为它与eTags或Ids有关,但无法知道。我使用的代码如下:

    public static IList<Course> GetAllCourses()
    {
        CoursesResource.ListRequest request = ClassService.Courses.List();
        request.PageSize = 100;

        ListCoursesResponse response = request.Execute();
        GoogleClassroomCourses = response.Courses;

        return GoogleClassroomCourses;
    }

    public static IList<CourseWork> GetCourseWork()
    {
        IList<string> courseIds = new List<string>();
        IList<string> eTags = new List<string>();

        foreach (Course course in GetAllCourses())
        {
            string id = course.Id;
            courseIds.Add(id);
            foreach (string cId in courseIds)
            {
                Course c = ClassService.Courses.Get(cId).Execute();
                eTags.Add(c.ETag);
            }
        }
    }

1 个答案:

答案 0 :(得分:0)

您可能希望使用此HTTP请求格式使用Method: courses.courseWork.list

GET https://classroom.googleapis.com/v1/courses/{courseId}/courseWork

如果成功,则返回与响应正文中的请求匹配的课程工作项。

示例JSON表示:

{
  "courseWork": [
    {
      object(CourseWork)
    }
  ],
  "nextPageToken": string,
}