2017-06-23 48 views
0

我试图创建一个附带了多个文件中的课堂作业,这里是我的代码有一个文件:将多个文件附加到Google课堂作业?

Classroom.Courses.CourseWork.create({ 
     courseId: id, 
     title : title, 
     description : desc, 
     workType : 'ASSIGNMENT', 
     materials: [ 
      { 
      driveFile:{ 
       driveFile: { 
       id: fileId, 
       title: fileName 
       }, 
       shareMode: "STUDENT_COPY" 
      }, 
      } 
     ], 
     state : "PUBLISHED" 
     }, id) 

如何添加其他文件?我试图重复“driveFile”,但没有运气:

materials: [ 
     { 
     driveFile:{ 
      driveFile: { 
      id: fileId, 
      title: fileName 
      }, 
      shareMode: "STUDENT_COPY" 
     }, 
     driveFile:{ 
      driveFile: { 
      id: fileId, 
      title: fileName 
      }, 
      shareMode: "STUDENT_COPY" 
     }, 
     } 
    ], 

在此找不到任何文档或其他问题。

谢谢!

回答

1

试试这个代码:

{ 
    "workType": "ASSIGNMENT", 
    "materials": [ 
    { 
     "driveFile": { 
     "driveFile": { 
      "id": "FILE_ID", 
      "title": "TestingFile" 
     }, 
     "shareMode": "STUDENT_COPY" 
     } 
    }, 
    { 
     "driveFile": { 
     "driveFile": { 
      "id": "FILE_ID", 
      "title": "Sample Docs" 
     }, 
     "shareMode": "STUDENT_COPY" 
     } 
    } 
    ], 
    "description": "Assignment 1 &2", 
    "title": "Assignment" 
} 

下面是结果:

enter image description here

我试了一下使用Method: courses.courseWork.create试试这个API来帮助我正确地构建请求。

希望这会有所帮助。