gpt4 book ai didi

javascript - How do I edit scopes?//Google Classroom control permission scopes in google apps scripts for student access 权限范围

转载 作者:行者123 更新时间:2023-12-01 17:34:24 24 4
gpt4 key购买 nike

我是一名高中教师,正在针对 Google Classroom 编写 Google Apps 脚本。我想创建一个电子表格,例如我的学生成绩 View ,我的学生可以使用他们的凭据访问。

我已经成功地编写了代码,这样我就可以通过在代码中显式放置学生的 Id 来以我的权限运行它。此外,我已经成功地用 Python 编写了代码,我可以在其中明确设置学生访问此(且仅此)信息所需的两个范围。但是,Google Apps 脚本自动范围生成让我受阻,因为我不能明确地只请求我想要的 2 个范围。

这是我用 python 编写时工作的两个作用域:

SCOPES = ['https://www.googleapis.com/auth/classroom.coursework.me.readonly https://www.googleapis.com/auth/classroom.student-submissions.me.readonly']

下面是 Google Apps 脚本自动生成的范围。

5 OAuth Scopes required by the script:
https://www.googleapis.com/auth/classroom.courses
https://www.googleapis.com/auth/classroom.coursework.students
https://www.googleapis.com/auth/classroom.profile.emails
https://www.googleapis.com/auth/classroom.profile.photos
https://www.googleapis.com/auth/classroom.rosters

这是我的代码:

function doGet() {
return HtmlService.createHtmlOutputFromFile('Index');
}

function getMyGrades() {
var pageToken;
var studentSubmissionsArray = [];


//Get Student Submissions for the logged in student that is running this app
do {
var optionalArgs = {
'pageToken': pageToken,
'userId' : 'me',
};
var response = Classroom.Courses.CourseWork.StudentSubmissions.list(courseId='7131560586', courseWorkId='-', optionalArgs);
var studentSubmissions = response.studentSubmissions;
if (studentSubmissions && studentSubmissions.length > 0) {
for (i = 0; i < studentSubmissions.length; i++) {
var studentSubmission = studentSubmissions[i];
var courseworkResponse = Classroom.Courses.CourseWork.get(courseId = '7131560586', id = studentSubmission.courseWorkId)
var studentSubmissionArray = [courseworkResponse.title, courseworkResponse.maxPoints];
studentSubmissionArray.push(studentSubmission.assignedGrade, studentSubmission.courseWorkType, studentSubmission.late, studentSubmission.state, studentSubmission.courseWorkId);
studentSubmissionsArray.push(studentSubmissionArray);
}
} else {
studentSubmissionsTable = "No Students Found";
}
pageToken = response.nextPageToken;

} while (pageToken);

studentSubmissionsArray.sort()

var studentSubmissionsTable = "<table border = 1, cellpadding = 8><tr><th>#</th><th>Title</th><th>Max Points</th><th>Assigned Grade</th><th>Type</th><th>late</th><th>State</th><th>Coursework ID</th></tr>"
if (studentSubmissionsArray && studentSubmissionsArray.length > 0) {
for (i = 0; i < studentSubmissionsArray.length; i++) {
c = i + 1;
studentSubmissionArray = studentSubmissionsArray[i];
studentSubmissionsTable = studentSubmissionsTable + '<tr><td>'+c+'</td><td>'+ studentSubmissionArray[0] + '</td><td>' + studentSubmissionArray[1] + '</td><td>' + studentSubmissionArray[2] + '</td><td>' + studentSubmissionArray[3] + '</td><td>' + studentSubmissionArray[4] + '</td><td>' + studentSubmissionArray[5] + '</td><td>' + studentSubmissionArray[6] + '</td></tr>'
}
studentSubmissionsTable = studentSubmissionsTable + '</table>'
}

return studentSubmissionsTable
}

最佳答案

...because I can't explicitly ask for only the 2 scopes I want.

为此,请从您的 Apps 脚本编辑器导航至查看 > 显示项目 list -

Manifest

...然后根据需要指定授权范围。您可能会找到有关相同信息的更多信息 here并引用整个 manifest structure如所须。希望这会有所帮助。

关于javascript - How do I edit scopes?//Google Classroom control permission scopes in google apps scripts for student access 权限范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46142164/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com