0

Hi everyone this is been driving me mad so I hope you can help

I am trying to use patch() to assigne a draft grade to an assignment but keep getting the error (patch) unknown parameter: 'draftGrade'

here is my code created in laravel PHP

$this->client->setAccessToken($_SESSION['access_token']);
        $service = new \Google_Service_Classroom($this->client);
        $courseId = '17531696064';
        $courseWorkId = '29297231820';
        $id = 'CgwI9aG3lwkQzI-Bkm0';
        $post_body = new \Google_Service_Classroom_StudentSubmission(array(
            'updateMask' => 'draftGrade',

        ));
        $opt_params = array(
            'draftGrade' => 90,
        );
        $list = $service->courses_courseWork_studentSubmissions->patch($courseId, $courseWorkId, $id, $post_body, $opt_params);

I have also used the following but still have no joy.

$list = $service->courses_courseWork_studentSubmissions->patch(17531696064,
            29297231820,
            'CgwI9aG3lwkQzI-Bkm0',
            new \Google_Service_Classroom_StudentSubmission(array('updateMask' => 'draftGrade')),
            array ('resource' =>['draftGrade' => 90] ));

Any help would be great.

1 Answers1

1

There can be one of two things you are doing wrong :-

  1. You have to pass update mask = 'assignedGrade' as a query parameter and also in the requestBody.
  2. What worked for me, I first assigned a grade as draft grade and assigned the same grade as draftGrade as well as assignedGrade in next request and the grade of the studentSubmission changed and the submission got returned as well.