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

    taskInfo

    Additional information about the task.

    stepNavigator

    The step navigator for this task.

    schemaInfo

    Information about the result schema.

    asyncActions

    A list of asynchronous actions to run on the task.

    usesTrackedData

    Does 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) format
    
  • Throws

    DecodingError if there is a decoding error.

    Declaration

    Swift

    public required init(from decoder: Decoder) throws

    Parameters

    decoder

    The decoder to use to decode this instance.

  • Instantiate a task result that is appropriate for this task.

    Declaration

    Swift

    open func instantiateTaskResult() -> RSDTaskResult

    Return 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 stepNavigator implements RSDTaskData and 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 usesTrackedData set to true and the method instantiateScoreBuilder() 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)
  • Should this step use a result from a previous run? In the default implementation, the task object acts only as a pass-through for the step navigator if that object implements the protocol.

    Declaration

    Swift

    open func shouldSkipStep(_ step: RSDStep) -> (shouldSkip: Bool, stepResult: RSDResult?)
  • 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 RSDScoringResult or RSDAnswerResult and 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 for RecursiveScoreBuilder.

    This method is only called if the step navigator attached to this task does not implement the RSDTrackingTask protocol.

    Declaration

    Swift

    open func instantiateScoreBuilder() -> RSDScoreBuilder?