Пример #1
0
 def test_put_merges_with_request_kwargs(self, call_mock, merge_mock):
     """
     Test that the call to put method calls merge helper with request_kwargs
     dictionary as first positional parameter
     """
     client.put(self.req_ctx, self.url, **self.request_kwargs)
     merge_mock.assert_called_once_with(self.request_kwargs, mock.ANY, mock.ANY)
Пример #2
0
 def test_put_merges_with_data_key(self, call_mock, merge_mock):
     """
     Test that the call to put method calls merge helper with 'data' as
     dictionary key (second positional parameter)
     """
     client.put(self.req_ctx, self.url)
     merge_mock.assert_called_once_with(mock.ANY, "data", mock.ANY)
Пример #3
0
 def test_put_merges_with_payload(self, call_mock, merge_mock):
     """
     Test that the call to put method with a payload calls merge helper and
     passes in the payload as the value parameter.
     """
     client.put(self.req_ctx, self.url, self.payload)
     merge_mock.assert_called_once_with(mock.ANY, mock.ANY, self.payload)
Пример #4
0
 def test_put_with_request_kwargs_and_payload(self, call_mock, merge_mock):
     """
     Test that the call to put method with payload and request kwargs passes through
     properly
     """
     client.put(self.req_ctx, self.url, self.payload, **self.request_kwargs)
     call_mock.assert_called_once_with(mock.ANY, mock.ANY, mock.ANY, **self.request_kwargs)
Пример #5
0
 def test_put_merges_with_payload(self, call_mock, merge_mock):
     """
     Test that the call to put method with a payload calls merge helper and passes
     in the payload as the value parameter.
     """
     client.put(self.req_ctx, self.url, self.payload)
     merge_mock.assert_called_once_with(mock.ANY, mock.ANY, self.payload)
Пример #6
0
 def test_put_merges_with_data_key(self, call_mock, merge_mock):
     """
     Test that the call to put method calls merge helper with 'data' as
     dictionary key (second positional parameter)
     """
     client.put(self.req_ctx, self.url)
     merge_mock.assert_called_once_with(mock.ANY, 'data', mock.ANY)
Пример #7
0
 def test_put_makes_call_with_action_url_and_context(self, call_mock, merge_mock):
     """
     Test that the call to get method sends expected action, url, and request
     context.
     """
     client.put(self.req_ctx, self.url)
     call_mock.assert_called_once_with("PUT", self.url, self.req_ctx)
Пример #8
0
 def test_put_makes_call_with_action_url_and_context(
         self, call_mock, merge_mock):
     """
     Test that the call to get method sends expected action, url, and request
     context.
     """
     client.put(self.req_ctx, self.url)
     call_mock.assert_called_once_with("PUT", self.url, self.req_ctx)
Пример #9
0
 def test_put_merges_with_request_kwargs(self, call_mock, merge_mock):
     """
     Test that the call to put method calls merge helper with request_kwargs
     dictionary as first positional parameter
     """
     client.put(self.req_ctx, self.url, **self.request_kwargs)
     merge_mock.assert_called_once_with(self.request_kwargs, mock.ANY,
                                        mock.ANY)
Пример #10
0
 def test_put_with_request_kwargs_and_payload(self, call_mock, merge_mock):
     """
     Test that the call to put method with payload and request kwargs passes
     through properly.
     """
     client.put(self.req_ctx, self.url, self.payload, **self.request_kwargs)
     call_mock.assert_called_once_with(mock.ANY, mock.ANY, mock.ANY,
                                       **self.request_kwargs)
Пример #11
0
def update_account(request_ctx, id, account_name=None, account_default_time_zone=None, account_default_storage_quota_mb=None, account_default_user_storage_quota_mb=None, account_default_group_storage_quota_mb=None, **request_kwargs):
    """
    Update an existing account.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param account_name: (optional) Updates the account name
        :type account_name: string or None
        :param account_default_time_zone: (optional) The default time zone of the account. Allowed time zones are {http://www.iana.org/time-zones IANA time zones} or friendlier {http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html Ruby on Rails time zones}.
        :type account_default_time_zone: string or None
        :param account_default_storage_quota_mb: (optional) The default course storage quota to be used, if not otherwise specified.
        :type account_default_storage_quota_mb: integer or None
        :param account_default_user_storage_quota_mb: (optional) The default user storage quota to be used, if not otherwise specified.
        :type account_default_user_storage_quota_mb: integer or None
        :param account_default_group_storage_quota_mb: (optional) The default group storage quota to be used, if not otherwise specified.
        :type account_default_group_storage_quota_mb: integer or None
        :return: Update an account
        :rtype: requests.Response (with Account data)

    """

    path = '/v1/accounts/{id}'
    payload = {
        'account[name]' : account_name,
        'account[default_time_zone]' : account_default_time_zone,
        'account[default_storage_quota_mb]' : account_default_storage_quota_mb,
        'account[default_user_storage_quota_mb]' : account_default_user_storage_quota_mb,
        'account[default_group_storage_quota_mb]' : account_default_group_storage_quota_mb,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #12
0
def update_tab_for_course(request_ctx, course_id, tab_id, position, hidden,
                          **request_kwargs):
    """
    Home and Settings tabs are not manageable, and can't be hidden or moved
    
    Returns a tab object

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param tab_id: (required) ID
        :type tab_id: string
        :param position: (required) The new position of the tab, 1-based
        :type position: integer
        :param hidden: (required) \\ true, or false.
        :type hidden: string
        :return: Update a tab for a course
        :rtype: requests.Response (with Tab data)

    """

    path = '/v1/courses/{course_id}/tabs/{tab_id}'
    payload = {
        'position': position,
        'hidden': hidden,
    }
    url = request_ctx.base_api_url + path.format(course_id=course_id,
                                                 tab_id=tab_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #13
0
def update_membership_users(request_ctx, group_id, user_id, moderator, workflow_state=None, **request_kwargs):
    """
    Accept a membership request, or add/remove moderator rights.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param group_id: (required) ID
        :type group_id: string
        :param user_id: (required) ID
        :type user_id: string
        :param moderator: (required) no description
        :type moderator: string
        :param workflow_state: (optional) Currently, the only allowed value is "accepted"
        :type workflow_state: string or None
        :return: Update a membership
        :rtype: requests.Response (with GroupMembership data)

    """

    workflow_state_types = "accepted"
    utils.validate_attr_is_acceptable(workflow_state, workflow_state_types)
    path = "/v1/groups/{group_id}/users/{user_id}"
    payload = {"workflow_state": workflow_state, "moderator": moderator}
    url = request_ctx.base_api_url + path.format(group_id=group_id, user_id=user_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def edit_user_login(request_ctx, account_id, id, login_unique_id=None, login_password=None, login_sis_user_id=None, **request_kwargs):
    """
    Update an existing login for a user in the given account.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param account_id: (required) ID
        :type account_id: string
        :param id: (required) ID
        :type id: string
        :param login_unique_id: (optional) The new unique ID for the login.
        :type login_unique_id: string or None
        :param login_password: (optional) The new password for the login. Can only be set by an admin user if admins are allowed to change passwords for the account.
        :type login_password: string or None
        :param login_sis_user_id: (optional) SIS ID for the login. To set this parameter, the caller must be able to manage SIS permissions on the account.
        :type login_sis_user_id: string or None
        :return: Edit a user login
        :rtype: requests.Response (with void data)

    """

    path = '/v1/accounts/{account_id}/logins/{id}'
    payload = {
        'login[unique_id]' : login_unique_id,
        'login[password]' : login_password,
        'login[sis_user_id]' : login_sis_user_id,
    }
    url = request_ctx.base_api_url + path.format(account_id=account_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def update_appointment_group(request_ctx, id, appointment_group_context_codes, appointment_group_sub_context_codes=None, appointment_group_title=None, appointment_group_description=None, appointment_group_location_name=None, appointment_group_location_address=None, appointment_group_publish=None, appointment_group_participants_per_appointment=None, appointment_group_min_appointments_per_participant=None, appointment_group_max_appointments_per_participant=None, appointment_group_new_appointments_X=None, appointment_group_participant_visibility=None, **request_kwargs):
    """
    Update and return an appointment group. If new_appointments are specified,
    the response will return a new_appointments array (same format as
    appointments array, see "List appointment groups" action).

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param appointment_group_context_codes: (required) Array of context codes (courses, e.g. course_1) this group should be linked to (1 or more). Users in the course(s) with appropriate permissions will be able to sign up for this appointment group.
        :type appointment_group_context_codes: string
        :param appointment_group_sub_context_codes: (optional) Array of sub context codes (course sections or a single group category) this group should be linked to. Used to limit the appointment group to particular sections. If a group category is specified, students will sign up in groups and the participant_type will be "Group" instead of "User".
        :type appointment_group_sub_context_codes: string or None
        :param appointment_group_title: (optional) Short title for the appointment group.
        :type appointment_group_title: string or None
        :param appointment_group_description: (optional) Longer text description of the appointment group.
        :type appointment_group_description: string or None
        :param appointment_group_location_name: (optional) Location name of the appointment group.
        :type appointment_group_location_name: string or None
        :param appointment_group_location_address: (optional) Location address.
        :type appointment_group_location_address: string or None
        :param appointment_group_publish: (optional) Indicates whether this appointment group should be published (i.e. made available for signup). Once published, an appointment group cannot be unpublished. Defaults to false.
        :type appointment_group_publish: boolean or None
        :param appointment_group_participants_per_appointment: (optional) Maximum number of participants that may register for each time slot. Defaults to null (no limit).
        :type appointment_group_participants_per_appointment: integer or None
        :param appointment_group_min_appointments_per_participant: (optional) Minimum number of time slots a user must register for. If not set, users do not need to sign up for any time slots.
        :type appointment_group_min_appointments_per_participant: integer or None
        :param appointment_group_max_appointments_per_participant: (optional) Maximum number of time slots a user may register for.
        :type appointment_group_max_appointments_per_participant: integer or None
        :param appointment_group_new_appointments_X: (optional) Nested array of start time/end time pairs indicating time slots for this appointment group. Refer to the example request.
        :type appointment_group_new_appointments_X: string or None
        :param appointment_group_participant_visibility: (optional) "private":: participants cannot see who has signed up for a particular time slot "protected":: participants can see who has signed up. Defaults to "private".
        :type appointment_group_participant_visibility: string or None
        :return: Update an appointment group
        :rtype: requests.Response (with void data)

    """

    appointment_group_participant_visibility_types = ('private', 'protected')
    utils.validate_attr_is_acceptable(appointment_group_participant_visibility, appointment_group_participant_visibility_types)
    path = '/v1/appointment_groups/{id}'
    payload = {
        'appointment_group[context_codes]' : appointment_group_context_codes,
        'appointment_group[sub_context_codes]' : appointment_group_sub_context_codes,
        'appointment_group[title]' : appointment_group_title,
        'appointment_group[description]' : appointment_group_description,
        'appointment_group[location_name]' : appointment_group_location_name,
        'appointment_group[location_address]' : appointment_group_location_address,
        'appointment_group[publish]' : appointment_group_publish,
        'appointment_group[participants_per_appointment]' : appointment_group_participants_per_appointment,
        'appointment_group[min_appointments_per_participant]' : appointment_group_min_appointments_per_participant,
        'appointment_group[max_appointments_per_participant]' : appointment_group_max_appointments_per_participant,
        'appointment_group[new_appointments][X]' : appointment_group_new_appointments_X,
        'appointment_group[participant_visibility]' : appointment_group_participant_visibility,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def update_question_group(request_ctx, course_id, quiz_id, id, quiz_groups_name=None, quiz_groups_pick_count=None, quiz_groups_question_points=None, **request_kwargs):
    """
    Update a question group

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param quiz_id: (required) ID
        :type quiz_id: string
        :param id: (required) ID
        :type id: string
        :param quiz_groups_name: (optional) The name of the question group.
        :type quiz_groups_name: string or None
        :param quiz_groups_pick_count: (optional) The number of questions to randomly select for this group.
        :type quiz_groups_pick_count: integer or None
        :param quiz_groups_question_points: (optional) The number of points to assign to each question in the group.
        :type quiz_groups_question_points: integer or None
        :return: Update a question group
        :rtype: requests.Response (with void data)

    """

    path = '/v1/courses/{course_id}/quizzes/{quiz_id}/groups/{id}'
    payload = {
        'quiz_groups[name]' : quiz_groups_name,
        'quiz_groups[pick_count]' : quiz_groups_pick_count,
        'quiz_groups[question_points]' : quiz_groups_question_points,
    }
    url = request_ctx.base_api_url + path.format(course_id=course_id, quiz_id=quiz_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #17
0
 def test_put_returns_call(self, call_mock):
     """
     Test that the call to put method returns the result of 'call'
     """
     result = client.put(self.req_ctx, self.url)
     self.assertEqual(result, call_mock.return_value,
                      "Call to 'put' should return result of 'call' method")
def update_column_data(request_ctx, course_id, id, user_id,
                       column_data_content, **request_kwargs):
    """
    Set the content of a custom column

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param id: (required) ID
        :type id: string
        :param user_id: (required) ID
        :type user_id: string
        :param column_data_content: (required) Column content. Setting this to blank will delete the datum object.
        :type column_data_content: string
        :return: Update column data
        :rtype: requests.Response (with ColumnDatum data)

    """

    path = '/v1/courses/{course_id}/custom_gradebook_columns/{id}/data/{user_id}'
    payload = {
        'column_data[content]': column_data_content,
    }
    url = request_ctx.base_api_url + path.format(
        course_id=course_id, id=id, user_id=user_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def update_column_data(request_ctx, course_id, id, user_id, column_data_content, **request_kwargs):
    """
    Set the content of a custom column

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param id: (required) ID
        :type id: string
        :param user_id: (required) ID
        :type user_id: string
        :param column_data_content: (required) Column content. Setting this to blank will delete the datum object.
        :type column_data_content: string
        :return: Update column data
        :rtype: requests.Response (with ColumnDatum data)

    """

    path = '/v1/courses/{course_id}/custom_gradebook_columns/{id}/data/{user_id}'
    payload = {
        'column_data[content]' : column_data_content,
    }
    url = request_ctx.base_api_url + path.format(course_id=course_id, id=id, user_id=user_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def update_preference_communication_channel_id(request_ctx, communication_channel_id, notification, notification_preferences_frequency, **request_kwargs):
    """
    Change the preference for a single notification for a single communication channel

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param communication_channel_id: (required) ID
        :type communication_channel_id: string
        :param notification: (required) ID
        :type notification: string
        :param notification_preferences_frequency: (required) The desired frequency for this notification
        :type notification_preferences_frequency: string
        :return: Update a preference
        :rtype: requests.Response (with void data)

    """

    path = '/v1/users/self/communication_channels/{communication_channel_id}/notification_preferences/{notification}'
    payload = {
        'notification_preferences[frequency]' : notification_preferences_frequency,
    }
    url = request_ctx.base_api_url + path.format(communication_channel_id=communication_channel_id, notification=notification)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def update_multiple_preferences_type(request_ctx, type, address, notification_preferences_X_frequency, **request_kwargs):
    """
    Change the preferences for multiple notifications for a single communication channel at once

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param type: (required) ID
        :type type: string
        :param address: (required) ID
        :type address: string
        :param notification_preferences_X_frequency: (required) The desired frequency for <X> notification
        :type notification_preferences_X_frequency: string
        :return: Update multiple preferences
        :rtype: requests.Response (with void data)

    """

    path = '/v1/users/self/communication_channels/{type}/{address}/notification_preferences'
    payload = {
        'notification_preferences[X][frequency]' : notification_preferences_X_frequency,
    }
    url = request_ctx.base_api_url + path.format(type=type, address=address)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #22
0
def merge_user_into_another_user_accounts(request_ctx, id, destination_account_id, destination_user_id, **request_kwargs):
    """
    Merge a user into another user.
    To merge users, the caller must have permissions to manage both users.
    
    When finding users by SIS ids in different accounts the
    destination_account_id is required.
    
    The account can also be identified by passing the domain in destination_account_id.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param destination_account_id: (required) ID
        :type destination_account_id: string
        :param destination_user_id: (required) ID
        :type destination_user_id: string
        :return: Merge user into another user
        :rtype: requests.Response (with User data)

    """

    path = '/v1/users/{id}/merge_into/accounts/{destination_account_id}/users/{destination_user_id}'
    url = request_ctx.base_api_url + path.format(id=id, destination_account_id=destination_account_id, destination_user_id=destination_user_id)
    response = client.put(request_ctx, url, **request_kwargs)

    return response
Пример #23
0
def update_single_poll(request_ctx, id, polls_question, polls_description=None, **request_kwargs):
    """
    Update an existing poll belonging to the current user

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param polls_question: (required) The title of the poll.
        :type polls_question: string
        :param polls_description: (optional) A brief description or instructions for the poll.
        :type polls_description: string or None
        :return: Update a single poll
        :rtype: requests.Response (with void data)

    """

    path = '/v1/polls/{id}'
    payload = {
        'polls[question]' : polls_question,
        'polls[description]' : polls_description,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #24
0
def edit_quiz(request_ctx, course_id, id, quiz_notify_of_update, **request_kwargs):
    """
    Modify an existing quiz. See the documentation for quiz creation.
    
    Additional arguments:

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param id: (required) ID
        :type id: string
        :param quiz_notify_of_update: (required) If true, notifies users that the quiz has changed. Defaults to true
        :type quiz_notify_of_update: boolean
        :return: Edit a quiz
        :rtype: requests.Response (with Quiz data)

    """

    path = "/v1/courses/{course_id}/quizzes/{id}"
    payload = {"quiz[notify_of_update]": quiz_notify_of_update}
    url = request_ctx.base_api_url + path.format(course_id=course_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #25
0
def merge_user_into_another_user_accounts(request_ctx, id, destination_account_id, destination_user_id, **request_kwargs):
    """
    Merge a user into another user.
    To merge users, the caller must have permissions to manage both users.
    
    When finding users by SIS ids in different accounts the
    destination_account_id is required.
    
    The account can also be identified by passing the domain in destination_account_id.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param destination_account_id: (required) ID
        :type destination_account_id: string
        :param destination_user_id: (required) ID
        :type destination_user_id: string
        :return: Merge user into another user
        :rtype: requests.Response (with User data)

    """

    path = '/v1/users/{id}/merge_into/accounts/{destination_account_id}/users/{destination_user_id}'
    url = request_ctx.base_api_url + path.format(id=id, destination_account_id=destination_account_id, destination_user_id=destination_user_id)
    response = client.put(request_ctx, url, **request_kwargs)

    return response
Пример #26
0
def edit_section(request_ctx,
                 id,
                 course_section_name=None,
                 course_section_sis_section_id=None,
                 course_section_start_at=None,
                 course_section_end_at=None,
                 **request_kwargs):
    """
    Modify an existing section. See the documentation for `SectionsController#create <https://github.com/instructure/canvas-lms/blob/master/app/controllers/sections_controller.rb>`_.
    :param request_ctx: The request context
    :type request_ctx: :class:RequestContext
    :param id: (required) ID
    :type id: string
    :param course_section_name: (optional) The name of the section
    :type course_section_name: string or None
    :param course_section_sis_section_id: (optional) The sis ID of the section
    :type course_section_sis_section_id: string or None
    :param course_section_start_at: (optional) Section start date in ISO8601 format, e.g. 2011-01-01T01:00Z
    :type course_section_start_at: datetime or None
    :param course_section_end_at: (optional) Section end date in ISO8601 format. e.g. 2011-01-01T01:00Z
    :type course_section_end_at: datetime or None
    :return: Edit a section
    :rtype: requests.Response (with Section data)
    """
    path = '/v1/sections/{id}'
    payload = {
        'course_section[name]': course_section_name,
        'course_section[sis_section_id]': course_section_sis_section_id,
        'course_section[start_at]': course_section_start_at,
        'course_section[end_at]': course_section_end_at,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)
    return response
Пример #27
0
def update_tab_for_course(request_ctx, course_id, tab_id, position, hidden, **request_kwargs):
    """
    Home and Settings tabs are not manageable, and can't be hidden or moved
    
    Returns a tab object

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param tab_id: (required) ID
        :type tab_id: string
        :param position: (required) The new position of the tab, 1-based
        :type position: integer
        :param hidden: (required) \\ true, or false.
        :type hidden: string
        :return: Update a tab for a course
        :rtype: requests.Response (with Tab data)

    """

    path = "/v1/courses/{course_id}/tabs/{tab_id}"
    payload = {"position": position, "hidden": hidden}
    url = request_ctx.base_api_url + path.format(course_id=course_id, tab_id=tab_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #28
0
def update_single_poll_choice(request_ctx, poll_id, id, poll_choices_text, poll_choices_is_correct=None, poll_choices_position=None, **request_kwargs):
    """
    Update an existing poll choice for this poll

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param poll_id: (required) ID
        :type poll_id: string
        :param id: (required) ID
        :type id: string
        :param poll_choices_text: (required) The descriptive text of the poll choice.
        :type poll_choices_text: string
        :param poll_choices_is_correct: (optional) Whether this poll choice is considered correct or not. Defaults to false.
        :type poll_choices_is_correct: boolean or None
        :param poll_choices_position: (optional) The order this poll choice should be returned in the context it's sibling poll choices.
        :type poll_choices_position: integer or None
        :return: Update a single poll choice
        :rtype: requests.Response (with void data)

    """

    path = '/v1/polls/{poll_id}/poll_choices/{id}'
    payload = {
        'poll_choices[text]' : poll_choices_text,
        'poll_choices[is_correct]' : poll_choices_is_correct,
        'poll_choices[position]' : poll_choices_position,
    }
    url = request_ctx.base_api_url + path.format(poll_id=poll_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #29
0
def update_courses(request_ctx, account_id, course_ids, event, **request_kwargs):
    """
    Update multiple courses in an account.  Operates asynchronously; use the `ProgressController#show <https://github.com/instructure/canvas-lms/blob/master/app/controllers/progress_controller.rb>`_
    to query the status of an operation.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param account_id: (required) ID
        :type account_id: string
        :param course_ids: (required) List of ids of courses to update. At most 500 courses may be updated in one call.
        :type course_ids: string
        :param event: (required) The action to take on each course. Must be one of 'offer', 'conclude', 'delete', or 'undelete'. * 'offer' makes a course visible to students. This action is also called "publish" on the web site. * 'conclude' prevents future enrollments and makes a course read-only for all participants. The course still appears in prior-enrollment lists. * 'delete' completely removes the course from the web site (including course menus and prior-enrollment lists). All enrollments are deleted. Course content may be physically deleted at a future date. * 'undelete' attempts to recover a course that has been deleted. (Recovery is not guaranteed; please conclude rather than delete a course if there is any possibility the course will be used again.) The recovered course will be unpublished. Deleted enrollments will not be recovered.
        :type event: string
        :return: Update courses
        :rtype: requests.Response (with Progress data)

    """

    path = '/v1/accounts/{account_id}/courses'
    payload = {
        'course_ids[]' : course_ids,
        'event' : event,
    }
    url = request_ctx.base_api_url + path.format(account_id=account_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def update_multiple_preferences_type(request_ctx, type, address,
                                     notification_preferences_X_frequency,
                                     **request_kwargs):
    """
    Change the preferences for multiple notifications for a single communication channel at once

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param type: (required) ID
        :type type: string
        :param address: (required) ID
        :type address: string
        :param notification_preferences_X_frequency: (required) The desired frequency for <X> notification
        :type notification_preferences_X_frequency: string
        :return: Update multiple preferences
        :rtype: requests.Response (with void data)

    """

    path = '/v1/users/self/communication_channels/{type}/{address}/notification_preferences'
    payload = {
        'notification_preferences[X][frequency]':
        notification_preferences_X_frequency,
    }
    url = request_ctx.base_api_url + path.format(type=type, address=address)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #31
0
def update_account(request_ctx, id, account_name=None, account_default_time_zone=None, account_default_storage_quota_mb=None, account_default_user_storage_quota_mb=None, account_default_group_storage_quota_mb=None, **request_kwargs):
    """
    Update an existing account.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param account_name: (optional) Updates the account name
        :type account_name: string or None
        :param account_default_time_zone: (optional) The default time zone of the account. Allowed time zones are {http://www.iana.org/time-zones IANA time zones} or friendlier {http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html Ruby on Rails time zones}.
        :type account_default_time_zone: string or None
        :param account_default_storage_quota_mb: (optional) The default course storage quota to be used, if not otherwise specified.
        :type account_default_storage_quota_mb: integer or None
        :param account_default_user_storage_quota_mb: (optional) The default user storage quota to be used, if not otherwise specified.
        :type account_default_user_storage_quota_mb: integer or None
        :param account_default_group_storage_quota_mb: (optional) The default group storage quota to be used, if not otherwise specified.
        :type account_default_group_storage_quota_mb: integer or None
        :return: Update an account
        :rtype: requests.Response (with Account data)

    """

    path = '/v1/accounts/{id}'
    payload = {
        'account[name]' : account_name,
        'account[default_time_zone]' : account_default_time_zone,
        'account[default_storage_quota_mb]' : account_default_storage_quota_mb,
        'account[default_user_storage_quota_mb]' : account_default_user_storage_quota_mb,
        'account[default_group_storage_quota_mb]' : account_default_group_storage_quota_mb,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #32
0
def update_single_poll(request_ctx,
                       id,
                       polls_question,
                       polls_description=None,
                       **request_kwargs):
    """
    Update an existing poll belonging to the current user

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param polls_question: (required) The title of the poll.
        :type polls_question: string
        :param polls_description: (optional) A brief description or instructions for the poll.
        :type polls_description: string or None
        :return: Update a single poll
        :rtype: requests.Response (with void data)

    """

    path = '/v1/polls/{id}'
    payload = {
        'polls[question]': polls_question,
        'polls[description]': polls_description,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #33
0
def update_single_poll_session(request_ctx, poll_id, id, poll_sessions_course_id, poll_sessions_course_section_id, poll_sessions_has_public_results=None, **request_kwargs):
    """
    Update an existing poll session for this poll

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param poll_id: (required) ID
        :type poll_id: string
        :param id: (required) ID
        :type id: string
        :param poll_sessions_course_id: (required) The id of the course this session is associated with.
        :type poll_sessions_course_id: integer
        :param poll_sessions_course_section_id: (required) The id of the course section this session is associated with.
        :type poll_sessions_course_section_id: integer
        :param poll_sessions_has_public_results: (optional) Whether or not results are viewable by students.
        :type poll_sessions_has_public_results: boolean or None
        :return: Update a single poll session
        :rtype: requests.Response (with void data)

    """

    path = '/v1/polls/{poll_id}/poll_sessions/{id}'
    payload = {
        'poll_sessions[course_id]' : poll_sessions_course_id,
        'poll_sessions[course_section_id]' : poll_sessions_course_section_id,
        'poll_sessions[has_public_results]' : poll_sessions_has_public_results,
    }
    url = request_ctx.base_api_url + path.format(poll_id=poll_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def update_preference_communication_channel_id(
        request_ctx, communication_channel_id, notification,
        notification_preferences_frequency, **request_kwargs):
    """
    Change the preference for a single notification for a single communication channel

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param communication_channel_id: (required) ID
        :type communication_channel_id: string
        :param notification: (required) ID
        :type notification: string
        :param notification_preferences_frequency: (required) The desired frequency for this notification
        :type notification_preferences_frequency: string
        :return: Update a preference
        :rtype: requests.Response (with void data)

    """

    path = '/v1/users/self/communication_channels/{communication_channel_id}/notification_preferences/{notification}'
    payload = {
        'notification_preferences[frequency]':
        notification_preferences_frequency,
    }
    url = request_ctx.base_api_url + path.format(
        communication_channel_id=communication_channel_id,
        notification=notification)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #35
0
def edit_section(request_ctx, id, course_section_name=None, course_section_sis_section_id=None, course_section_start_at=None, course_section_end_at=None, **request_kwargs):
    """
    Modify an existing section. See the documentation for `SectionsController#create <https://github.com/instructure/canvas-lms/blob/master/app/controllers/sections_controller.rb>`_.
    :param request_ctx: The request context
    :type request_ctx: :class:RequestContext
    :param id: (required) ID
    :type id: string
    :param course_section_name: (optional) The name of the section
    :type course_section_name: string or None
    :param course_section_sis_section_id: (optional) The sis ID of the section
    :type course_section_sis_section_id: string or None
    :param course_section_start_at: (optional) Section start date in ISO8601 format, e.g. 2011-01-01T01:00Z
    :type course_section_start_at: datetime or None
    :param course_section_end_at: (optional) Section end date in ISO8601 format. e.g. 2011-01-01T01:00Z
    :type course_section_end_at: datetime or None
    :return: Edit a section
    :rtype: requests.Response (with Section data)
    """
    path = '/v1/sections/{id}'
    payload = {
        'course_section[name]' : course_section_name,
        'course_section[sis_section_id]' : course_section_sis_section_id,
        'course_section[start_at]' : course_section_start_at,
        'course_section[end_at]' : course_section_end_at,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)
    return response
Пример #36
0
def set_feature_flag_users(request_ctx, user_id, feature, state=None, locking_account_id=None, **request_kwargs):
    """
    Set a feature flag for a given Account, Course, or User. This call will fail if a parent account sets
    a feature flag for the same feature in any state other than "allowed".

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param user_id: (required) ID
        :type user_id: string
        :param feature: (required) ID
        :type feature: string
        :param state: (optional) "off":: The feature is not available for the course, user, or account and sub-accounts. "allowed":: (valid only on accounts) The feature is off in the account, but may be enabled in sub-accounts and courses by setting a feature flag on the sub-account or course. "on":: The feature is turned on unconditionally for the user, course, or account and sub-accounts.
        :type state: string or None
        :param locking_account_id: (optional) If set, this FeatureFlag may only be modified by someone with administrative rights in the specified account. The locking account must be above the target object in the account chain.
        :type locking_account_id: integer or None
        :return: Set feature flag
        :rtype: requests.Response (with FeatureFlag data)

    """

    state_types = ('off', 'allowed', 'on')
    utils.validate_attr_is_acceptable(state, state_types)
    path = '/v1/users/{user_id}/features/flags/{feature}'
    payload = {
        'state' : state,
        'locking_account_id' : locking_account_id,
    }
    url = request_ctx.base_api_url + path.format(user_id=user_id, feature=feature)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def update_course_settings(request_ctx, course_id,
                           allow_student_discussion_topics,
                           allow_student_forum_attachments,
                           allow_student_discussion_editing, **request_kwargs):
    """
    Can update the following course settings:

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param allow_student_discussion_topics: (required) no description
        :type allow_student_discussion_topics: boolean
        :param allow_student_forum_attachments: (required) no description
        :type allow_student_forum_attachments: boolean
        :param allow_student_discussion_editing: (required) no description
        :type allow_student_discussion_editing: boolean
        :return: Update course settings
        :rtype: requests.Response (with void data)

    """

    path = '/v1/courses/{course_id}/settings'
    payload = {
        'allow_student_discussion_topics': allow_student_discussion_topics,
        'allow_student_forum_attachments': allow_student_forum_attachments,
        'allow_student_discussion_editing': allow_student_discussion_editing,
    }
    url = request_ctx.base_api_url + path.format(course_id=course_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def flagging_question(request_ctx, quiz_submission_id, id, attempt, validation_token, access_code=None, **request_kwargs):
    """
    Set a flag on a quiz question to indicate that you want to return to it
    later.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param quiz_submission_id: (required) ID
        :type quiz_submission_id: string
        :param id: (required) ID
        :type id: string
        :param attempt: (required) The attempt number of the quiz submission being taken. Note that this must be the latest attempt index, as questions for earlier attempts can not be modified.
        :type attempt: integer
        :param validation_token: (required) The unique validation token you received when the Quiz Submission was created.
        :type validation_token: string
        :param access_code: (optional) Access code for the Quiz, if any.
        :type access_code: string or None
        :return: Flagging a question.
        :rtype: requests.Response (with void data)

    """

    path = '/v1/quiz_submissions/{quiz_submission_id}/questions/{id}/flag'
    payload = {
        'attempt' : attempt,
        'validation_token' : validation_token,
        'access_code' : access_code,
    }
    url = request_ctx.base_api_url + path.format(quiz_submission_id=quiz_submission_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def answering_question(request_ctx, quiz_submission_id, id, attempt, validation_token, access_code=None, answer=None, **request_kwargs):
    """
    Provide or modify an answer to a QuizQuestion.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param quiz_submission_id: (required) ID
        :type quiz_submission_id: string
        :param id: (required) ID
        :type id: string
        :param attempt: (required) The attempt number of the quiz submission being taken. Note that this must be the latest attempt index, as questions for earlier attempts can not be modified.
        :type attempt: integer
        :param validation_token: (required) The unique validation token you received when the Quiz Submission was created.
        :type validation_token: string
        :param access_code: (optional) Access code for the Quiz, if any.
        :type access_code: string or None
        :param answer: (optional) The answer to the question. The type and format of this argument depend on the question type. See {Appendix: Question Answer Formats} for the accepted answer formats for each question type.
        :type answer: mixed or None
        :return: Answering a question.
        :rtype: requests.Response (with void data)

    """

    path = '/v1/quiz_submissions/{quiz_submission_id}/questions/{id}'
    payload = {
        'attempt' : attempt,
        'validation_token' : validation_token,
        'access_code' : access_code,
        'answer' : answer,
    }
    url = request_ctx.base_api_url + path.format(quiz_submission_id=quiz_submission_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def update_courses(request_ctx, account_id, course_ids, event,
                   **request_kwargs):
    """
    Update multiple courses in an account.  Operates asynchronously; use the `ProgressController#show <https://github.com/instructure/canvas-lms/blob/master/app/controllers/progress_controller.rb>`_
    to query the status of an operation.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param account_id: (required) ID
        :type account_id: string
        :param course_ids: (required) List of ids of courses to update. At most 500 courses may be updated in one call.
        :type course_ids: string
        :param event: (required) The action to take on each course. Must be one of 'offer', 'conclude', 'delete', or 'undelete'. * 'offer' makes a course visible to students. This action is also called "publish" on the web site. * 'conclude' prevents future enrollments and makes a course read-only for all participants. The course still appears in prior-enrollment lists. * 'delete' completely removes the course from the web site (including course menus and prior-enrollment lists). All enrollments are deleted. Course content may be physically deleted at a future date. * 'undelete' attempts to recover a course that has been deleted. (Recovery is not guaranteed; please conclude rather than delete a course if there is any possibility the course will be used again.) The recovered course will be unpublished. Deleted enrollments will not be recovered.
        :type event: string
        :return: Update courses
        :rtype: requests.Response (with Progress data)

    """

    path = '/v1/accounts/{account_id}/courses'
    payload = {
        'course_ids[]': course_ids,
        'event': event,
    }
    url = request_ctx.base_api_url + path.format(account_id=account_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #41
0
def update_course_settings(request_ctx, course_id, allow_student_discussion_topics, allow_student_forum_attachments, allow_student_discussion_editing, **request_kwargs):
    """
    Can update the following course settings:

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param allow_student_discussion_topics: (required) no description
        :type allow_student_discussion_topics: boolean
        :param allow_student_forum_attachments: (required) no description
        :type allow_student_forum_attachments: boolean
        :param allow_student_discussion_editing: (required) no description
        :type allow_student_discussion_editing: boolean
        :return: Update course settings
        :rtype: requests.Response (with void data)

    """

    path = '/v1/courses/{course_id}/settings'
    payload = {
        'allow_student_discussion_topics' : allow_student_discussion_topics,
        'allow_student_forum_attachments' : allow_student_forum_attachments,
        'allow_student_discussion_editing' : allow_student_discussion_editing,
    }
    url = request_ctx.base_api_url + path.format(course_id=course_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #42
0
def update_existing_quiz_question(request_ctx, course_id, quiz_id, id, question_question_name, question_question_text, question_question_type, question_quiz_group_id=None, question_position=None, question_points_possible=None, question_correct_comments=None, question_incorrect_comments=None, question_neutral_comments=None, question_text_after_answers=None, question_answers=None, **request_kwargs):
    """
    Updates an existing quiz question for this quiz

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param quiz_id: (required) The associated quiz's unique identifier.
        :type quiz_id: integer
        :param id: (required) The quiz question's unique identifier.
        :type id: integer
        :param question_question_name: (required) The name of the question.
        :type question_question_name: string
        :param question_question_text: (required) The text of the question.
        :type question_question_text: string
        :param question_question_type: (required) The type of question. Multiple optional fields depend upon the type of question to be used.
        :type question_question_type: string
        :param question_quiz_group_id: (optional) The id of the quiz group to assign the question to.
        :type question_quiz_group_id: integer or None
        :param question_position: (optional) The order in which the question will be displayed in the quiz in relation to other questions.
        :type question_position: integer or None
        :param question_points_possible: (optional) The maximum amount of points received for answering this question correctly.
        :type question_points_possible: integer or None
        :param question_correct_comments: (optional) The comment to display if the student answers the question correctly.
        :type question_correct_comments: string or None
        :param question_incorrect_comments: (optional) The comment to display if the student answers incorrectly.
        :type question_incorrect_comments: string or None
        :param question_neutral_comments: (optional) The comment to display regardless of how the student answered.
        :type question_neutral_comments: string or None
        :param question_text_after_answers: (optional) no description
        :type question_text_after_answers: string or None
        :param question_answers: (optional) no description
        :type question_answers: [answer] or None
        :return: Update an existing quiz question
        :rtype: requests.Response (with QuizQuestion data)

    """

    question_question_type_types = ('calculated_question', 'essay_question', 'file_upload_question', 'fill_in_multiple_blanks_question', 'matching_question', 'multiple_answers_question', 'multiple_choice_question', 'multiple_dropdowns_question', 'numerical_question', 'short_answer_question', 'text_only_question')
    utils.validate_attr_is_acceptable(question_question_type, question_question_type_types)
    path = '/v1/courses/{course_id}/quizzes/{quiz_id}/questions/{id}'
    payload = {
        'question[question_name]' : question_question_name,
        'question[question_text]' : question_question_text,
        'question[quiz_group_id]' : question_quiz_group_id,
        'question[question_type]' : question_question_type,
        'question[position]' : question_position,
        'question[points_possible]' : question_points_possible,
        'question[correct_comments]' : question_correct_comments,
        'question[incorrect_comments]' : question_incorrect_comments,
        'question[neutral_comments]' : question_neutral_comments,
        'question[text_after_answers]' : question_text_after_answers,
        'question[answers]' : question_answers,
    }
    url = request_ctx.base_api_url + path.format(course_id=course_id, quiz_id=quiz_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #43
0
 def test_put_returns_call(self, call_mock):
     """
     Test that the call to put method returns the result of 'call'
     """
     result = client.put(self.req_ctx, self.url)
     self.assertEqual(
         result, call_mock.return_value,
         "Call to 'put' should return result of 'call' method")
Пример #44
0
def update_module_item(request_ctx, course_id, module_id, id, module_item_completion_requirement_min_score=None, module_item_title=None, module_item_position=None, module_item_indent=None, module_item_external_url=None, module_item_new_tab=None, module_item_completion_requirement_type=None, module_item_published=None, module_item_module_id=None, **request_kwargs):
    """
    Update and return an existing module item

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param module_id: (required) ID
        :type module_id: string
        :param id: (required) ID
        :type id: string
        :param module_item_completion_requirement_min_score: (required) Minimum score required to complete, Required for completion_requirement type 'min_score'.
        :type module_item_completion_requirement_min_score: integer
        :param module_item_title: (optional) The name of the module item
        :type module_item_title: string or None
        :param module_item_position: (optional) The position of this item in the module (1-based)
        :type module_item_position: integer or None
        :param module_item_indent: (optional) 0-based indent level; module items may be indented to show a hierarchy
        :type module_item_indent: integer or None
        :param module_item_external_url: (optional) External url that the item points to. Only applies to 'ExternalUrl' type.
        :type module_item_external_url: string or None
        :param module_item_new_tab: (optional) Whether the external tool opens in a new tab. Only applies to 'ExternalTool' type.
        :type module_item_new_tab: boolean or None
        :param module_item_completion_requirement_type: (optional) Completion requirement for this module item. "must_view": Applies to all item types "must_contribute": Only applies to "Assignment", "Discussion", and "Page" types "must_submit", "min_score": Only apply to "Assignment" and "Quiz" types Inapplicable types will be ignored
        :type module_item_completion_requirement_type: string or None
        :param module_item_published: (optional) Whether the module item is published and visible to students.
        :type module_item_published: boolean or None
        :param module_item_module_id: (optional) Move this item to another module by specifying the target module id here. The target module must be in the same course.
        :type module_item_module_id: string or None
        :return: Update a module item
        :rtype: requests.Response (with ModuleItem data)

    """

    module_item_completion_requirement_type_types = ('must_view', 'must_contribute', 'must_submit', 'min_score')
    utils.validate_attr_is_acceptable(module_item_completion_requirement_type, module_item_completion_requirement_type_types)
    if module_item_type in ('ExternalUrl', 'ExternalTool') and module_item_external_url is None:
        raise ValueError('module_item_external_url must be set for ExternalUrl or ExternalTool items')
    if module_item_completion_requirement_type == 'min_score' and module_item_completion_requirement_min_score is None:
        raise ValueError('module_item_completion_requirement_min_score must be set for min_score requirement types')

    path = '/v1/courses/{course_id}/modules/{module_id}/items/{id}'
    payload = {
        'module_item[title]' : module_item_title,
        'module_item[position]' : module_item_position,
        'module_item[indent]' : module_item_indent,
        'module_item[external_url]' : module_item_external_url,
        'module_item[new_tab]' : module_item_new_tab,
        'module_item[completion_requirement][type]' : module_item_completion_requirement_type,
        'module_item[completion_requirement][min_score]' : module_item_completion_requirement_min_score,
        'module_item[published]' : module_item_published,
        'module_item[module_id]' : module_item_module_id,
    }
    url = request_ctx.base_api_url + path.format(course_id=course_id, module_id=module_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #45
0
def update_create_page_groups(request_ctx,
                              group_id,
                              url,
                              wiki_page_title,
                              wiki_page_body,
                              wiki_page_hide_from_students,
                              wiki_page_notify_of_update,
                              wiki_page_editing_roles=None,
                              wiki_page_published=None,
                              wiki_page_front_page=None,
                              **request_kwargs):
    """
    Update the title or contents of a wiki page

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param group_id: (required) ID
        :type group_id: string
        :param url: (required) ID
        :type url: string
        :param wiki_page_title: (required) The title for the new page. NOTE: changing a page's title will change its url. The updated url will be returned in the result.
        :type wiki_page_title: string
        :param wiki_page_body: (required) The content for the new page.
        :type wiki_page_body: string
        :param wiki_page_hide_from_students: (required) Whether the page should be hidden from students. *Note:* when draft state is enabled, attempts to set +hide_from_students+ will be ignored and the value returned will always be the inverse of the +published+ value.
        :type wiki_page_hide_from_students: boolean
        :param wiki_page_notify_of_update: (required) Whether participants should be notified when this page changes.
        :type wiki_page_notify_of_update: boolean
        :param wiki_page_editing_roles: (optional) Which user roles are allowed to edit this page. Any combination of these roles is allowed (separated by commas). "teachers":: Allows editing by teachers in the course. "students":: Allows editing by students in the course. "members":: For group wikis, allows editing by members of the group. "public":: Allows editing by any user.
        :type wiki_page_editing_roles: string or None
        :param wiki_page_published: (optional) Whether the page is published (true) or draft state (false). *Note:* when draft state is disabled, attempts to set +published+ will be ignored and the value returned will always be the inverse of the +hide_from_students+ value.
        :type wiki_page_published: boolean or None
        :param wiki_page_front_page: (optional) Set an unhidden page as the front page (if true)
        :type wiki_page_front_page: boolean or None
        :return: Update/create page
        :rtype: requests.Response (with Page data)

    """

    wiki_page_editing_roles_types = ('teachers', 'students', 'members',
                                     'public')
    utils.validate_attr_is_acceptable(wiki_page_editing_roles,
                                      wiki_page_editing_roles_types)
    path = '/v1/groups/{group_id}/pages/{url}'
    payload = {
        'wiki_page[title]': wiki_page_title,
        'wiki_page[body]': wiki_page_body,
        'wiki_page[hide_from_students]': wiki_page_hide_from_students,
        'wiki_page[editing_roles]': wiki_page_editing_roles,
        'wiki_page[notify_of_update]': wiki_page_notify_of_update,
        'wiki_page[published]': wiki_page_published,
        'wiki_page[front_page]': wiki_page_front_page,
    }
    url = request_ctx.base_api_url + path.format(group_id=group_id, url=url)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #46
0
def update_module(request_ctx,
                  course_id,
                  id,
                  module_name=None,
                  module_unlock_at=None,
                  module_position=None,
                  module_require_sequential_progress=None,
                  module_prerequisite_module_ids=None,
                  module_publish_final_grade=None,
                  module_published=None,
                  **request_kwargs):
    """
    Update and return an existing module

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param id: (required) ID
        :type id: string
        :param module_name: (optional) The name of the module
        :type module_name: string or None
        :param module_unlock_at: (optional) The date the module will unlock
        :type module_unlock_at: datetime or None
        :param module_position: (optional) The position of the module in the course (1-based)
        :type module_position: integer or None
        :param module_require_sequential_progress: (optional) Whether module items must be unlocked in order
        :type module_require_sequential_progress: boolean or None
        :param module_prerequisite_module_ids: (optional) IDs of Modules that must be completed before this one is unlocked Prerequisite modules must precede this module (i.e. have a lower position value), otherwise they will be ignored
        :type module_prerequisite_module_ids: string or None
        :param module_publish_final_grade: (optional) Whether to publish the student's final grade for the course upon completion of this module.
        :type module_publish_final_grade: boolean or None
        :param module_published: (optional) Whether the module is published and visible to students
        :type module_published: boolean or None
        :return: Update a module
        :rtype: requests.Response (with Module data)

    """

    path = '/v1/courses/{course_id}/modules/{id}'
    payload = {
        'module[name]': module_name,
        'module[unlock_at]': module_unlock_at,
        'module[position]': module_position,
        'module[require_sequential_progress]':
        module_require_sequential_progress,
        'module[prerequisite_module_ids]': module_prerequisite_module_ids,
        'module[publish_final_grade]': module_publish_final_grade,
        'module[published]': module_published,
    }
    url = request_ctx.base_api_url + path.format(course_id=course_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #47
0
def update_assignment_override(request_ctx,
                               course_id,
                               assignment_id,
                               id,
                               assignment_override_student_ids=None,
                               assignment_override_title=None,
                               assignment_override_due_at=None,
                               assignment_override_unlock_at=None,
                               assignment_override_lock_at=None,
                               **request_kwargs):
    """
    All current overridden values must be supplied if they are to be retained;
    e.g. if due_at was overridden, but this PUT omits a value for due_at,
    due_at will no longer be overridden. If the override is adhoc and
    student_ids is not supplied, the target override set is unchanged. Target
    override sets cannot be changed for group or section overrides.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param assignment_id: (required) ID
        :type assignment_id: string
        :param id: (required) ID
        :type id: string
        :param assignment_override_student_ids: (optional) The IDs of the override's target students. If present, the IDs must each identify a user with an active student enrollment in the course that is not already targetted by a different adhoc override. Ignored unless the override being updated is adhoc.
        :type assignment_override_student_ids: integer or None
        :param assignment_override_title: (optional) The title of an adhoc assignment override. Ignored unless the override being updated is adhoc.
        :type assignment_override_title: string or None
        :param assignment_override_due_at: (optional) The day/time the overridden assignment is due. Accepts times in ISO 8601 format, e.g. 2014-10-21T18:48:00Z. If absent, this override will not affect due date. May be present but null to indicate the override removes any previous due date.
        :type assignment_override_due_at: timestamp or None
        :param assignment_override_unlock_at: (optional) The day/time the overridden assignment becomes unlocked. Accepts times in ISO 8601 format, e.g. 2014-10-21T18:48:00Z. If absent, this override will not affect the unlock date. May be present but null to indicate the override removes any previous unlock date.
        :type assignment_override_unlock_at: timestamp or None
        :param assignment_override_lock_at: (optional) The day/time the overridden assignment becomes locked. Accepts times in ISO 8601 format, e.g. 2014-10-21T18:48:00Z. If absent, this override will not affect the lock date. May be present but null to indicate the override removes any previous lock date.
        :type assignment_override_lock_at: timestamp or None
        :return: Update an assignment override
        :rtype: requests.Response (with AssignmentOverride data)

    """

    path = '/v1/courses/{course_id}/assignments/{assignment_id}/overrides/{id}'
    payload = {
        'assignment_override[student_ids]': assignment_override_student_ids,
        'assignment_override[title]': assignment_override_title,
        'assignment_override[due_at]': assignment_override_due_at,
        'assignment_override[unlock_at]': assignment_override_unlock_at,
        'assignment_override[lock_at]': assignment_override_lock_at,
    }
    url = request_ctx.base_api_url + path.format(
        course_id=course_id, assignment_id=assignment_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #48
0
def update_calendar_event(request_ctx, id, calendar_event_context_code, calendar_event_title=None, calendar_event_description=None, calendar_event_start_at=None, calendar_event_end_at=None, calendar_event_location_name=None, calendar_event_location_address=None, calendar_event_time_zone_edited=None, calendar_event_child_event_data_X_start_at=None, calendar_event_child_event_data_X_end_at=None, calendar_event_child_event_data_X_context_code=None, **request_kwargs):
    """
    Update and return a calendar event

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param calendar_event_context_code: (required) Context code of the course/group/user whose calendar this event should be added to.
        :type calendar_event_context_code: string
        :param calendar_event_title: (optional) Short title for the calendar event.
        :type calendar_event_title: string or None
        :param calendar_event_description: (optional) Longer HTML description of the event.
        :type calendar_event_description: string or None
        :param calendar_event_start_at: (optional) Start date/time of the event.
        :type calendar_event_start_at: datetime or None
        :param calendar_event_end_at: (optional) End date/time of the event.
        :type calendar_event_end_at: datetime or None
        :param calendar_event_location_name: (optional) Location name of the event.
        :type calendar_event_location_name: string or None
        :param calendar_event_location_address: (optional) Location address
        :type calendar_event_location_address: string or None
        :param calendar_event_time_zone_edited: (optional) Time zone of the user editing the event. Allowed time zones are {http://www.iana.org/time-zones IANA time zones} or friendlier {http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html Ruby on Rails time zones}.
        :type calendar_event_time_zone_edited: string or None
        :param calendar_event_child_event_data_X_start_at: (optional) Section-level start time(s) if this is a course event. X can be any identifier, provided that it is consistent across the start_at, end_at and context_code
        :type calendar_event_child_event_data_X_start_at: datetime or None
        :param calendar_event_child_event_data_X_end_at: (optional) Section-level end time(s) if this is a course event.
        :type calendar_event_child_event_data_X_end_at: datetime or None
        :param calendar_event_child_event_data_X_context_code: (optional) Context code(s) corresponding to the section-level start and end time(s).
        :type calendar_event_child_event_data_X_context_code: string or None
        :return: Update a calendar event
        :rtype: requests.Response (with void data)

    """

    path = '/v1/calendar_events/{id}'
    payload = {
        'calendar_event[context_code]' : calendar_event_context_code,
        'calendar_event[title]' : calendar_event_title,
        'calendar_event[description]' : calendar_event_description,
        'calendar_event[start_at]' : calendar_event_start_at,
        'calendar_event[end_at]' : calendar_event_end_at,
        'calendar_event[location_name]' : calendar_event_location_name,
        'calendar_event[location_address]' : calendar_event_location_address,
        'calendar_event[time_zone_edited]' : calendar_event_time_zone_edited,
        'calendar_event[child_event_data][X][start_at]' : calendar_event_child_event_data_X_start_at,
        'calendar_event[child_event_data][X][end_at]' : calendar_event_child_event_data_X_end_at,
        'calendar_event[child_event_data][X][context_code]' : calendar_event_child_event_data_X_context_code,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #49
0
def update_outcome(request_ctx, id, title=None, display_name=None, description=None, vendor_guid=None, mastery_points=None, ratings_description=None, ratings_points=None, **request_kwargs):
    """
    Modify an existing outcome. Fields not provided are left as is;
    unrecognized fields are ignored.
    
    If any new ratings are provided, the combination of all new ratings
    provided completely replace any existing embedded rubric criterion; it is
    not possible to tweak the ratings of the embedded rubric criterion.
    
    A new embedded rubric criterion's mastery_points default to the maximum
    points in the highest rating if not specified in the mastery_points
    parameter. Any new ratings lacking a description are given a default of "No
    description". Any new ratings lacking a point value are given a default of
    0.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param title: (optional) The new outcome title.
        :type title: string or None
        :param display_name: (optional) A friendly name shown in reports for outcomes with cryptic titles, such as common core standards names.
        :type display_name: string or None
        :param description: (optional) The new outcome description.
        :type description: string or None
        :param vendor_guid: (optional) A custom GUID for the learning standard.
        :type vendor_guid: string or None
        :param mastery_points: (optional) The new mastery threshold for the embedded rubric criterion.
        :type mastery_points: integer or None
        :param ratings_description: (optional) The description of a new rating level for the embedded rubric criterion.
        :type ratings_description: string or None
        :param ratings_points: (optional) The points corresponding to a new rating level for the embedded rubric criterion.
        :type ratings_points: integer or None
        :return: Update an outcome
        :rtype: requests.Response (with Outcome data)

    """

    path = '/v1/outcomes/{id}'
    payload = {
        'title' : title,
        'display_name' : display_name,
        'description' : description,
        'vendor_guid' : vendor_guid,
        'mastery_points' : mastery_points,
        'ratings[description]' : ratings_description,
        'ratings[points]' : ratings_points,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
def update_group_category(request_ctx,
                          group_category_id,
                          name,
                          self_signup=None,
                          auto_leader=None,
                          group_limit=None,
                          create_group_count=None,
                          split_group_count=None,
                          **request_kwargs):
    """
    Modifies an existing group category.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param group_category_id: (required) ID
        :type group_category_id: string
        :param name: (required) Name of the group category
        :type name: string
        :param self_signup: (optional) Allow students to sign up for a group themselves (Course Only). Valid values are: "enabled":: allows students to self sign up for any group in course "restricted":: allows students to self sign up only for groups in the same section null disallows self sign up
        :type self_signup: string or None
        :param auto_leader: (optional) Assigns group leaders automatically when generating and allocating students to groups Valid values are: "first":: the first student to be allocated to a group is the leader "random":: a random student from all members is chosen as the leader
        :type auto_leader: string or None
        :param group_limit: (optional) Limit the maximum number of users in each group (Course Only). Requires self signup.
        :type group_limit: string or None
        :param create_group_count: (optional) Create this number of groups (Course Only).
        :type create_group_count: string or None
        :param split_group_count: (optional) (Deprecated) Create this number of groups, and evenly distribute students among them. not allowed with "enable_self_signup". because the group assignment happens synchronously, it's recommended that you instead use the assign_unassigned_members endpoint. (Course Only)
        :type split_group_count: string or None
        :return: Update a Group Category
        :rtype: requests.Response (with GroupCategory data)

    """

    self_signup_types = ('enabled', 'restricted')
    auto_leader_types = ('first', 'random')
    utils.validate_attr_is_acceptable(self_signup, self_signup_types)
    utils.validate_attr_is_acceptable(auto_leader, auto_leader_types)
    path = '/v1/group_categories/{group_category_id}'
    payload = {
        'name': name,
        'self_signup': self_signup,
        'auto_leader': auto_leader,
        'group_limit': group_limit,
        'create_group_count': create_group_count,
        'split_group_count': split_group_count,
    }
    url = request_ctx.base_api_url + path.format(
        group_category_id=group_category_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #51
0
def update_student_question_scores_and_comments(request_ctx,
                                                course_id,
                                                quiz_id,
                                                id,
                                                attempt,
                                                fudge_points=None,
                                                questions=None,
                                                **request_kwargs):
    """
    Update the amount of points a student has scored for questions they've
    answered, provide comments for the student about their answer(s), or simply
    fudge the total score by a specific amount of points.
    
    <b>Responses</b>
    
    * <b>200 OK</b> if the request was successful
    * <b>403 Forbidden</b> if you are not a teacher in this course
    * <b>400 Bad Request</b> if the attempt parameter is missing or invalid
    * <b>400 Bad Request</b> if the specified QS attempt is not yet complete

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param course_id: (required) ID
        :type course_id: string
        :param quiz_id: (required) ID
        :type quiz_id: string
        :param id: (required) ID
        :type id: string
        :param attempt: (required) The attempt number of the quiz submission that should be updated. This attempt MUST be already completed.
        :type attempt: integer
        :param fudge_points: (optional) Amount of positive or negative points to fudge the total score by.
        :type fudge_points: float or None
        :param questions: (optional) A set of scores and comments for each question answered by the student. The keys are the question IDs, and the values are hashes of `score` and `comment` entries. See {Appendix: Manual Scoring} for more on this parameter.
        :type questions: hash or None
        :return: Update student question scores and comments.
        :rtype: requests.Response (with void data)

    """

    path = '/v1/courses/{course_id}/quizzes/{quiz_id}/submissions/{id}'
    payload = {
        'attempt': attempt,
        'fudge_points': fudge_points,
        'questions': questions,
    }
    url = request_ctx.base_api_url + path.format(
        course_id=course_id, quiz_id=quiz_id, id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #52
0
def edit_user(request_ctx,
              id,
              user_name=None,
              user_short_name=None,
              user_sortable_name=None,
              user_time_zone=None,
              user_locale=None,
              user_avatar_token=None,
              user_avatar_url=None,
              **request_kwargs):
    """
    Modify an existing user. To modify a user's login, see the documentation for logins.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param user_name: (optional) The full name of the user. This name will be used by teacher for grading.
        :type user_name: string or None
        :param user_short_name: (optional) User's name as it will be displayed in discussions, messages, and comments.
        :type user_short_name: string or None
        :param user_sortable_name: (optional) User's name as used to sort alphabetically in lists.
        :type user_sortable_name: string or None
        :param user_time_zone: (optional) The time zone for the user. Allowed time zones are {http://www.iana.org/time-zones IANA time zones} or friendlier {http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html Ruby on Rails time zones}.
        :type user_time_zone: string or None
        :param user_locale: (optional) The user's preferred language as a two-letter ISO 639-1 code.
        :type user_locale: string or None
        :param user_avatar_token: (optional) A unique representation of the avatar record to assign as the user's current avatar. This token can be obtained from the user avatars endpoint. This supersedes the user[avatar][url] argument, and if both are included the url will be ignored. Note: this is an internal representation and is subject to change without notice. It should be consumed with this api endpoint and used in the user update endpoint, and should not be constructed by the client.
        :type user_avatar_token: string or None
        :param user_avatar_url: (optional) To set the user's avatar to point to an external url, do not include a token and instead pass the url here. Warning: For maximum compatibility, please use 128 px square images.
        :type user_avatar_url: string or None
        :return: Edit a user
        :rtype: requests.Response (with User data)

    """

    path = '/v1/users/{id}'
    payload = {
        'user[name]': user_name,
        'user[short_name]': user_short_name,
        'user[sortable_name]': user_sortable_name,
        'user[time_zone]': user_time_zone,
        'user[locale]': user_locale,
        'user[avatar][token]': user_avatar_token,
        'user[avatar][url]': user_avatar_url,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #53
0
def update_role(request_ctx,
                account_id,
                role,
                label=None,
                permissions={},
                **request_kwargs):
    """
    Update permissions for an existing role.

    Recognized roles are:
    * TeacherEnrollment
    * StudentEnrollment
    * TaEnrollment
    * ObserverEnrollment
    * DesignerEnrollment
    * AccountAdmin
    * Any previously created custom role

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param account_id: (required) ID
        :type account_id: string
        :param role: (required) ID
        :type role: string
        :param label: The label for the role. Can only change the label of a custom role that belongs directly to the account.
        :type label: string
        :param permissions: (optional) Specifies the permissions that will be granted to this role. See Canvas API docs for details on the structure.
        :type permissions: dict
        :return: Update a role
        :rtype: requests.Response (with Role data)

    """

    path = '/v1/accounts/{account_id}/roles/{role}'
    payload = {}
    if label and label != '':
        payload['label'] = label
    # flatten the permissions dict
    for p in permissions:
        for a in permissions[p]:
            payload['permissions[{}][{}]'.format(p, a)] = permissions[p][a]

    url = request_ctx.base_api_url + path.format(account_id=account_id,
                                                 role=role)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #54
0
def edit_group(request_ctx, group_id, name, description, is_public, join_level,
               avatar_id, storage_quota_mb, **request_kwargs):
    """
    Modifies an existing group.  Note that to set an avatar image for the
    group, you must first upload the image file to the group, and the use the
    id in the response as the argument to this function.  See the
    {file:file_uploads.html File Upload Documentation} for details on the file
    upload workflow.

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param group_id: (required) ID
        :type group_id: string
        :param name: (required) The name of the group
        :type name: string
        :param description: (required) A description of the group
        :type description: string
        :param is_public: (required) Whether the group is public (applies only to community groups). Currently you cannot set a group back to private once it has been made public.
        :type is_public: boolean
        :param join_level: (required) no description
        :type join_level: string
        :param avatar_id: (required) The id of the attachment previously uploaded to the group that you would like to use as the avatar image for this group.
        :type avatar_id: integer
        :param storage_quota_mb: (required) The allowed file storage for the group, in megabytes. This parameter is ignored if the caller does not have the manage_storage_quotas permission.
        :type storage_quota_mb: integer
        :return: Edit a group
        :rtype: requests.Response (with Group data)

    """

    join_level_types = ('parent_context_auto_join', 'parent_context_request',
                        'invitation_only')
    utils.validate_attr_is_acceptable(join_level, join_level_types)
    path = '/v1/groups/{group_id}'
    payload = {
        'name': name,
        'description': description,
        'is_public': is_public,
        'join_level': join_level,
        'avatar_id': avatar_id,
        'storage_quota_mb': storage_quota_mb,
    }
    url = request_ctx.base_api_url + path.format(group_id=group_id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #55
0
def update_role(request_ctx,
                account_id,
                role,
                permissions_X_explicit=None,
                permissions_X_enabled=None,
                **request_kwargs):
    """
    Update permissions for an existing role.
    
    Recognized roles are:
    * TeacherEnrollment
    * StudentEnrollment
    * TaEnrollment
    * ObserverEnrollment
    * DesignerEnrollment
    * AccountAdmin
    * Any previously created custom role

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param account_id: (required) ID
        :type account_id: string
        :param role: (required) ID
        :type role: string
        :param permissions_X_explicit: (optional) no description
        :type permissions_X_explicit: boolean or None
        :param permissions_X_enabled: (optional) These arguments are described in the documentation for the {api:RoleOverridesController#add_role add_role method}.
        :type permissions_X_enabled: boolean or None
        :return: Update a role
        :rtype: requests.Response (with Role data)

    """

    path = '/v1/accounts/{account_id}/roles/{role}'
    payload = {
        'permissions[X][explicit]': permissions_X_explicit,
        'permissions[X][enabled]': permissions_X_enabled,
    }
    url = request_ctx.base_api_url + path.format(account_id=account_id,
                                                 role=role)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response
Пример #56
0
def update_folder(request_ctx, id, name, parent_folder_id, lock_at, unlock_at,
                  locked, hidden, position, **request_kwargs):
    """
    Updates a folder

        :param request_ctx: The request context
        :type request_ctx: :class:RequestContext
        :param id: (required) ID
        :type id: string
        :param name: (required) The new name of the folder
        :type name: string
        :param parent_folder_id: (required) The id of the folder to move this folder into. The new folder must be in the same context as the original parent folder.
        :type parent_folder_id: string
        :param lock_at: (required) The datetime to lock the folder at
        :type lock_at: datetime
        :param unlock_at: (required) The datetime to unlock the folder at
        :type unlock_at: datetime
        :param locked: (required) Flag the folder as locked
        :type locked: boolean
        :param hidden: (required) Flag the folder as hidden
        :type hidden: boolean
        :param position: (required) Set an explicit sort position for the folder
        :type position: integer
        :return: Update folder
        :rtype: requests.Response (with Folder data)

    """

    path = '/v1/folders/{id}'
    payload = {
        'name': name,
        'parent_folder_id': parent_folder_id,
        'lock_at': lock_at,
        'unlock_at': unlock_at,
        'locked': locked,
        'hidden': hidden,
        'position': position,
    }
    url = request_ctx.base_api_url + path.format(id=id)
    response = client.put(request_ctx, url, payload=payload, **request_kwargs)

    return response