Example of All Data Types Being Used

Overview

The following examples illustrate an Instrument that contains fields of every data type supported by the RIOS specification. It is accompanied by a Web Form that is broken up into several pages and uses all available element types.

Instrument

{
  "id": "urn:examples:all-types",
  "version": "1.0",

  "title": "A Simple Example",

  "record": [
    {
      "id": "float_field",
      "type": "float"
    },

    {
      "id": "integer_field",
      "type": "integer"
    },

    {
      "id": "text_field",
      "type": "text"
    },

    {
      "id": "enumeration_field",
      "type": {
        "base": "enumeration",
        "enumerations": {
          "red": {},
          "blue": {},
          "green": {}
        }
      }
    },

    {
      "id": "enumerationset_field",
      "type": {
        "base": "enumerationSet",
        "enumerations": {
          "pizza": {},
          "taco": {},
          "sushi": {},
          "burger": {},
          "salad": {}
        }
      }
    },

    {
      "id": "date_field",
      "type": "date"
    },

    {
      "id": "time_field",
      "type": "time"
    },

    {
      "id": "datetime_field",
      "type": "dateTime"
    },

    {
      "id": "recordlist_field",
      "type": {
        "base": "recordList",
        "record": [
          {
            "id": "sub_field_1",
            "type": "text"
          },

          {
            "id": "sub_field_2",
            "type": "integer"
          }
        ]
      }
    },

    {
      "id": "matrix_field",
      "type": {
        "base": "matrix",
        "rows": [
          {
            "id": "row_1"
          },

          {
            "id": "row_2"
          }
        ],
        "columns": [
          {
            "id": "column_1",
            "type": "text"
          },

          {
            "id": "column_2",
            "type": "integer"
          }
        ]
      }
    }
  ]
}

Web Form

{
  "instrument": {
    "id": "urn:examples:all-types",
    "version": "1.0"
  },

  "defaultLocalization": "en",
  "title": {
    "en": "All RIOS Data Types"
  },

  "pages": [
    {
      "id": "basics",
      "elements": [
        {
          "type": "header",
          "options": {
            "text": {
              "en": "Basic Field Types"
            }
          }
        },

        {
          "type": "text",
          "options": {
            "text": {
              "en": "This page contains questions associated with basic field types."
            }
          }
        },

        {
          "type": "question",
          "options": {
            "fieldId": "text_field",
            "text": {
              "en": "Please enter some text:"
            }
          }
        },

        {
          "type": "question",
          "options": {
            "fieldId": "integer_field",
            "text": {
              "en": "Please enter an integer:"
            }
          }
        },

        {
          "type": "question",
          "options": {
            "fieldId": "float_field",
            "text": {
              "en": "Please enter a number that includes a decimal:"
            }
          }
        }
      ]
    },

    {
      "id": "choices",
      "elements": [
        {
          "type": "header",
          "options": {
            "text": {
              "en": "Choice-Based Field Types"
            }
          }
        },

        {
          "type": "text",
          "options": {
            "text": {
              "en": "This page contains questions associated with enumerated-choice field types."
            }
          }
        },

        {
          "type": "question",
          "options": {
            "fieldId": "enumeration_field",
            "text": {
              "en": "What is your favorite color?"
            },
            "enumerations": [
              {
                "id": "green",
                "text": {
                  "en": "Green"
                }
              },

              {
                "id": "blue",
                "text": {
                  "en": "Blue"
                }
              },

              {
                "id": "red",
                "text": {
                  "en": "Red"
                }
              }
            ]
          }
        },

        {
          "type": "divider"
        },

        {
          "type": "question",
          "options": {
            "fieldId": "enumerationset_field",
            "text": {
              "en": "Which of these foods do you enjoy eating?"
            },
            "enumerations": [
              {
                "id": "taco",
                "text": {
                  "en": "Tacos"
                }
              },

              {
                "id": "salad",
                "text": {
                  "en": "Salads"
                }
              },

              {
                "id": "burger",
                "text": {
                  "en": "Burgers"
                }
              },

              {
                "id": "sushi",
                "text": {
                  "en": "Sushi"
                }
              },

              {
                "id": "pizza",
                "text": {
                  "en": "Pizza"
                }
              }
            ]
          }
        }
      ]
    },

    {
      "id": "temporal",
      "elements": [
        {
          "type": "header",
          "options": {
            "text": {
              "en": "Date/Time-Based Field Types"
            }
          }
        },

        {
          "type": "text",
          "options": {
            "text": {
              "en": "This page contains questions associated with date- and time-related field types."
            }
          }
        },

        {
          "type": "question",
          "options": {
            "fieldId": "date_field",
            "text": {
              "en": "Please enter a date:"
            }
          }
        },

        {
          "type": "question",
          "options": {
            "fieldId": "time_field",
            "text": {
              "en": "Please enter a time:"
            }
          }
        },

        {
          "type": "question",
          "options": {
            "fieldId": "datetime_field",
            "text": {
              "en": "Please enter a date and time:"
            }
          }
        }
      ]
    },

    {
      "id": "complex",
      "elements": [
        {
          "type": "header",
          "options": {
            "text": {
              "en": "Complex Field Types"
            }
          }
        },

        {
          "type": "text",
          "options": {
            "text": {
              "en": "This page contains questions associated with complex field types. Play the following audio clip for more information."
            }
          }
        },

        {
          "type": "audio",
          "options": {
            "source": {
              "en": [
                "http://example.com/instructions.mp3"
              ]
            }
          }
        },

        {
          "type": "question",
          "options": {
            "fieldId": "recordlist_field",
            "text": {
              "en": "Please enter as many combinations of the following two fields as you'd like:"
            },
            "questions": [
              {
                "fieldId": "sub_field_1",
                "text": {
                  "en": "Enter some text:"
                }
              },

              {
                "fieldId": "sub_field_2",
                "text": {
                  "en": "Enter an integer:"
                }
              }
            ]
          }
        },

        {
          "type": "divider"
        },

        {
          "type": "question",
          "options": {
            "fieldId": "matrix_field",
            "text": {
              "en": "Please fill out the following grid:"
            },
            "rows": [
              {
                "id": "row_1",
                "text": {
                  "en": "First Row"
                }
              },

              {
                "id": "row_2",
                "text": {
                  "en": "Second Row"
                }
              }
            ],
            "questions": [
              {
                "fieldId": "column_1",
                "text": {
                  "en": "Enter some text:"
                }
              },

              {
                "fieldId": "column_2",
                "text": {
                  "en": "Enter an integer:"
                }
              }
            ]
          }
        }
      ]
    }
  ]
}

Assessment

{
  "instrument": {
    "id": "urn:examples:all-types",
    "version": "1.0"
  },

  "values": {
    "float_field": {
      "value": 12.3
    },

    "integer_field": {
      "value": 42
    },

    "text_field": {
      "value": "hello world"
    },

    "enumeration_field": {
      "value": "blue"
    },

    "enumerationset_field": {
      "value": ["pizza", "taco"]
    },

    "date_field": {
      "value": "2015-07-04"
    },

    "time_field": {
      "value": "12:34:56"
    },

    "datetime_field": {
      "value": "2010-04-01T03:55:24"
    },

    "recordlist_field": {
      "value": [
        {
          "sub_field_1": {
            "value": "foo"
          },

          "sub_field_2": {
            "value": 12
          }
        },

        {
          "sub_field_1": {
            "value": "bar"
          },

          "sub_field_2": {
            "value": 9001
          }
        }
      ]
    },

    "matrix_field": {
      "value": {
        "row_1": {
          "column_1": {
            "value": "happy"
          },

          "column_2": {
            "value": 1337
          }
        },

        "row_2": {
          "column_1": {
            "value": "sad"
          },

          "column_2": {
            "value": 12345
          }
        }
      }
    }
  }
}