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
18namespace Google\Service\Classroom\Resource;
19
20use Google\Service\Classroom\ClassroomEmpty;
21use Google\Service\Classroom\CourseWork;
22use Google\Service\Classroom\ListCourseWorkResponse;
23use Google\Service\Classroom\ModifyCourseWorkAssigneesRequest;
24
25/**
26 * The "courseWork" collection of methods.
27 * Typical usage is:
28 *  <code>
29 *   $classroomService = new Google\Service\Classroom(...);
30 *   $courseWork = $classroomService->courseWork;
31 *  </code>
32 */
33class CoursesCourseWork extends \Google\Service\Resource
34{
35  /**
36   * Creates course work. The resulting course work (and corresponding student
37   * submissions) are associated with the Developer Console project of the [OAuth
38   * client ID](https://support.google.com/cloud/answer/6158849) used to make the
39   * request. Classroom API requests to modify course work and student submissions
40   * must be made with an OAuth client ID from the associated Developer Console
41   * project. This method returns the following error codes: * `PERMISSION_DENIED`
42   * if the requesting user is not permitted to access the requested course,
43   * create course work in the requested course, share a Drive attachment, or for
44   * access errors. * `INVALID_ARGUMENT` if the request is malformed. *
45   * `NOT_FOUND` if the requested course does not exist. * `FAILED_PRECONDITION`
46   * for the following request error: * AttachmentNotVisible (courseWork.create)
47   *
48   * @param string $courseId Identifier of the course. This identifier can be
49   * either the Classroom-assigned identifier or an alias.
50   * @param CourseWork $postBody
51   * @param array $optParams Optional parameters.
52   * @return CourseWork
53   */
54  public function create($courseId, CourseWork $postBody, $optParams = [])
55  {
56    $params = ['courseId' => $courseId, 'postBody' => $postBody];
57    $params = array_merge($params, $optParams);
58    return $this->call('create', [$params], CourseWork::class);
59  }
60  /**
61   * Deletes a course work. This request must be made by the Developer Console
62   * project of the [OAuth client
63   * ID](https://support.google.com/cloud/answer/6158849) used to create the
64   * corresponding course work item. This method returns the following error
65   * codes: * `PERMISSION_DENIED` if the requesting developer project did not
66   * create the corresponding course work, if the requesting user is not permitted
67   * to delete the requested course or for access errors. * `FAILED_PRECONDITION`
68   * if the requested course work has already been deleted. * `NOT_FOUND` if no
69   * course exists with the requested ID. (courseWork.delete)
70   *
71   * @param string $courseId Identifier of the course. This identifier can be
72   * either the Classroom-assigned identifier or an alias.
73   * @param string $id Identifier of the course work to delete. This identifier is
74   * a Classroom-assigned identifier.
75   * @param array $optParams Optional parameters.
76   * @return ClassroomEmpty
77   */
78  public function delete($courseId, $id, $optParams = [])
79  {
80    $params = ['courseId' => $courseId, 'id' => $id];
81    $params = array_merge($params, $optParams);
82    return $this->call('delete', [$params], ClassroomEmpty::class);
83  }
84  /**
85   * Returns course work. This method returns the following error codes: *
86   * `PERMISSION_DENIED` if the requesting user is not permitted to access the
87   * requested course or course work, or for access errors. * `INVALID_ARGUMENT`
88   * if the request is malformed. * `NOT_FOUND` if the requested course or course
89   * work does not exist. (courseWork.get)
90   *
91   * @param string $courseId Identifier of the course. This identifier can be
92   * either the Classroom-assigned identifier or an alias.
93   * @param string $id Identifier of the course work.
94   * @param array $optParams Optional parameters.
95   * @return CourseWork
96   */
97  public function get($courseId, $id, $optParams = [])
98  {
99    $params = ['courseId' => $courseId, 'id' => $id];
100    $params = array_merge($params, $optParams);
101    return $this->call('get', [$params], CourseWork::class);
102  }
103  /**
104   * Returns a list of course work that the requester is permitted to view. Course
105   * students may only view `PUBLISHED` course work. Course teachers and domain
106   * administrators may view all course work. This method returns the following
107   * error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to
108   * access the requested course or for access errors. * `INVALID_ARGUMENT` if the
109   * request is malformed. * `NOT_FOUND` if the requested course does not exist.
110   * (courseWork.listCoursesCourseWork)
111   *
112   * @param string $courseId Identifier of the course. This identifier can be
113   * either the Classroom-assigned identifier or an alias.
114   * @param array $optParams Optional parameters.
115   *
116   * @opt_param string courseWorkStates Restriction on the work status to return.
117   * Only courseWork that matches is returned. If unspecified, items with a work
118   * status of `PUBLISHED` is returned.
119   * @opt_param string orderBy Optional sort ordering for results. A comma-
120   * separated list of fields with an optional sort direction keyword. Supported
121   * fields are `updateTime` and `dueDate`. Supported direction keywords are `asc`
122   * and `desc`. If not specified, `updateTime desc` is the default behavior.
123   * Examples: `dueDate asc,updateTime desc`, `updateTime,dueDate desc`
124   * @opt_param int pageSize Maximum number of items to return. Zero or
125   * unspecified indicates that the server may assign a maximum. The server may
126   * return fewer than the specified number of results.
127   * @opt_param string pageToken nextPageToken value returned from a previous list
128   * call, indicating that the subsequent page of results should be returned. The
129   * list request must be otherwise identical to the one that resulted in this
130   * token.
131   * @return ListCourseWorkResponse
132   */
133  public function listCoursesCourseWork($courseId, $optParams = [])
134  {
135    $params = ['courseId' => $courseId];
136    $params = array_merge($params, $optParams);
137    return $this->call('list', [$params], ListCourseWorkResponse::class);
138  }
139  /**
140   * Modifies assignee mode and options of a coursework. Only a teacher of the
141   * course that contains the coursework may call this method. This method returns
142   * the following error codes: * `PERMISSION_DENIED` if the requesting user is
143   * not permitted to access the requested course or course work or for access
144   * errors. * `INVALID_ARGUMENT` if the request is malformed. * `NOT_FOUND` if
145   * the requested course or course work does not exist.
146   * (courseWork.modifyAssignees)
147   *
148   * @param string $courseId Identifier of the course. This identifier can be
149   * either the Classroom-assigned identifier or an alias.
150   * @param string $id Identifier of the coursework.
151   * @param ModifyCourseWorkAssigneesRequest $postBody
152   * @param array $optParams Optional parameters.
153   * @return CourseWork
154   */
155  public function modifyAssignees($courseId, $id, ModifyCourseWorkAssigneesRequest $postBody, $optParams = [])
156  {
157    $params = ['courseId' => $courseId, 'id' => $id, 'postBody' => $postBody];
158    $params = array_merge($params, $optParams);
159    return $this->call('modifyAssignees', [$params], CourseWork::class);
160  }
161  /**
162   * Updates one or more fields of a course work. See
163   * google.classroom.v1.CourseWork for details of which fields may be updated and
164   * who may change them. This request must be made by the Developer Console
165   * project of the [OAuth client
166   * ID](https://support.google.com/cloud/answer/6158849) used to create the
167   * corresponding course work item. This method returns the following error
168   * codes: * `PERMISSION_DENIED` if the requesting developer project did not
169   * create the corresponding course work, if the user is not permitted to make
170   * the requested modification to the student submission, or for access errors. *
171   * `INVALID_ARGUMENT` if the request is malformed. * `FAILED_PRECONDITION` if
172   * the requested course work has already been deleted. * `NOT_FOUND` if the
173   * requested course, course work, or student submission does not exist.
174   * (courseWork.patch)
175   *
176   * @param string $courseId Identifier of the course. This identifier can be
177   * either the Classroom-assigned identifier or an alias.
178   * @param string $id Identifier of the course work.
179   * @param CourseWork $postBody
180   * @param array $optParams Optional parameters.
181   *
182   * @opt_param string updateMask Mask that identifies which fields on the course
183   * work to update. This field is required to do an update. The update fails if
184   * invalid fields are specified. If a field supports empty values, it can be
185   * cleared by specifying it in the update mask and not in the CourseWork object.
186   * If a field that does not support empty values is included in the update mask
187   * and not set in the CourseWork object, an `INVALID_ARGUMENT` error is
188   * returned. The following fields may be specified by teachers: * `title` *
189   * `description` * `state` * `due_date` * `due_time` * `max_points` *
190   * `scheduled_time` * `submission_modification_mode` * `topic_id`
191   * @return CourseWork
192   */
193  public function patch($courseId, $id, CourseWork $postBody, $optParams = [])
194  {
195    $params = ['courseId' => $courseId, 'id' => $id, 'postBody' => $postBody];
196    $params = array_merge($params, $optParams);
197    return $this->call('patch', [$params], CourseWork::class);
198  }
199}
200
201// Adding a class alias for backwards compatibility with the previous class name.
202class_alias(CoursesCourseWork::class, 'Google_Service_Classroom_Resource_CoursesCourseWork');
203