<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "macCatalyst: 17.4.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Assignables",
  "identifier" : "/documentation/Assignables/AssignedWorkDocument",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Assignables"
    ],
    "preciseIdentifier" : "s:11Assignables20AssignedWorkDocumentV"
  },
  "title" : "AssignedWorkDocument"
}
-->

# AssignedWorkDocument

An assigned work document is a document that contains taker and
scorer markup specific to a taker. It also contains a copy of the assignable
document upon which it is based.

```
struct AssignedWorkDocument
```

## Overview

This document has a collection of [`AssignedWorkDocument.ScoreAnnotation`](/documentation/Assignables/AssignedWorkDocument/ScoreAnnotation) objects
that represent marks such as correct and incorrect marks on a page.
Score annotations are not automatically associated with a question
defined in the `AssignableDocument` that this work document is based on.
To determine the score for the work, you use `computeScore`.

You cannot instantiate this document type directly. Instead, you instantiate
it by calling [`assign(to:)`](/documentation/Assignables/AssignableDocument/assign(to:)) or
`makeAssignedWorkDocument()`.

This document is fully mergeable, which means that any copies of this document
that are independently mutated can be merged into a determinisitic resulting
document. You can merge copies of this document into this one using
[`merge(_:)`](/documentation/Assignables/AssignedWorkDocument/merge(_:)).
You can also merge individual parts of copies of this
document into this one with [`merge(partData:into:)`](/documentation/Assignables/AssignedWorkDocument/merge(partData:into:)).
For example, if deviceA has documentA and
deviceB has documentB, which is a copy of documentA. When a user changes a
question in documentB on deviceB, deviceB can export that part’s data
and send it to deviceA to be merged back into documentA.

You can create as many of these objects as you have memory for.
This type assumes single-threaded access.

## Topics

### Creating an assigned work document

[`init(id: AssignedWorkDocument.ID, assignableDocument: AssignableDocument, partData: [AssignedWorkDocument.PartID : MergeablePartData]) async throws`](/documentation/Assignables/AssignedWorkDocument/init(id:assignableDocument:partData:)-8eh38)

Construct an instance of this object with the parts data passed in.

[`init(id: AssignedWorkDocument.ID, assignableDocument: AssignableDocument, partData: [AssignedWorkDocument.PartID : URL]) throws`](/documentation/Assignables/AssignedWorkDocument/init(id:assignableDocument:partData:)-54yg5)

Construct an instance of this object with the parts data passed in.

### Inspecting a work document

[`typealias ID`](/documentation/Assignables/AssignedWorkDocument/ID-swift.typealias)

A type representing the stable identity of this document.

[`var id: AssignedWorkDocument.ID`](/documentation/Assignables/AssignedWorkDocument/id-swift.property)

The stable identity of this document.

[`var isMultiPageDocument: Bool`](/documentation/Assignables/AssignedWorkDocument/isMultiPageDocument)

`true`, if this document has more than one page; `false`, otherwise.

[`var isPartial: Bool`](/documentation/Assignables/AssignedWorkDocument/isPartial)

Denotes whether or not this document is a partial one.

[`enum PartIDs`](/documentation/Assignables/AssignedWorkDocument/PartIDs-swift.enum)

An enumeration containing the identities of parts managed by this view.

[`var partIDs: [MergeablePartsContainerPartID]`](/documentation/Assignables/AssignedWorkDocument/partIDs-swift.property)

Returns a collection of identifiers reflecting the manifest of parts available in the document.

[`var scoreAnnotations: [AssignedWorkDocument.ScoreAnnotation]`](/documentation/Assignables/AssignedWorkDocument/scoreAnnotations)

The collection of score annotations for this work document.
Treated as a multiset. i.e. The order of the elements doesn’t matter
and duplicate values are allowed.

[`var scorers: [AnyUserIdentity]`](/documentation/Assignables/AssignedWorkDocument/scorers)

The identities of users scoring this assigned work.
Treated as a set.

[`var pagesDebugDescription: String`](/documentation/Assignables/AssignedWorkDocument/pagesDebugDescription)

[`enum Error`](/documentation/Assignables/AssignedWorkDocument/Error)

Errors for this document type.

### Getting the assignable document

[`var assignableDocument: AssignableDocument`](/documentation/Assignables/AssignedWorkDocument/assignableDocument)

The assignable document that this work document is based on.

### Getting the assignees

[`var assignees: [AnyUserIdentity]`](/documentation/Assignables/AssignedWorkDocument/assignees)

The identities of takers of this document.
Treated as a set.

### Getting the configuration

[`typealias Configuration`](/documentation/Assignables/AssignedWorkDocument/Configuration-swift.typealias)

The configuration for an assessment taker work which contains
an optional manual score for the document.

[`var configuration: any AssignedWorkDocumentConfiguration`](/documentation/Assignables/AssignedWorkDocument/configuration-swift.property)

The configuration for a taker work which contains
an optional manual score for the document.

### Merging the parts

[`func merge(AssignedWorkDocument) async throws -> Bool`](/documentation/Assignables/AssignedWorkDocument/merge(_:))

Merge another object of this type into this object.

[`func merge(partData: MergeablePartData, into: AssignedWorkDocument.PartID) async throws -> Bool`](/documentation/Assignables/AssignedWorkDocument/merge(partData:into:))

Merges an individual part into the specified part of this object.

[`func merge(other: AssignedWorkDocument) throws -> Bool`](/documentation/Assignables/AssignedWorkDocument/merge(other:))

Merge another object of this type into this object.

[`func merge(partID: AssignedWorkDocument.PartID, partDataURL: URL) throws -> Bool`](/documentation/Assignables/AssignedWorkDocument/merge(partID:partDataURL:))

Merges an individual part’s data into the specified part of this object.

### Producing thumbnails

[`func questionThumbnails(visibleParts: [AssignedWorkDocument.PartID]) async -> [AssignableDocument.Question.ID : [AssignableDocument.Question.Thumbnail]]`](/documentation/Assignables/AssignedWorkDocument/questionThumbnails(visibleParts:))

Produces thumbnails of question regions within the document.

### Computing the score

[`func computeScore() -> Double`](/documentation/Assignables/AssignedWorkDocument/computeScore())

Gathers all of the points based on all the `AssignedWorkDocument.ScoreAnnotation`s
in the document and its `kind` property.

[`struct ScoreAnnotation`](/documentation/Assignables/AssignedWorkDocument/ScoreAnnotation)

A score mark on page of the work document.

### Making the parts

[`func makePart(for: AssignedWorkDocument.PartID) throws -> MergeablePartData?`](/documentation/Assignables/AssignedWorkDocument/makePart(for:))

Creates data for the part with the given identifier.

### Exporting the parts

[`func exportParts(identifiedBy: [AssignedWorkDocument.PartID]) async throws -> [AssignedWorkDocument.PartID : MergeablePartData]`](/documentation/Assignables/AssignedWorkDocument/exportParts(identifiedBy:))

Given a set of part identifiers, return a dictionary
of part ID to part data.

[`func export(partIDs: [AssignedWorkDocument.PartID]) async throws -> [AssignedWorkDocument.PartID : URL]`](/documentation/Assignables/AssignedWorkDocument/export(partIDs:))

Given a set of part identifiers, return a dictionary
of part ID to data objects for the requested parts.

### Comparing work documents

[`static func == (AssignedWorkDocument, AssignedWorkDocument) -> Bool`](/documentation/Assignables/AssignedWorkDocument/==(_:_:))

Returns a Boolean value indicating whether two values are equal.

### Hashing the work document

[`func hash(into: inout Hasher)`](/documentation/Assignables/AssignedWorkDocument/hash(into:))

Hashes the essential components of this value by feeding them into the given hasher.

### Accessing work documents

[`subscript(AssignedWorkDocument.Page.ID) -> AssignedWorkDocument.Page?`](/documentation/Assignables/AssignedWorkDocument/subscript(_:)-4srtw)

Access the page that the ID points to, if any.

[`subscript(AssignedWorkDocument.ScoreAnnotation.ID) -> AssignedWorkDocument.ScoreAnnotation?`](/documentation/Assignables/AssignedWorkDocument/subscript(_:)-5h89c)

Access the score annotation that the identifier refers to, if any.

### Default Implementations

[MergeableDocument Implementations](/documentation/Assignables/AssignedWorkDocument/MergeableDocument-Implementations)

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`MergeablePartsContainer`](/documentation/Assignables/MergeablePartsContainer)

[`MergeableDocument`](/documentation/Assignables/MergeableDocument)

[`Copyable`](/documentation/Swift/Copyable)

[`Identifiable`](/documentation/Swift/Identifiable)

[`Escapable`](/documentation/Swift/Escapable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)