RSDTaskObject
open class RSDTaskObject : RSDUIActionHandlerObject, RSDCopyTask, RSDTrackingTask, Decodable
RSDTaskObject is the interface for running a task. It includes information about how to calculate progress,
validation, and the order of display for the steps.
-
A short string that uniquely identifies the task.
Declaration
Swift
public let identifier: String -
Copyright information about the task.
Declaration
Swift
open private(set) var copyright: String? { get } -
Information about the result schema.
Declaration
Swift
open private(set) var schemaInfo: RSDSchemaInfo? { get } -
The step navigator for this task.
Declaration
Swift
public let stepNavigator: RSDStepNavigator -
A list of asynchronous actions to run on the task.
Declaration
Swift
public let asyncActions: [RSDAsyncActionConfiguration]? -
Does this task use stored data and/or include a scoring at this level?
Declaration
Swift
public let usesTrackedData: Bool -
Default initializer.
Declaration
Swift
public required init(identifier: String, stepNavigator: RSDStepNavigator, schemaInfo: RSDSchemaInfo? = nil, asyncActions: [RSDAsyncActionConfiguration]? = nil, usesTrackedData: Bool = false)Parameters
taskInfoAdditional information about the task.
stepNavigatorThe step navigator for this task.
schemaInfoInformation about the result schema.
asyncActionsA list of asynchronous actions to run on the task.
usesTrackedDataDoes this task use stored data and/or include a scoring at this level?
-
Initialize from a
Decoder.example:
let json = """ { "identifier" : "foo", "usesTrackedData" : false, "schemaInfo" : { "identifier" : "foo.1.2", "revision" : 3 }, "steps": [ { "identifier": "step1", "type": "instruction", "title": "Step 1" }, { "identifier": "step2", "type": "instruction", "title": "Step 2" }, ] "asyncActions" : [ { "identifier" : "location", "type" : "location" } ] } """.data(using: .utf8)! // our data in native (JSON) formatThrows
DecodingErrorif there is a decoding error.Declaration
Swift
public required init(from decoder: Decoder) throwsParameters
decoderThe decoder to use to decode this instance.
-
Instantiate a task result that is appropriate for this task.
Declaration
Swift
open func instantiateTaskResult() -> RSDTaskResultReturn Value
A task result for this task.
-
Validate the task to check for any model configuration that should throw an error.
Throws
An error appropriate to the failed validation.Declaration
Swift
open func validate() throws
-
Returns the task data for this task result.
The default implementation will first look to see if the
stepNavigatorimplementsRSDTaskDataand if so, will return the task data from the navigator.Otherwise, the task will only build a score if this task object has the property
usesTrackedDataset to true and the methodinstantiateScoreBuilder()returns a score builder.Declaration
Swift
open func taskData(for taskResult: RSDTaskResult) -> RSDTaskData? -
Setup the data tracker. In the default implementation, the task object only acts as a pass-through for the step navigator if that object implements the protocol.
Declaration
Swift
open func setupTask(with data: RSDTaskData?, for path: RSDTaskPathComponent) -
Instantiate the score builder to use to build the task data for this task result.
The default behavior is to use a simple recursive builder that will look for results that implement either
RSDScoringResultorRSDAnswerResultand return either a dictionary or array as applicable if more than one score is found at any given level of subtask result or collection result. For a more detailed description, go code spelunking into the unit tests forRecursiveScoreBuilder.This method is only called if the step navigator attached to this task does not implement the
RSDTrackingTaskprotocol.Declaration
Swift
open func instantiateScoreBuilder() -> RSDScoreBuilder?
-
Declaration
Swift
public func copy(with identifier: String, schemaInfo: RSDSchemaInfo?) -> Self -
Declaration
Swift
public func copy(with identifier: String) -> Self
View on GitHub
RSDTaskObject Class Reference