Design and use my own function

Dear All,
I’m new to Survey Solutions, but a more than 14 years old Csprouser.
However, Survey Solution have some advanced functionalities such as Websurvey, so i’m starting to use it.

a) Please can i design and use my own function/methods/class (in C#), compile and use them in Survey Solutions?
b) Does questionnaire responses are parsing in PostgreSQL specific tables and columns?
Thanks in advance for response!

What will that function do?

Severals things require user defined functions, by example:
a) Warn enumerators about tablet battery level;
b) Output questionnaires as HTML, word like customized printable report;
c) Parse checkbox responses;
d) Manage others responses;
etc…etc…
Usually, for each new questionnaire development, i designed lots of.
Best regards,

Very interesting, thanks for sharing.
Would you please clarify how you can do, for example, a), in CSPro? Does CSPro has such functionality? We would be very interested to know as this will inform our own development plans.
Thanks much,

There’re links about Cspro:
http://www.csprousers.org/help/CSPro/user_defined_functions.html
http://www.csprousers.org/help/CSPro/function_statement.html
http://www.csprousers.org/help/CSPro/additional_function_examples.html

I have designed or i’m using a lot of theses functions and i would like to do the same thing for Survey Solutions using C#.
Another:
b) Does questionnaire responses are parsing in PostgreSQL specific tables and columns?

Thanks a lot for your support!

Hi Misha,
Cspro have powerful paradata log recording severals informations about devices. So i designed an user defined function to perform a)
For a)

function NiveauBatterie()//Changement pour un questionnaire:session_instance=case_instance.
numeric ChargeBatterie;
string SqlChargeBatterie =“SELECT battery_level FROM device_state_event ORDER BY id DESC LIMIT 1”;
//string logFileName=concat(strip(dataFolder),strip(usern),".cslog"));
ChargeBatterie=sqlquery(paradata,SqlChargeBatterie);
if ChargeBatterie>15 or ChargeBatterie=default then
else
errmsg (257, ChargeBatterie);
errmsg (258);
savepartial();
stop(1);
endif;
end;


Language=FR
257 Le niveau de la batterie %d pourcent, est en deca de la charge permise pour l’utilisation. Vous etes oblige d’arreter la conversation pour recharger/changer la batterie de votre appareil.
258 L’application va s’auto-enregistrer et se fermer pour faciliter la recharge/changement de batterie pour l’appareil!

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

In Survey Solutions the questionnaire designer may utilize the C# expressions to specify:

  1. validation conditions;
  2. enabling conditions;
  3. filtering conditions;
  4. variable calculation expressions.

In all of the above cases Survey Solutions expects an expression and not a program (or procedure, or function).

So you can’t access the battery level from inside the questionnaire logic as it will potentially permit to create questionnaires which are valid when the battery level is above 15% and erroneous otherwise.
Last battery status of every interviewer is reported to supervisor after synchronization. Most tablets issue a warning of low battery automatically. If yours are not doing so, there is plenty of already developed tools for this task:

Similarly you won’t be able to write/delete files, send something over the net, or do other dangerous operations.

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Once you download the data from Survey Solutions you can process it just like any other dataset including production of reports. This step is next after Survey Solutions.

ccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
I don’t understand what is meant in C) here. Parsing is a process explained here:


I am not sure how this can be applied to a checkbox with values Y/N.

ddddddddddddddddddddddddddddddddddddddddddddddddddd
Similarly I don’t understand D).

For your other question regarding PostGRE SQL see #27 here:
https://support.mysurvey.solutions/getting-started/faq-for-it-personnel/

Interesting discussion. Indeed, as Sergiy has indicated Survey Solutions does not allow creation of custom functions. This is our conscious decision. Survey Solutions is based on three pillars: data capturing, survey management and data management. We provide our users with out of the box functionality to cover these main three features. The data quality and reliability of our system is our top priority.

We do not know how to ensure the reliable operation and security of our system with user written functions. We have no control over such functions and we cannot rule out a possibility of some user mistakes (i.e., the infinite loops) that would result in data losses. This is why we decided not to implement user-written functions.

If you are interested, let’s open another topic where we can compare CSPro and Survey Solutions and discuss what are advantages and disadvantages of each system.

Dear Misha and Sergiy,
Please see this post concerning a non exhaustive list of functionalities and features that users can find in Survey Solutions, not in Cspro:
http://csprousers.org/forum/viewtopic.php?f=6&t=2735
Since this post, Cspro support Regular Expression;

My topic wasn’t about this: Comparison between… But, as a very new Survey Solutions User, i’m trying to see if i can port some logic from Cspro to Survey Solutions.

As you present it, by example here, (https://slideplayer.fr/slide/12869970/) , Cspro is highly flexible, very expert centered Sofware Devlopment Kit for application development, among others:
a) Have a visible compiler and IDE;
b) Have a data collection/processing oriented language;
c) Support multiple languages for application development and data management ( Cspro ( a very rich and powerful C derivated language), SQL, PHP, HTML-CSS-Javascript);
d) Support RDBMS such as MariaDB/MySQL, MS SQL Server for data parsing (in relational multiple tables and columns) via Cspro2SQL or CsWeb;
e) Support ability for a user to define, write, use his own function,
f) Support source code logic reuse (include basic logic or group of function etc) in new application;
g) Support built once/deploy manies;
h) Support Standalone Windows OS application when using NSIS as installer;
i) Have an open source parts: Csweb server, Cspro2SQL, CsproDashboard;
j) Lots of open source functions, applications (Cspro come from 30 years of Development…);
etc.etc.

Survey Solution doesn’t follow the same evolution as you define it as an hybrid system. It’s very difficult to compare elements that have different way and objectives… By example, among other, your Websurvey tools interest me greatly.

Best regards,

1 Like

htuser, the answer to all of the questions you’ve asked so far imho is “no, not possible”. Perhaps you could study the program a bit more before trying to improve it.

Survey Solutions follows a different model than CSPro. In basic terms, in CSPro you have to develop an application and have the freedom (and responsibility) to specify its behavior. In Survey Solutions the application is already developed and all users utilize the same application, which is not user editable. Instead you edit a document, which will be processed by that application, to reflect the survey you conduct. Hence items like

Support source code logic reuse (include basic logic or group of function etc) in new application;

are not applicable by design. (you can of course reuse=copy+paste the sections or code that you’ve written from other questionnaires, but it is different).

With that I suggest that you formulate your business need questions, such as “In the LFS Zimbabwe 2023 we need to know (for such and such analysis, explain) what was the battery charge (in hours and minutes of estimated remaining time, in % of the full charge of the tablet, with all tablets and batteries being different) when each question was answered by the interviewer (and what if it was plugged, and what if it was over the web, etc etc). This information is needed after the survey is completed and not required during the data collection.” and I can help converge to

  • it is possible,
  • it is not possible, or
  • maybe possible but I don’t know how.

About Battery, during fieldwork, often enumerators/surveyors continue to use tablets/smartphones devices with lower than 15% charge…and until battery depletion, in spit of Android messages… This results in battery degradation and long charging times. We’re using lot of Samsung Galaxy Note with stylus… In theses models, battery are not easily user replaceable… (as, majority tablet models…)

It’s why we design functions inside questionnaire logic for automatic battery charge monitoring. And it’s very very useful. Since, device battery last more.

Sorry for this question, since it’s more convenient for Questionnaire developer to implement their own function and share it on the forum rather than asking you all the times…
I would like that you revise, a little, your model, for this flexibility… And, encourage imaginations!

See e.g. here:


just in case you need to replace the batteries in devices which have died.

Whatever restriction you implement will affect not the tablet, but the functioning of the software. So rather than continuing the interview when the power drops below 15%, the data entry application will stop and the interviewers will watch youtube until the power drops to 0% justifying it as “application doesn’t work at the moment”. This would be especially unfortunate if you are, say, 1 question away from completion of the interview.

The bigger problem, I think, is that you are writing that the interviewers are not following the instructions they are given. With this, how can you be certain they are even conducting the interviews?

Our biggest restricting factor (as software developers) is not lack of imagination, as you may be implying in your last statement.

Very, very useful” is best expressed in some metrics. For example:

  • saved 20USD for a survey costing 50,000USD or
  • extended the useful life of tablets by 37 days added to their 4 years of expected service life, etc.

Thanks much for your comments and for pointing out the features of Survey Solutions on CSPro board. We are also happy you are looking into our product.

To summarize our ideology:

We think there is a trade off between the flexibility and reliability. Compared to CSPro, Survey Solutions puts more weight onto reliability of the system. Yes, in CSPro (as well as with Blase and ODK) you can develop a custom systems. In Survey Solutions we deliver the system for you. In our view, the advantage of our model is that, while less flexible, Survey Solutions is tested by now in 143 countries and in more than 2,000 surveys. Every new survey is another test for our system and another opportunity for improvement.

Yes, you can build your custom system. But, regardless how talented and skilled you are, you do not have such extensive testing ground. Almost by definition, the custom system would be less reliable and have higher risk of data losses compared to the ready-made system.

But again, we are very happy to continue this discussion that is informative for us. And your feedback as a long time CSPro use is invaluable to us.

Our biggest restricting factor (as software developers) is not lack of imagination, as you may be implying in your last statement.

Sorry Segiy, i never wrote you don’t have or lack imagination. But, you must encourage imagination for questionnaire developer using your system.
As you know, now, Census/Survey data collection belong of data engineer or data science. Data processing has never been easy. I’m collecting and processing Census/Survey data in developing countries since 2001. And i can’t imagine processing data or having an intelligent data collection application without strong programming. However, i’m not an advanced developer, but Agro-economics engineer…

It’s why professional users around the world have preference of using R, Python,SQL (for data processing), Cspro, ODK 2 (ODK1 is very limited…) : for the implementation of data collection application. If you take a look on Data Science training from several’s universities, you’ll easily understand me…
BLAISE, ODK2, CSPro understand very well that each questionnaire has his own logic and require specific development. So, we can’t have or it’s difficult to have a ready to use universal application… for all questionnaire…
Best Regards,

Thank you Misha since you understand me well. Compare to Cspro or Blaise, Survey Solution is very young. But for the future, i would like that you difference systems and questionnaire applications. So, i think that ODK2, Blaise, CSPro doing this difference so much than you. You can always design a reliable system, but able to support flexible questionnaire applications.
Each questionnaire is an application. And it’s very difficult either impossible to have intelligent data collection application without a great flexibility. Application developer must be able to design and implement his own ideas for improving questionnaire application.
Before using Cspro and a little ODK2 (never ODK1), i was using SPSS Data Entry. But his early versions was not so powerful,(not support roster, and not have a specific data collection/processing programming language…) . Since 2004, i’m using mainly Cspro with relational database: MariaDB/MySQL.
The advantage of this way is, i can use Cspro compatible language (SQL, Cspro, HTML/CSS, Javascript), for designing intelligent and powerful data collection application and Cspro language, SQL, R, Python, SPSS etc… for data processing, tabulation, indices calculation and presentation. It’s a very convenient way since data are clearly stored in relational database (multiple tables and columns).
However, Cspro system lack of multiples functionalities and features… that we can find from you…

Best Regards,