# Update an assignment

Updates the fields supplied and leaves the rest untouched, then returns the
assignment in the same shape as reading it. Every field is optional and an
empty body is a valid request that changes nothing.
**status and steps_completed are kept consistent with each other**, so
sending one can change the other:
- Setting status to COMPLETE sets steps_completed to the module's full step
count.
- Setting status to INCOMPLETE on an assignment that was COMPLETE resets
steps_completed to 0.
- Sending a steps_completed equal to the module's full step count sets status
to COMPLETE, whether or not status was sent.

So a request that sends only one of the two can come back with both changed.
Read the returned record rather than assuming the values you sent.
Moving an assignment to a status that counts as finished - COMPLETE, PASSED or
EXEMPT - is what marks the module done for that user, and runs whatever the
module has set up to follow completion, such as issuing a certificate. If the
module has a retake period, expires_at is set from it at the same time.
The assignment must belong to the module in the URL; a mismatched pair returns
a 404. Invalid input returns a 422 identifying the fields at fault.
Send neither training_id nor user_id unless you mean to hand the assignment to
a different module or a different user. Changing training_id is applied and
*then* returns a 404, because the updated record no longer belongs to the
module in the URL - so a 404 here does not mean the change was rejected.

Endpoint: PUT /api/v2/training/{training_id}/user/{id}
Version: 2.0.0
Security: default

## Path parameters:

  - `training_id` (integer, required)
    The ID of the training module.

  - `id` (integer, required)
    The ID of the assignment.

## Header parameters:

  - `Rosterfy-Platform` (string)

## Request fields (application/json):

  - `training_id` (integer)
    The module the assignment belongs to. Taken from the URL on create, so there is no need to send it. Sending a different one on update moves the assignment to that module, and because the response is then read back against the module in the URL, the request returns 404 even though the move has been applied. Omit it.

  - `user_id` (integer)
    The user the module is assigned to. Required on create. Sending it on update hands the assignment, and the progress recorded against it, to a different user - so omit it unless that is what you want.

  - `status` (string)
    Where the user has got to. One of COMPLETE, INCOMPLETE, PASSED, FAILED or EXEMPT. Defaults to INCOMPLETE on create. Setting it to COMPLETE also sets steps_completed to the module's full step count; setting it back to INCOMPLETE from COMPLETE resets steps_completed to 0.

  - `steps_completed` (integer)
    How many of the module's steps the user has finished. Sending a value equal to the module's total step count marks the assignment COMPLETE.

  - `expires_at` (string)
    When the completion stops counting, as YYYY-MM-DD HH:MM:SS. Set automatically from the module's retake period when the assignment completes, so it rarely needs sending.

  - `score` (integer)
    The score the user achieved. Stored as sent and not validated, so keep it a whole number.

  - `external_id` (string)
    Your own reference for the assignment, or the status reported by an externally hosted course. Stored as sent and not validated.

  - `meta` (object)
    Free-form object stored against the assignment. Rosterfy keeps the completion history under a history key, so send a full object rather than a partial one.

## Response 200 fields (application/json):

  - `object` (object)

  - `object.id` (integer)

  - `object.training_id` (integer)

  - `object.user_id` (integer)

  - `object.steps_completed` (integer)

  - `object.status` (string)

  - `object.score` (integer)

  - `object.expires_at` (string | null)

  - `object.meta` (string | null)

  - `object.external_id` (string | null)

  - `object.deleted_at` (string | null)

  - `object.created_at` (string)

  - `object.updated_at` (string)

  - `nice` (object)

  - `nice.rrn` (string)

  - `nice.training_name` (string)

  - `nice.training_service` (string)

  - `nice.training_meta` (object)

  - `nice.training_meta.middleware` (string)

  - `nice.has_history` (boolean)

  - `nice.training_success_message` (string)

  - `nice.is_expired` (boolean)

  - `nice.status` (string)

  - `nice.binary_status` (boolean)

  - `nice.finished_status` (boolean)

  - `nice.score_percentage` (integer)

  - `nice.steps_percentage` (number)

  - `relations` (object)

  - `permissions` (object)

  - `permissions.read` (boolean)

  - `permissions.update` (boolean)

  - `permissions.delete` (boolean)

