1 | <?php
|
---|
2 | /*
|
---|
3 | * Copyright 2014 Google Inc.
|
---|
4 | *
|
---|
5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
---|
6 | * use this file except in compliance with the License. You may obtain a copy of
|
---|
7 | * the License at
|
---|
8 | *
|
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 | *
|
---|
11 | * Unless required by applicable law or agreed to in writing, software
|
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
---|
13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
---|
14 | * License for the specific language governing permissions and limitations under
|
---|
15 | * the License.
|
---|
16 | */
|
---|
17 |
|
---|
18 | namespace Google\Service\Classroom\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Classroom\AddOnContext;
|
---|
21 | use Google\Service\Classroom\ClassroomEmpty;
|
---|
22 | use Google\Service\Classroom\CourseWork;
|
---|
23 | use Google\Service\Classroom\ListCourseWorkResponse;
|
---|
24 | use Google\Service\Classroom\ModifyCourseWorkAssigneesRequest;
|
---|
25 | use Google\Service\Classroom\Rubric;
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * The "courseWork" collection of methods.
|
---|
29 | * Typical usage is:
|
---|
30 | * <code>
|
---|
31 | * $classroomService = new Google\Service\Classroom(...);
|
---|
32 | * $courseWork = $classroomService->courses_courseWork;
|
---|
33 | * </code>
|
---|
34 | */
|
---|
35 | class CoursesCourseWork extends \Google\Service\Resource
|
---|
36 | {
|
---|
37 | /**
|
---|
38 | * Creates course work. The resulting course work (and corresponding student
|
---|
39 | * submissions) are associated with the Developer Console project of the [OAuth
|
---|
40 | * client ID](https://support.google.com/cloud/answer/6158849) used to make the
|
---|
41 | * request. Classroom API requests to modify course work and student submissions
|
---|
42 | * must be made with an OAuth client ID from the associated Developer Console
|
---|
43 | * project. This method returns the following error codes: * `PERMISSION_DENIED`
|
---|
44 | * if the requesting user is not permitted to access the requested course,
|
---|
45 | * create course work in the requested course, share a Drive attachment, or for
|
---|
46 | * access errors. * `INVALID_ARGUMENT` if the request is malformed. *
|
---|
47 | * `NOT_FOUND` if the requested course does not exist. * `FAILED_PRECONDITION`
|
---|
48 | * for the following request error: * AttachmentNotVisible (courseWork.create)
|
---|
49 | *
|
---|
50 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
51 | * either the Classroom-assigned identifier or an alias.
|
---|
52 | * @param CourseWork $postBody
|
---|
53 | * @param array $optParams Optional parameters.
|
---|
54 | * @return CourseWork
|
---|
55 | * @throws \Google\Service\Exception
|
---|
56 | */
|
---|
57 | public function create($courseId, CourseWork $postBody, $optParams = [])
|
---|
58 | {
|
---|
59 | $params = ['courseId' => $courseId, 'postBody' => $postBody];
|
---|
60 | $params = array_merge($params, $optParams);
|
---|
61 | return $this->call('create', [$params], CourseWork::class);
|
---|
62 | }
|
---|
63 | /**
|
---|
64 | * Deletes a course work. This request must be made by the Developer Console
|
---|
65 | * project of the [OAuth client
|
---|
66 | * ID](https://support.google.com/cloud/answer/6158849) used to create the
|
---|
67 | * corresponding course work item. This method returns the following error
|
---|
68 | * codes: * `PERMISSION_DENIED` if the requesting developer project did not
|
---|
69 | * create the corresponding course work, if the requesting user is not permitted
|
---|
70 | * to delete the requested course or for access errors. * `FAILED_PRECONDITION`
|
---|
71 | * if the requested course work has already been deleted. * `NOT_FOUND` if no
|
---|
72 | * course exists with the requested ID. (courseWork.delete)
|
---|
73 | *
|
---|
74 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
75 | * either the Classroom-assigned identifier or an alias.
|
---|
76 | * @param string $id Identifier of the course work to delete. This identifier is
|
---|
77 | * a Classroom-assigned identifier.
|
---|
78 | * @param array $optParams Optional parameters.
|
---|
79 | * @return ClassroomEmpty
|
---|
80 | * @throws \Google\Service\Exception
|
---|
81 | */
|
---|
82 | public function delete($courseId, $id, $optParams = [])
|
---|
83 | {
|
---|
84 | $params = ['courseId' => $courseId, 'id' => $id];
|
---|
85 | $params = array_merge($params, $optParams);
|
---|
86 | return $this->call('delete', [$params], ClassroomEmpty::class);
|
---|
87 | }
|
---|
88 | /**
|
---|
89 | * Returns course work. This method returns the following error codes: *
|
---|
90 | * `PERMISSION_DENIED` if the requesting user is not permitted to access the
|
---|
91 | * requested course or course work, or for access errors. * `INVALID_ARGUMENT`
|
---|
92 | * if the request is malformed. * `NOT_FOUND` if the requested course or course
|
---|
93 | * work does not exist. (courseWork.get)
|
---|
94 | *
|
---|
95 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
96 | * either the Classroom-assigned identifier or an alias.
|
---|
97 | * @param string $id Identifier of the course work.
|
---|
98 | * @param array $optParams Optional parameters.
|
---|
99 | * @return CourseWork
|
---|
100 | * @throws \Google\Service\Exception
|
---|
101 | */
|
---|
102 | public function get($courseId, $id, $optParams = [])
|
---|
103 | {
|
---|
104 | $params = ['courseId' => $courseId, 'id' => $id];
|
---|
105 | $params = array_merge($params, $optParams);
|
---|
106 | return $this->call('get', [$params], CourseWork::class);
|
---|
107 | }
|
---|
108 | /**
|
---|
109 | * Gets metadata for Classroom add-ons in the context of a specific post. To
|
---|
110 | * maintain the integrity of its own data and permissions model, an add-on
|
---|
111 | * should call this to validate query parameters and the requesting user's role
|
---|
112 | * whenever the add-on is opened in an
|
---|
113 | * [iframe](https://developers.google.com/classroom/add-ons/get-
|
---|
114 | * started/iframes/iframes-overview). This method returns the following error
|
---|
115 | * codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the
|
---|
116 | * request is malformed. * `NOT_FOUND` if one of the identified resources does
|
---|
117 | * not exist. (courseWork.getAddOnContext)
|
---|
118 | *
|
---|
119 | * @param string $courseId Required. Identifier of the course.
|
---|
120 | * @param string $itemId Identifier of the `Announcement`, `CourseWork`, or
|
---|
121 | * `CourseWorkMaterial` under which the attachment is attached. This field is
|
---|
122 | * required, but is not marked as such while we are migrating from post_id.
|
---|
123 | * @param array $optParams Optional parameters.
|
---|
124 | *
|
---|
125 | * @opt_param string addOnToken Optional. Token that authorizes the request. The
|
---|
126 | * token is passed as a query parameter when the user is redirected from
|
---|
127 | * Classroom to the add-on's URL. The authorization token is required when
|
---|
128 | * neither of the following is true: * The add-on has attachments on the post. *
|
---|
129 | * The developer project issuing the request is the same project that created
|
---|
130 | * the post.
|
---|
131 | * @opt_param string attachmentId Optional. The identifier of the attachment.
|
---|
132 | * This field is required for all requests except when the user is in the
|
---|
133 | * [Attachment Discovery iframe](https://developers.google.com/classroom/add-
|
---|
134 | * ons/get-started/iframes/attachment-discovery-iframe).
|
---|
135 | * @opt_param string postId Optional. Deprecated, use `item_id` instead.
|
---|
136 | * @return AddOnContext
|
---|
137 | * @throws \Google\Service\Exception
|
---|
138 | */
|
---|
139 | public function getAddOnContext($courseId, $itemId, $optParams = [])
|
---|
140 | {
|
---|
141 | $params = ['courseId' => $courseId, 'itemId' => $itemId];
|
---|
142 | $params = array_merge($params, $optParams);
|
---|
143 | return $this->call('getAddOnContext', [$params], AddOnContext::class);
|
---|
144 | }
|
---|
145 | /**
|
---|
146 | * Returns a list of course work that the requester is permitted to view. Course
|
---|
147 | * students may only view `PUBLISHED` course work. Course teachers and domain
|
---|
148 | * administrators may view all course work. This method returns the following
|
---|
149 | * error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to
|
---|
150 | * access the requested course or for access errors. * `INVALID_ARGUMENT` if the
|
---|
151 | * request is malformed. * `NOT_FOUND` if the requested course does not exist.
|
---|
152 | * (courseWork.listCoursesCourseWork)
|
---|
153 | *
|
---|
154 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
155 | * either the Classroom-assigned identifier or an alias.
|
---|
156 | * @param array $optParams Optional parameters.
|
---|
157 | *
|
---|
158 | * @opt_param string courseWorkStates Restriction on the work status to return.
|
---|
159 | * Only courseWork that matches is returned. If unspecified, items with a work
|
---|
160 | * status of `PUBLISHED` is returned.
|
---|
161 | * @opt_param string orderBy Optional sort ordering for results. A comma-
|
---|
162 | * separated list of fields with an optional sort direction keyword. Supported
|
---|
163 | * fields are `updateTime` and `dueDate`. Supported direction keywords are `asc`
|
---|
164 | * and `desc`. If not specified, `updateTime desc` is the default behavior.
|
---|
165 | * Examples: `dueDate asc,updateTime desc`, `updateTime,dueDate desc`
|
---|
166 | * @opt_param int pageSize Maximum number of items to return. Zero or
|
---|
167 | * unspecified indicates that the server may assign a maximum. The server may
|
---|
168 | * return fewer than the specified number of results.
|
---|
169 | * @opt_param string pageToken nextPageToken value returned from a previous list
|
---|
170 | * call, indicating that the subsequent page of results should be returned. The
|
---|
171 | * list request must be otherwise identical to the one that resulted in this
|
---|
172 | * token.
|
---|
173 | * @return ListCourseWorkResponse
|
---|
174 | * @throws \Google\Service\Exception
|
---|
175 | */
|
---|
176 | public function listCoursesCourseWork($courseId, $optParams = [])
|
---|
177 | {
|
---|
178 | $params = ['courseId' => $courseId];
|
---|
179 | $params = array_merge($params, $optParams);
|
---|
180 | return $this->call('list', [$params], ListCourseWorkResponse::class);
|
---|
181 | }
|
---|
182 | /**
|
---|
183 | * Modifies assignee mode and options of a coursework. Only a teacher of the
|
---|
184 | * course that contains the coursework may call this method. This method returns
|
---|
185 | * the following error codes: * `PERMISSION_DENIED` if the requesting user is
|
---|
186 | * not permitted to access the requested course or course work or for access
|
---|
187 | * errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if
|
---|
188 | * the requested course or course work does not exist.
|
---|
189 | * (courseWork.modifyAssignees)
|
---|
190 | *
|
---|
191 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
192 | * either the Classroom-assigned identifier or an alias.
|
---|
193 | * @param string $id Identifier of the coursework.
|
---|
194 | * @param ModifyCourseWorkAssigneesRequest $postBody
|
---|
195 | * @param array $optParams Optional parameters.
|
---|
196 | * @return CourseWork
|
---|
197 | * @throws \Google\Service\Exception
|
---|
198 | */
|
---|
199 | public function modifyAssignees($courseId, $id, ModifyCourseWorkAssigneesRequest $postBody, $optParams = [])
|
---|
200 | {
|
---|
201 | $params = ['courseId' => $courseId, 'id' => $id, 'postBody' => $postBody];
|
---|
202 | $params = array_merge($params, $optParams);
|
---|
203 | return $this->call('modifyAssignees', [$params], CourseWork::class);
|
---|
204 | }
|
---|
205 | /**
|
---|
206 | * Updates one or more fields of a course work. See
|
---|
207 | * google.classroom.v1.CourseWork for details of which fields may be updated and
|
---|
208 | * who may change them. This request must be made by the Developer Console
|
---|
209 | * project of the [OAuth client
|
---|
210 | * ID](https://support.google.com/cloud/answer/6158849) used to create the
|
---|
211 | * corresponding course work item. This method returns the following error
|
---|
212 | * codes: * `PERMISSION_DENIED` if the requesting developer project did not
|
---|
213 | * create the corresponding course work, if the user is not permitted to make
|
---|
214 | * the requested modification to the student submission, or for access errors. *
|
---|
215 | * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if
|
---|
216 | * the requested course work has already been deleted. * `NOT_FOUND` if the
|
---|
217 | * requested course or course work does not exist. (courseWork.patch)
|
---|
218 | *
|
---|
219 | * @param string $courseId Identifier of the course. This identifier can be
|
---|
220 | * either the Classroom-assigned identifier or an alias.
|
---|
221 | * @param string $id Identifier of the course work.
|
---|
222 | * @param CourseWork $postBody
|
---|
223 | * @param array $optParams Optional parameters.
|
---|
224 | *
|
---|
225 | * @opt_param string updateMask Mask that identifies which fields on the course
|
---|
226 | * work to update. This field is required to do an update. The update fails if
|
---|
227 | * invalid fields are specified. If a field supports empty values, it can be
|
---|
228 | * cleared by specifying it in the update mask and not in the `CourseWork`
|
---|
229 | * object. If a field that does not support empty values is included in the
|
---|
230 | * update mask and not set in the `CourseWork` object, an `INVALID_ARGUMENT`
|
---|
231 | * error is returned. The following fields may be specified by teachers: *
|
---|
232 | * `title` * `description` * `state` * `due_date` * `due_time` * `max_points` *
|
---|
233 | * `scheduled_time` * `submission_modification_mode` * `topic_id` *
|
---|
234 | * `grading_period_id` Available in [V1_20240401_PREVIEW](https://developers.goo
|
---|
235 | * gle.com/classroom/reference/preview) and later.
|
---|
236 | * @return CourseWork
|
---|
237 | * @throws \Google\Service\Exception
|
---|
238 | */
|
---|
239 | public function patch($courseId, $id, CourseWork $postBody, $optParams = [])
|
---|
240 | {
|
---|
241 | $params = ['courseId' => $courseId, 'id' => $id, 'postBody' => $postBody];
|
---|
242 | $params = array_merge($params, $optParams);
|
---|
243 | return $this->call('patch', [$params], CourseWork::class);
|
---|
244 | }
|
---|
245 | /**
|
---|
246 | * Updates a rubric. See google.classroom.v1.Rubric for details of which fields
|
---|
247 | * can be updated. Rubric update capabilities are
|
---|
248 | * [limited](/classroom/rubrics/limitations) once grading has started. This
|
---|
249 | * request must be made by the Google Cloud console of the [OAuth client
|
---|
250 | * ID](https://support.google.com/cloud/answer/6158849) used to create the
|
---|
251 | * parent course work item. This method returns the following error codes: *
|
---|
252 | * `PERMISSION_DENIED` if the requesting developer project didn't create the
|
---|
253 | * corresponding course work, if the user isn't permitted to make the requested
|
---|
254 | * modification to the rubric, or for access errors. This error code is also
|
---|
255 | * returned if grading has already started on the rubric. * `INVALID_ARGUMENT`
|
---|
256 | * if the request is malformed and for the following request error: *
|
---|
257 | * `RubricCriteriaInvalidFormat` * `NOT_FOUND` if the requested course, course
|
---|
258 | * work, or rubric doesn't exist or if the user doesn't have access to the
|
---|
259 | * corresponding course work. * `INTERNAL` if grading has already started on the
|
---|
260 | * rubric. (courseWork.updateRubric)
|
---|
261 | *
|
---|
262 | * @param string $courseId Required. Identifier of the course.
|
---|
263 | * @param string $courseWorkId Required. Identifier of the course work.
|
---|
264 | * @param Rubric $postBody
|
---|
265 | * @param array $optParams Optional parameters.
|
---|
266 | *
|
---|
267 | * @opt_param string id Optional. Identifier of the rubric.
|
---|
268 | * @opt_param string updateMask Optional. Mask that identifies which fields on
|
---|
269 | * the rubric to update. This field is required to do an update. The update
|
---|
270 | * fails if invalid fields are specified. There are multiple options to define
|
---|
271 | * the criteria of a rubric: the `source_spreadsheet_id` and the `criteria`
|
---|
272 | * list. Only one of these can be used at a time to define a rubric. The rubric
|
---|
273 | * `criteria` list is fully replaced by the rubric criteria specified in the
|
---|
274 | * update request. For example, if a criterion or level is missing from the
|
---|
275 | * request, it is deleted. New criteria and levels are added and an ID is
|
---|
276 | * assigned. Existing criteria and levels retain the previously assigned ID if
|
---|
277 | * the ID is specified in the request. The following fields can be specified by
|
---|
278 | * teachers: * `criteria` * `source_spreadsheet_id`
|
---|
279 | * @return Rubric
|
---|
280 | * @throws \Google\Service\Exception
|
---|
281 | */
|
---|
282 | public function updateRubric($courseId, $courseWorkId, Rubric $postBody, $optParams = [])
|
---|
283 | {
|
---|
284 | $params = ['courseId' => $courseId, 'courseWorkId' => $courseWorkId, 'postBody' => $postBody];
|
---|
285 | $params = array_merge($params, $optParams);
|
---|
286 | return $this->call('updateRubric', [$params], Rubric::class);
|
---|
287 | }
|
---|
288 | }
|
---|
289 |
|
---|
290 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
291 | class_alias(CoursesCourseWork::class, 'Google_Service_Classroom_Resource_CoursesCourseWork');
|
---|