How data is stored
In XCAWI2, all data entered by the respondent was first saved before being validated. If there were errors in the data, it would be presented back to the respondent, but it would still be saved in the data.
Perl does not distinguish between different "scalar" datatypes, so in
effect all values were processed and stored as a single type. Values
were interpreted based on the operators used (e.g. == vs eq).
However, Javascript has distinct number, string and boolean types, and
single operators (i.e. == for both numerical and string
comparisons). The new CAWI should therefore store data according to
the correct Javascript type.
INVALID DATA AND DATA TYPES
The intention in the new CAWI is to only save valid responses in the main part of the data store. Invalid values would be saved in the cache, which would allow them to be presented back to the user for correction.
This will just apply to enforcing the definition of the quesiton - it
will not apply to validation checks in the CHECK: block.
Data saved in the main part of the data store should be stored with the correct type (number, string, boolean, array). In both XCAWI2 and the CAPMI, everything was a string,
NOT ASKED vs NO RESPONSE
It would be useful to be able to distinguish between "not asked" and "no response" in the data.
Javascript has two values we can use for this purpose - null and undefined. "null" will be used for "asked but not answered" and "undefined" is used for "not asked".
Questions not on the route will not be present in the data store - so "get()" will return "undefined".
If a question is asked, but no response was given (and the question is not REQUIRED), then "null" will be stored in the data (or the cache) for that question.
Note that using the test x == null (double equals) is true if x is
either null or undefined.
The store() function should check if the value to be stored is
undefined, and delete it instead of storing undefined.
The main issue with this is Multi-response questions - the data is currently stored as a list of the selected values, with no indication that the items missing from that list were presented to the respondent or not.
Also, should "null" be used for strings, or is the empty string better?