In designer, it would be helpful to be able to copy and past an entire validation condition (syntax and comment) to another question. This would be useful for example in cases where you want to add the same or similar validation to a series of (already programmed) questions. Macro’s are helpful for the syntax, but the comment must still be manually entered or copied separately. Not essential, but would be useful.
Kevin, I really like the idea. But I have a few clarifying questions about what would be most useful:
- copy-paste or copy- paste-modify. Do you want the former, the latter, or both?
- if copy - paste, would you want to source from another question, or from a repository of validations (like macros but with both a condition and a message) ?
- if copy- paste-modify, would the modified validation and message pair be itself something that could be copied and modified? Or are you seeing this more as a function that takes parameters (e.g, threshold not to be exceeded, question to compare against, substring in message that changes) so that the function doesn’t change but its outputs do, as a function of parameters and usage context?
When working on GHS and NLSS we had a lot of questions with identical validation conditions, e.g.
self==0 || or self.InRange(100,20000) for monetary values. Adding and updating all checks was a bit burdensome, as one had to always copy two things, the validation message and the validation syntax and revisit all questions if you wanted to change the condition or wording. Having read your questions I am not sure if copy and paste is necessarily the best way forward, as one would have to re-do things to make updates.
From your suggestions I really like the optional sourcing from a validation repository similar to macros, as this would allow one to easily attach the validation rule to many questions and make quick and systematic updates. Sourcing from other questions would be less transparent as one first has to find the original question. Also, I don’t think it is necessary to be able to modifying the pasted validation rule, as there tend to be more groups of questions with the same validation rules, rather than many questions with a small differences in their validation rules. For each group you could simply refer to the same validation macro, and when creating a new validation macro for a new group of questions one can simply copy and paste twice (and make the modifications).
The thought of a function with parameters is also an interesting one. Where I can really see this work would be in range checks as these are probably the most common and straightforward checks. It would be simpler if one had parameters for the cutoff points from which onward warning and error messages would flag, as well as a parameter for out-of-range allowed values (for DK codes). Ideally one could specify values, and questions and functions. In other more complex checks, I am not sure if one would gain much with parameters over syntax.
Andreas, my most common use cases for this class of thing, so far, have been :
- batch update of range checks when the client decided to change/standardize the DK code. Here, macros worked.
- batch revision of filter conditions to fix errors or implement better ideas /code. Here, I had the same code, except for one parameter : the lookup table name.
- re-use of same code to check that a non zero quantity of something was used when its use was reported used in a previous question (used fertilizer => fertilizer quantity >0). Here, I reused the same code, but two parameters differed : yes/no question about use, name of the thing in the error message (“fertilizer”, “urea”, “phytosanitary product”)
- batch changes to error messages where the save validation is used (e.g, put “ERROR” or “INCONSISTENCY” at the beginning of the message.
The first one doesn’t argue for any new features. The next three, however, do.
Thanks for the other use case, insightful.
For 1 & 4 new functionality would really help to make batch uploads. I am facing a whole questionnaire full of questions with Naira values that need checking as we speak. You are right, use case 1 can be done with a macro, so technically no new feature needed, but with a validation repository one could update the message with the syntax both in one place.
About 2 & 3: interesting cases for function with parameters, I understand it better now. The question I am asking myself here is how much benefit there is in having a new functionality: you would get fewer, but more complex statements/functions. Often it is simpler and faster to just write it up a few times with small modifications rather than specifying something complex. Hard for me to judge here.
Just in case, an error message is optional in Survey Solutions. If you copy just the validation expression, but not the error message, the word ‘error’ (in the active language) will be displayed. This is of course not as good as proper informative error messages, but may be a quick solution if you are just copying range checks or other simple stuff like that.
+1 on Validation repository
Updating every individual validation when you need to change a range or add an extra check is a bit tedious and error prone, especially with the associated changes to both the error message and error message translations .
If we could just add a reference to an existing validation and expect any changes to the validation conditions to affect all the questions with that validation assigned, that would be excellent.
Validations are also much simpler to implement and understand than macros for survey creators.
without a coding background.