Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion canvasapi/custom_gradebook_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ def reorder_custom_columns(self, order, **kwargs):
)

return response.json().get("reorder")

def update_custom_column_entry(self, user_id, column_data, **kwargs):
"""
Sets the content of a custom column or create them if inexistent.

:calls: `PUT /api/v1/courses/:course_id/custom_gradebook_columns/:id/data/:user_id \
<https://canvas.instructure.com/doc/api/custom_gradebook_columns.html#method.custom_gradebook_column_data_api.update>`_

:param column_data: The content in the column.
:type column_data: str
:param user_id: The id for the user to be updated.
:type column_data: int

:rtype: :class:`canvasapi.custom_gradebook_columns.ColumnData`
"""

kwargs["column_data"] = {"content": column_data}

response = self._requester.request(
"PUT",
"courses/{}/custom_gradebook_columns/{}/data/{}".format(
self.course_id, self.id, user_id
),
_kwargs=combine_kwargs(**kwargs),
)

if response.json().get("content"):
return ColumnData(self._requester, response.json())

def update_custom_column(self, **kwargs):
"""
Expand Down Expand Up @@ -113,7 +141,7 @@ def update_column_data(self, column_data, **kwargs):
:rtype: :class:`canvasapi.custom_gradebook_columns.ColumnData`
"""

kwargs["column_data"] = column_data
kwargs["column_data"] = {"content": column_data}

response = self._requester.request(
"PUT",
Expand Down