Skip to content

Commit

Permalink
Merge pull request #162 from ucfopen/develop
Browse files Browse the repository at this point in the history
Release v0.9.0
  • Loading branch information
Thetwam authored Mar 1, 2018
2 parents fec7469 + 1a412fe commit 1903e21
Show file tree
Hide file tree
Showing 31 changed files with 1,739 additions and 530 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
Expand Down
2 changes: 2 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ Patches and Suggestions

- Adrian Goetz [@a-goetz](https://github.com/a-goetz)
- Alyssa Davis [@allygator](https://github.com/allygator)
- Andrew Gardener [@andrew-gardener](https://github.com/andrew-gardener)
- Anthony Rodriguez [@AnthonyRodriguez726](https://github.com/AnthonyRodriguez726)
- Ben Liblit [@liblit](https://github.com/liblit)
- Daniel Brinkman [@DanBrink91](https://github.com/DanBrink91)
- Daniel Grobani [@dgrobani](https://github.com/dgrobani)
- David Warden [@dfwarden](https://github.com/dfwarden)
- Devin Singh [@devints47](https://github.com/devints47)
- Elise Heron [@thedarkestknight](https://github.com/thedarkestknight)
- Ian Turgeon [@iturgeon](https://github.com/iturgeon)
Expand Down
32 changes: 31 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Change Log

## [0.9.0] - 2018-02-28

### New Endpoint Coverage

- Quiz Questions

### General

- Added example usage for several common endpoints to our documentation.
- Updated `PaginatedList` to allow specification of the root element to build the list from when given an atypical JSON response (see [#146](https://github.com/ucfopen/canvasapi/issues/146)). (thanks [@dfwarden](https://github.com/dfwarden))
- Improved keyword argument support for `course.get_section()` (thanks [@andrew-gardener](https://github.com/andrew-gardener))
- When uploading a file to a submission with `Submission.upload_comment`, it will automatically attached to a new comment.

### Deprecation Warnings

- :warning: **_Dropped support for Python 3.3_** :warning:
- [Python 3.3 is end-of-life as of September 2017](https://www.python.org/dev/peps/pep-0398/#lifespan)
- Should continue to function in 3.3, but compatibility cannot be guaranteed going forward.
- Several methods in the `Course` and `Section` classes relating to assignments and submissions have been deprecated.
- Comparable methods have been implemented in the `Assignment` and `Submission` classes, as appropriate.
- The deprecated methods now include a warning in the documentation with reference to the replacement. Additionally, the deprecated methods will raise a `DeprecationWarning`.
- These methods will be removed in a future release.
- `Course.list_sections()` has been deprecated. Use `Course.get_sections()` instead.

### Bugfixes

- Fixed an issue where booleans would be capitalized when sent to Canvas, causing Canvas to misinterpret them and set default values.
- Fixed an issue where unexpected JSON responses from Canvas would cause `PaginatedList` objects to fail.

## [0.8.2] - 2018-01-24

### Bugfixes
Expand Down Expand Up @@ -37,7 +66,7 @@

- Added support for other iterables as parameter values. (Thanks, [@liblit](https://github.com/liblit))
- For many endpoints that accept an "object id", either a CanvasAPI Object or integer ID can now be passed. (Thanks, [@a-goetz](https://github.com/a-goetz))
- Added a requester cache that rememebers the last 5 requests to Canvas. It can be accessed as the attribute `_cache` of the `requester object`. (e.g. `course._requester._cache`)
- Added a requester cache that remembers the last 5 requests to Canvas. It can be accessed as the attribute `_cache` of the `requester object`. (e.g. `course._requester._cache`)
- Files can now be downloaded directly from the `File` object in one of two ways: (Thanks, [@DanBrink91](https://github.com/DanBrink91))
1. `get_contents` will directly return the contents of the file. (e.g. `file.get_contents()`)
2. `download` will download the file and save it to the provided path. (e.g. `file.download('example.txt')`)
Expand Down Expand Up @@ -201,6 +230,7 @@ Huge thanks to [@liblit](https://github.com/liblit) for lots of issues, suggesti
- Fixed some incorrectly defined parameters
- Fixed an issue where tests would fail due to an improperly configured requires block

[0.9.0]: https://github.com/ucfopen/canvasapi/compare/v0.8.2...v0.9.0
[0.8.2]: https://github.com/ucfopen/canvasapi/compare/v0.8.1...v0.8.2
[0.8.1]: https://github.com/ucfopen/canvasapi/compare/v0.8.0...v0.8.1
[0.8.0]: https://github.com/ucfopen/canvasapi/compare/v0.7.0...v0.8.0
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ Let’s look at how we can use the `PaginatedList` returned by our `get_courses(
# Retrieve a list of courses the user is enrolled in
>>> courses = user.get_courses()

>>> print courses
>>> print(courses)
<PaginatedList of type Course>

# Access the first element in our list.
#
# You'll notice the first call takes a moment, but the next N-1
# elements (where N = the per_page argument supplied; the default is 10)
# will be instantly accessible.
>>> print courses[0]
>>> print(courses[0])
TST101 Test Course (1234567)

# Iterate over our course list
>>> for course in courses:
print course
print(course)

TST101 Test Course 1 (1234567)
TST102 Test Course 2 (1234568)
Expand Down
2 changes: 1 addition & 1 deletion canvasapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

__all__ = ["Canvas"]

__version__ = '0.8.2'
__version__ = '0.9.0'
1 change: 1 addition & 0 deletions canvasapi/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ def list_enrollment_terms(self, **kwargs):
'GET',
'accounts/{}/terms'.format(self.id),
{'account_id': self.id},
_root='enrollment_terms',
_kwargs=combine_kwargs(**kwargs)
)

Expand Down
101 changes: 99 additions & 2 deletions canvasapi/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from six import python_2_unicode_compatible

from canvasapi.canvas_object import CanvasObject
from canvasapi.util import combine_kwargs
from canvasapi.exceptions import RequiredFieldMissing
from canvasapi.paginated_list import PaginatedList
from canvasapi.submission import Submission
from canvasapi.user import UserDisplay
from canvasapi.util import combine_kwargs, obj_or_id


@python_2_unicode_compatible
Expand All @@ -12,7 +16,7 @@ class Assignment(CanvasObject):
def __str__(self):
return "{} ({})".format(self.name, self.id)

def delete(self):
def delete(self, **kwargs):
"""
Delete this assignment.
Expand All @@ -24,6 +28,7 @@ def delete(self):
response = self._requester.request(
'DELETE',
'courses/{}/assignments/{}'.format(self.course_id, self.id),
_kwargs=combine_kwargs(**kwargs)
)
return Assignment(self._requester, response.json())

Expand All @@ -47,6 +52,98 @@ def edit(self, **kwargs):

return Assignment(self._requester, response.json())

def get_gradeable_students(self, **kwargs):
"""
List students eligible to submit the assignment.
:calls: `GET /api/v1/courses/:course_id/assignments/:assignment_id/gradeable_students \
<https://canvas.instructure.com/doc/api/submissions.html#method.submissions_api.gradeable_students>`_
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.user.UserDisplay`
"""
return PaginatedList(
UserDisplay,
self._requester,
'GET',
'courses/{}/assignments/{}/gradeable_students'.format(self.course_id, self.id),
_kwargs=combine_kwargs(**kwargs)
)

def get_submission(self, user, **kwargs):
"""
Get a single submission, based on user id.
:calls: `GET /api/v1/courses/:course_id/assignments/:assignment_id/submissions/:user_id \
<https://canvas.instructure.com/doc/api/submissions.html#method.submissions_api.show>`_
:param user: The object or ID of the related user
:type user: :class:`canvasapi.user.User` or int
:rtype: :class:`canvasapi.submission.Submission`
"""
from canvasapi.user import User

user_id = obj_or_id(user, "user", (User,))

response = self._requester.request(
'GET',
'courses/{}/assignments/{}/submissions/{}'.format(self.course_id, self.id, user_id),
_kwargs=combine_kwargs(**kwargs)
)
response_json = response.json()
response_json.update(course_id=self.course_id)

return Submission(self._requester, response_json)

def get_submissions(self, **kwargs):
"""
Get all existing submissions for this assignment.
:calls: `GET /api/v1/courses/:course_id/assignments/:assignment_id/submissions \
<https://canvas.instructure.com/doc/api/submissions.html#method.submissions_api.index>`_
:rtype: :class:`canvasapi.paginated_list.PaginatedList` of
:class:`canvasapi.submission.Submission`
"""
return PaginatedList(
Submission,
self._requester,
'GET',
'courses/{}/assignments/{}/submissions'.format(self.course_id, self.id),
{'course_id': self.course_id},
_kwargs=combine_kwargs(**kwargs)
)

def submit(self, submission, **kwargs):
"""
Makes a submission for an assignment.
:calls: `POST /api/v1/courses/:course_id/assignments/:assignment_id/submissions \
<https://canvas.instructure.com/doc/api/submissions.html#method.submissions.create>`_
:param submission: The attributes of the submission.
:type submission: dict
:rtype: :class:`canvasapi.submission.Submission`
"""
if isinstance(submission, dict) and 'submission_type' in submission:
kwargs['submision'] = submission
else:
raise RequiredFieldMissing(
"Dictionary with key 'submission_type' is required."
)

response = self._requester.request(
'POST',
'courses/{}/assignments/{}/submissions'.format(self.course_id, self.id),
_kwargs=combine_kwargs(**kwargs)
)
response_json = response.json()
response_json.update(course_id=self.course_id)

return Submission(self._requester, response_json)


@python_2_unicode_compatible
class AssignmentGroup(CanvasObject):
Expand Down
2 changes: 1 addition & 1 deletion canvasapi/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def add_recipients(self, recipients):
:param recipients: A list of string format recipient ids.
These may be user ids or course/group ids prefixed
with 'course\_' or 'group\_' respectively,
with 'course\\_' or 'group\\_' respectively,
e.g. recipients['1', '2', 'course_3']
:type recipients: `list` of `str`
:rtype: :class:`canvasapi.account.Conversation`
Expand Down
Loading

0 comments on commit 1903e21

Please sign in to comment.