A lengthy checkbox variable with several categories

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

A lengthy checkbox variable with several categories

Post by AriSilva »

I´m trying to use a multiple response variable with a checkbox approach.
I´ve used it several times and I know it works, for a small number of cases.
In this present case the variable needs to handle 300 alternatives, so, I designed a string field with length 900, since each category (the value in the valueset) would occupy 3 bytes.
When I load it with up to 36 categories it works fine. If I load it with 37 up to 45 categories it also works, although it shows the checkbox with a very wide size. And more than 45 categories it does not work at all.
Is there any limitation for the number of values in the valueset?
Is it limited by the screen vertical size? (I´m working in Windows)
Best
Ari
Best
Ari
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: A lengthy checkbox variable with several categories

Post by htuser »

Hi Ari,
Never i use so long checkbox, so i don't understand the issue. If you can post the small part with this issue, we could see if it's possible to help you.
In the meantime, i think the next version would give us more freedom and flexibility since it allow to interact with Javascript. So, you'll be able to open a HTML page with your checkbox (https://developer.mozilla.org/fr/docs/W ... t/checkbox) in the Webview. I think HTML5/CSS3/Javascript are more powerful to manage them than CSPro. It's why i'm advocating for :

1.- having a way to customize Webview window in CSPro logic or settings so they can be displayed as required;
2.- Having a convenient way to transfer data collected trough HTML5 form etc in a Webview to CSPro logic/ item.

If we have both, i think that manies CSProusers issues would be easily solved with more JavaScript Interface features, among other:
a) browse to attach a file (file dialog);
b) Read text using camera (OCR);
c) Having greater question type. For example having multiple questions and roster data in matrix question type (https://surveyjs.io/Examples/Library?id ... ype-matrix) on Android.
e) etc.
PS: I suggest you to test your checkbox on https://surveyjs.io/Examples/Library?id ... content-js and run it to see if all are correct! The actual CSPro version can display checkbox in HTML Webview page, but transfer results from Webview to CSPro related item is tricky...

Best,
G.VOLNY, a CSProuser from Haiti, since 2004
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: A lengthy checkbox variable with several categories

Post by htuser »

If you want to parse your CSPro dictionary to HTML checkbox, please use this:https://github.com/parstat/cspro-cawi/
Here's an example from a long checkbox dictionary using javascript libraries developed by the Parstat Project.
cspro-cawi-js.zip
HTML Checkbox using CSPro dictionary
(5.5 KiB) Downloaded 148 times
G.VOLNY, a CSProuser from Haiti, since 2004
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: A lengthy checkbox variable with several categories

Post by htuser »

Finally, your solution for 300 options is not only checkbox, but with search:
http://alechko.github.io/jquery-search- ... tions.html
Best
G.VOLNY, a CSProuser from Haiti, since 2004
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: A lengthy checkbox variable with several categories

Post by AriSilva »

Thank you for your very prompt answer.
Even if the javascript/html combination might solve my problem, which I´m not sure it will, my programmers are not familiar with html and javascript, so, I would rather prefer staying in the cspro´s language realm.
This proposed lengthy checkbox is to be used by a managerial program to attach preferred counties (municipios) for each interviewer to work on them. The application is not finished, it just shows the checkbox for the manager to nark all the counties that each interviewer, one by one, will connect his identification (CPF, in our case, it is like the SSN).
If you need to have a look at it, I´m attaching an example of the problem.
1. Execute \projeto\20_Programas\30_Alocacao_Teste\PB_EDUCA_30_Alocacao.pff
2. As it is, the program will execute well because I set a break at line 133 in the .apc (if ind = 37 then break; endif;)
3. That is, the checkbox is loaded as expected.
4. If you change 37 to 40, for example, the checkbox is still loaded, but it is shown very wide.
5. And if you change the 37 to 50, it stops working.
Best
Attachments
alocacao.zip
(1.84 MiB) Downloaded 156 times
Best
Ari
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: A lengthy checkbox variable with several categories

Post by htuser »

Hi Ari,
I' revise your function loadValuesetEscolherMunicipios() and i'm unable to unsdertand why. A smallest sample application with more comments in logic, in english would allow us to understand better the issue.

Best,
G.VOLNY, a CSProuser from Haiti, since 2004
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: A lengthy checkbox variable with several categories

Post by sherrell »

Hi Ari,

How many interviewers will you have, and how many assignments will each get?

Can each of your 300 places be assigned to one, or more than one interviewer?

Are you trying to make all these assignments prior to fieldwork?

If you want to prioritize assignments by interviewer, I would suggest having a multiply-occurring item for the max # of localities you expect to assign to a single interviewer. The full list of localities would be displayed in the first occurrence. But for occ #2 onwards, each possible selection would be reduced by the previous selections. Do this by dynamically creating the value set for each occurrence. There have been a few posts about that recently, here's one thread: https://www.csprousers.org/forum/viewto ... 06&p=14082

However, if there should be a 1-to-1 correspondence between locality and interviewer, then it sounds like you should further restrict this by having a lookup file under the hood. Only present localities for assignments that have not been previously assigned to other interviewers.

Alternatively you could prioritize assignments by locality, assuming there is that 1-to-1 correspondence between locality and interviewer. Have your 300-row roster which lists all localities. The manager can just scroll within the roster, choosing interviewers from a dropdown list of names, assigning them to localities that have not yet been assigned. I like this method, as it's much easier to implement! And is just as user friendly as the strategy you're trying to employ.

Good luck,
Sherrell
AriSilva
Posts: 591
Joined: July 22nd, 2016, 3:55 pm

Re: A lengthy checkbox variable with several categories

Post by AriSilva »

Thank you both htuser and Sherrell.
To htuser:
The loadValuesetEscolherMunicipios function loads the valueset that will contain the list of municipios to be checked. Before adding to the list, it checks if the municipio is already there, because my input (where I read the munic key) has many duplicates.
Line 125 is where I insert the new municipio into the valueset.
Line 133 is a debugging command to stop the loading if it is greater than a certain limit. Commenting out this line it would load all the municipios into the valueset, but this is precisely the problem.
Using the 37 limit it works well.
By changing the limit 37 to a greater value, 40 for exmple, it still works, but the box is very wide, and if you change the 37 to 50, it stops working.
I hope I explained it in order for you to try the program by yourself.

To Sherrel:
I´m sorry I did not explain the application thoroughly, I wrote only about the part that was not working.
The survey we are designing is related to the COVID-19 in schools, and we will have 3 questionnaires, one for the school itself, one for the teachers and the third one for the students.
We should have about 800 schools in this survey (in fact, the schools are subdivided into levels of teaching, so we should have around 1200 school-level cases, since one particular school can have more than one teaching level).
This survey will be applied into one of our northeast states, which has around 280 counties (municipios, in our case).
I do not have yet the full number of interviewers we will use, it should be around 60, and they will work in 5 timed phases, each phase to collect data of a specific teaching level.
The program I´ve sent you will be used to plan the interviewer´s workload. and its final goal is to associate interviewers to schools, in a 1-to-1 relationship.
It will be used before each teaching level phase, by the survey field coordinator.
The geographical hierarchy is state (only one state), counties, schools, and then teaching level.
One school-level will be covered by a single interviewer, but an interviewer will be assigned to many school-levels.
In order to facilitate the assignments, the idea was to plan ahead , determining which would be the preferred areas (counties) that each interviewer would work with. That is, each interviewer would be assigned a list of counties where s/he would work, and to build that list we would use a checkbox containing all the counties. For each user the field coordinator (the user in this case) would check all the preferred counties that this specific interviewer would work. This would be done just once, or when new interviewers are brought into the game.
Then, after that, in order to attach the school-levels to each interviewer, the program would show a radio button field containing only the school-levels belonging to the preferred counties of that particular interviewer, for the user to choose from.
By not having this list of preferred counties, we will be forced to show a radio button with a list of all the school-levels, instead of showing just the school-level ones belonging to the preferred counties.
Best
Ari
Best
Ari
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: A lengthy checkbox variable with several categories

Post by sherrell »

Hi Ari,

Thanks for heads up on what you're doing. Good luck with the survey!

While CSPro should be able to handle a checkbox of this size, it looks like you've run into a bug. Unfortunately our next release won't be out for a few months, so you'll have to use an alternate strategy. While it may not be as slick, could you make the selection a 2-step process? That is, choose the county first, then choose the schools within it in a second check box? That will hopefully circumvent the bug you've run into.

Thanks much,
Sherrell
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: A lengthy checkbox variable with several categories

Post by Gregory Martin »

Ari,

The checkbox itself is fine, but there's an issue with the sizing of the "extended control." We'll fix the issue for CSPro 7.7, but a workaround for you is to move the field a bit to the right on the form. Basically you need to give it space to bring up the control to the left of the field. This, for example, works:

ari_checkbox.png
ari_checkbox.png (2.66 KiB) Viewed 3107 times
Post Reply