Modify a word many times within a long questionnaire

Is there a way to modify a word many times within a long questionnaire? For this I imagine that it is necessary to have access to the main code of the questionnaire. (this can solve many things, like speed up the build process) Is there such a thing?

What are you trying to do, why would you do that?

Thanks for your question! It may take a long time to explain …
here I go: I have created a text variable with the color code that I assign to certain questions. There are a lot of questions. Previously, I assigned the color with: “red”. Now I need to modify that word with my variables %code_color% in the whole questionnaire. This will allow me to modify the color only once in my variable. This is just an application example, but there may be many more.

This sounds like a table code_color → name_color

code_color name_color
1 red
2 green
3 blue

Then you can use the ? : Operator to check the code_color and assign the name color to the variable.

For example:
code_color == 1 ? "Red" :
code_color == 2 ? "Green" : "Blue":
"Color by default"

There is a search/replace functionality (click on the magnifier icon, or press CTRL-F).

1 Like

Thank you so much! I just realized how much is behind the magnifier icon, even regular expressions !!!

I only have the doubt if there is a way to access the main code of the questionnaire to work all the construction programmatically. Will it be possible?

Thanks again!

Yes, for example this: \b(\w+?)\s\1\b will find all entries with duplicate words in them.

Could you please explain what is the case for construction of the questionnaire programmatically?

I imagine a tool that allows access to the code of a questionnaire. (I imagine there is more than one code, at least front and back). In this case it would be the backend, I mean the code of the questions and that supports the logic and stages of the questionnaire. This would allow working in a text editor and programming the questionnaire. Adding questions using the language in which this code is built. Later this code can be uploaded to the Survey Solutions server and based on this code generate the questionnaire. With this available, the opensource community of developers could create Survey Solution wrappers with other languages ​​(Python, R) to generate questionnaires in the user’s preferred languages. I imagine that there are people who prefer the excellent user interface that SurveySolution offers and there are others who would prefer to build the questionnaire using programming tools.

As an example, R has a package called Shiny, which works as a wrapper for other languages, facilitating the deployment of web applications.

I hope I can explain myself clearly.

Greetings and thanks for your time. …

Survey Solutions describes the questionnaire in its own format, which you can see when you export the data from the HQ. Refer to the file as described here:

However importing the documents in this format will require

  • absolute compatibility of the tool;
  • commitment to enforce the limits that Survey Solutions supports;
  • security safeguards to prevent injecting malicious code;
  • commitment to compile migrations to the updated Survey Solutions requirements;
  • ability of the authors to support the users of those tools;
    etc, etc, etc

Can we have a show of hands who is willing to contribute?

I had played some time ago with creating questionnaires offline (using Python). I had since removed the ssaw.designer module from the repo but seems like the example script is still out there - ssaw/ at main · vavalomi/ssaw · GitHub

Because of the removed module, this script is unfortunately not going to work but you may get the idea which way I was going.

The biggest hurdle (ind addition to what @sergiy has outlined above) is that questionnaire is not just a static structure, but contains expressions in a specific language (C#).

Although you have examples on dual-language documents (like html with embedded javascript or styles) but I felt it wouldn’t be super convenient to write a questionnaire in python but then use C# string constants as expressions. When you work in the online designer you get syntax highlighting, compiling errors and warning. All this would be absent in the offline mixed-language mode.

Of course it would’ve been cool to have the expression engine in python, R, javascript and other languages but the bottleneck is Android - we at this moment don’t have good way to run these expressions on the tablet, only C#.