【问题标题】:App Script Google Classroom API adding teachers to a course via batch press (loop)App Script Google Classroom API 通过批处理(循环)将教师添加到课程中
【发布时间】:2020-08-09 07:37:24
【问题描述】:
function testScripts() {
  var courses = [12345678902, 123425373134];
    
  var newTeacher = ["teacher@mail.com", "teacher@mail.com"];
    
  for (x = 0; x <= courses.length - 1; x++) {
    var final = courses[x];
    var finalT = newTeacher[x];
    
    var addTeacher = Classroom.Courses.Teachers.create(
      { userId: finalT }, final
    );
  }
}

我试过这段代码,但它给了我这个错误:GoogleJsonResponseException: API call to classroom.courses.teachers.create failed with error: Requested entity already exists

只有数组中的第一门课程会更新为要添加的新教师。

谢谢!

【问题讨论】:

  • 您可能需要考虑在线学习 JavaScript 课程

标签: javascript google-apps-script google-classroom


【解决方案1】:
var courses = [12345678902, 123425373134];
    
var newTeacher = ["teacher@mail.com", "teacher@mail.com"];

for (x = 0; x <= courses.length - 1; x++) {
  Classroom.Courses.Teachers.create(
    {userId: newTeacher[x]}, courses[x]
  );
}

解决了。将其指向上面声明的变量。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-31
    • 2020-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多