RSDFormUIStepObject

RSDFormUIStepObject is a concrete implementation of the RSDFormUIStep and RSDSurveyNavigationStep protocols. It is a subclass of RSDUIStepObject and can be used to display a navigable survey.

  • The inputFields array is used to hold a logical subgrouping of input fields.

    Declaration

    Swift

    open private(set) var inputFields: [RSDInputField] {
      get
      }
  • Default type is .form.

    Declaration

    Swift

    open override class func defaultType() -> RSDStepType
  • Initializer required for copy(with:) implementation.

    Declaration

    Swift

    public required init(identifier: String, type: RSDStepType?)
  • Override to set the properties of the subclass.

    Declaration

    Swift

    override open func copyInto(_ copy: RSDUIStepObject)
  • Default initializer.

    Declaration

    Swift

    public init(identifier: String, inputFields: [RSDInputField], type: RSDStepType? = nil)

    Parameters

    identifier

    A short string that uniquely identifies the step.

    inputFields

    The input fields used to create this step.

    type

    The type of the step. Default = RSDStepType.form

  • Identifier to skip to if all input fields have nil answers.

    Declaration

    Swift

    open var skipToIfNil: String? { get }
  • Identifier for the next step to navigate to based on the current task result.

    Note

    The conditional rule is ignored by this implementation of the navigation rule. Instead, this will evaluate any survey rules and the direct navigation rule inherited from RSDUIStepObject.

    Declaration

    Swift

    open override func nextStepIdentifier(with result: RSDTaskResult?, isPeeking: Bool) -> String?

    Parameters

    result

    The current task result.

    conditionalRule

    The conditional rule associated with this task. (Ignored)

    isPeeking

    Is this navigation rule being called on a result for a step that is navigating forward or is it a step navigator that is peeking at the next step to set up UI display? If peeking at the next step then this parameter will be true.

    Return Value

    The identifier of the next step.

  • Evaluate the task result and return the set of cohorts to add and remove. Default implementation calls evaluateCohortsToApply(with:).

    Declaration

    Swift

    open func cohortsToApply(with result: RSDTaskResult) -> (add: Set<String>, remove: Set<String>)?

    Parameters

    result

    The task result to evaluate.

    Return Value

    The cohorts to add/remove or nil if no rules apply.

  • Initialize from a Decoder. This implementation will query the RSDFactory attached to the decoder for the appropriate implementation for each input field in the array.

  • example:

        // Example JSON dictionary that includes a date, integer, and multiple choice question
        // defined in an array of dictionaries keyed to "inputFields".
        let json = """
            {
            "identifier": "step3",
            "type": "form",
            "title": "Step 3",
            "text": "Some text.",
            "inputFields": [
                            {
                            "identifier": "foo",
                            "type": "date",
                            "uiHint": "picker",
                            "prompt": "Foo",
                            "range" : { "minimumDate" : "2017-02-20",
                                        "maximumDate" : "2017-03-20",
                                        "codingFormat" : "yyyy-MM-dd" }
                            },
                            {
                            "identifier": "bar",
                            "type": "integer",
                            "prompt": "Bar"
                            },
                            {
                            "identifier": "goo",
                            "type": "multipleChoice",
                            "choices" : ["never", "sometimes", "often", "always"]
                            }
                           ]
            }
        """.data(using: .utf8)! // our data in native (JSON) format
    
  • Throws

    DecodingError

    Declaration

    Swift

    public required init(from decoder: Decoder) throws

    Parameters

    decoder

    The decoder to use to decode this instance.

  • Instantiate a step result that is appropriate for this step. The default for this class is a RSDCollectionResultObject.

    Declaration

    Swift

    open override func instantiateStepResult() -> RSDResult

    Return Value

    A result for this step.

  • Validate the step to check for any configuration that should throw an error. This class will check that the input fields have unique identifiers and will call the validate() method on each input field.

    Throws

    An error if validation fails.

    Declaration

    Swift

    open override func validate() throws