BIDMCDigitalPsychiatry / LAMP-platform

The LAMP Platform (issues and documentation).
https://docs.lamp.digital/
13 stars 10 forks source link

Survey schema updates: warnings, text blocks, randomization groups, and required questions #385

Open avaidyam opened 3 years ago

avaidyam commented 3 years ago

A Survey activity's settings are currently an array of questions to be displayed. Each entry contains question text, type, options, etc.


Support warnings popups

In addition to these, a new field warnings should be added. This field will contain a dictionary mapping of values to text, as shown below:

"warnings": {
    "3": "This survey is not being monitored for responses."
}

If the warnings field is not defined as part of a question's settings, it is ignored, to ensure backwards compatibility. If the response specified by the user exists in this warnings dictionary, then the corresponding text will be shown to the user in a simple alert dialog with an "OK" button. If the user's response is NOT found in this dictionary OR there is no warnings dictionary, it is ignored and no dialog is shown. This applies to ANY question type, including text, rating, or list, etc.


Support null question type

If the type for a question is null, then NO user entry should be permitted; this effectively converts the question into a block of text. The text should be displayed with no use entry fields. The duration timer should still run to track how long the text was read by the user for.


Support required question fields

A new required field should indicate that the survey cannot be completed without the completion of this particular question on which required = true. If this field does not exist, it should be considered optional for backwards compatibility.

The current implementation of slider and rating questions defaults to the first value in the options list; this behavior must be changed such that no value is selected by default. If required is not true or undefined for the question, the activity event temporal slice value field must be null to indicate no user response.


Support randomizationGroup field

The new randomizationGroup field requires a string value that indicates whether this question is to be randomized. If this field is undefined/not found for a question, it is presented in the question index order (current implementation/behavior).

Array.prototype.sample = function() { return this[Math.floor(Math.random() * this.length)] }

The Activity settings/configuration UI may ONLY be modified through updating the JSON Schema for the Survey activity; no other custom UI elements should be changed.

avaidyam commented 2 years ago

@dcurrey88 Patching you in from issue #518 - it looks like this is what you want:

Support null question type If the type for a question is null, then NO user entry should be permitted; this effectively converts the question into a block of text. The text should be displayed with no use entry fields. The duration timer should still run to track how long the text was read by the user for.