StudentSubmissions.Patch UpdateMask Error

孤者浪人 提交于 2019-12-23 05:51:32

问题


Trying to use the StudentSubmissions.Patch part of the Classroom API in Google Apps Script and keeping running across this error

updateMask: updateMask may only contain "draftGrade" or "assignedGrade"

Here is my code for that particular section:

var studentSubmission = {'draft_grade':'88'}
var patchC = Classroom.Courses.CourseWork.StudentSubmissions.patch(studentSubmission, courseId, cwId, submissionId);

There is clearly something wrong with the way I am passing the StudentSubmission Resource parameter, but I can't figure out why...

This is clearly the documentation I am referring to - https://developers.google.com/classroom/reference/rest/v1/courses.courseWork.studentSubmissions/patch

UPDATE

I was able to change the code a bit to reflect what you both were saying. Obviously, I didn't use exactly what you both said because KENdi's example is in Python and Ein2012, it would error out on the var patchC = Classroom... line.

I changed some things that now look like this:

var studentSubmission = {'draftGrade':'88'}
   var extra =  {'updateMask':'draftGrade'};
   var patchC = Classroom.Courses.CourseWork.StudentSubmissions.patch(studentSubmission, courseId, cwId, submissionId, extra);

But now I get a different error "@ProjectPermissionDenied The Developer Console project is not permitted to make this request". So, now I'm unsure if that formatting is correct and there is some Developer Console situation I haven't resolved (although feel as though I'm correct), or that new formatting is wrong and I'm just getting the wild permission error.

I saw this Similar Error but what if the course work was one created normally through classroom and not via a script? Ahh.


回答1:


specify update mask fields and later execute and also specify names as instructed in the documentation ("draftGrade","assignedGrade")

var studentSubmission = {'draftGrade':'88'}
var patchC = Classroom.Courses.CourseWork.StudentSubmissions.patch(studentSubmission, courseId, cwId, submissionId);
patchC.UpdateMask = "draftGrade";


var response = submisionObj.Execute();



回答2:


From your error, it is stated that the updateMask must only contain "draftGrade" or "assignedGrade". So from your code, you need only that two value for the updateMask.

The updateMask identifies which fields on the student submission to update. This field is required to do an update. The update fails if invalid fields are specified

From this documentation, The StudentSubmission resource has two fields to store grades: assignedGrade, which is the grade reported to students, and draftGrade, which is a tentative grade visible only to teachers. These fields are updated using courses.courseWork.studentSubmissions.patch with a field mask containing the appropriate fields.

Here is the example code on how to do that.

studentSubmission = { 
'assignedGrade': 99, 
'draftGrade': 80 
} 
service.courses().courseWork().studentSubmission().patch( 
courseId=<course ID or alias>, 
courseWorkId=<courseWork ID>, 
id=<studentSubmission ID>, 
updateMask='assignedGrade,draftGrade', 
body=studentSubmission).execute()


来源:https://stackoverflow.com/questions/38484693/studentsubmissions-patch-updatemask-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!