Google课堂:我如何获得studentSubmissionId?

时间:2018-05-08 19:04:40

标签: google-classroom

我有courseWorkId,courseId和学生电子邮件。我已经验证他们使用API​​资源管理器来获取数据是正确的。我想获得studentSubmissionId所以我可以修补成绩并指定分数。我不是很快与JSON,似乎无法解析下面的响应我得到的值。

function getSubmissionId(stdEmail) {

    gapi.client.classroom.courses.courseWork.studentSubmissions.list({
          courseId: gCourseId,
          courseWorkId: gCourseWorkId,
          userId:'stdEmail'
        }).then(function(response) {

        // response.result...??
        // how to I parse this??

        });

}

2 个答案:

答案 0 :(得分:0)

在线查看如何访问JSON Objects

var myObj = { "name":"John",
              "age":30,
              "car":{
                      "brand": "Ferrari"
                    }
             };
x = myObj.age
y = myObj["car"]["brand"];

console.log(x); // returns 30
console.log(y); // returns Ferrari

答案 1 :(得分:0)

这对我来说很有效,它获取了StudentSubmissionId。

function getSubmissionId(stdEmail) {

var gStudentSubmissionID;

gapi.client.classroom.courses.courseWork.studentSubmissions.list({
      courseId: gCourseId,
      courseWorkId: gCourseWorkId,
      userId: stdEmail
    }).then(function(response) {

    gStudentSubmissionID = response.result.studentSubmissions[0].id;

    //console.log(response.result.studentSubmissions[0].id);
    console.log('associatedWithDeveloper: '+response.result.studentSubmissions[0].associatedWithDeveloper);  

    });

}