2021 update of the form
3 enhancements of our main form are detailed here. All made possible by using existing features of collect and thanks to a more attentive reading of the documentation and some guru help
1 - Facilitate and generalize the use of personal settings per form.
In the previous version of the form, we used user's phone number, stored in Collect to allow form customization. Each value from 0 to 9 represents at least ten parameters (see point 3 of the first message of the topic).
This "hack" is quite functional but limited because we can set only one phone number in the app, and not all the forms in the app use the same parameters...
In combination with user settings (user identity and email address defined at Collect's level), we will use the "last saved values" feature, introduced in Collect v1.21.0, to define user settings in each form
The logical is simple :
Each parameters is set to its lasts saved value. If it is the first use of the form, defaults values are set to true or the "Collect user's settings" one when possible (username and email).
here the "default" column of the user name :
coalesce(${last-saved#user_name},${username})
${username} is a field of type "username".
And here for the "geopint" setting (Do you want to create geopoint within the form ?)
coalesce(${last-saved#utiliser_geopoint},’true’)
User will be able to modify each value and next time he will use the form, this last saved value will be the default.
Those settings will be useful to adapt the form :
- show/hide group of question,
- filter select option (filter column : contains(${user_settings},filter))
Here is the extract of the 2021 version of the form relative to user settings and preferences. The empty columns are droped.
type | name | label | calculation | required | appearance | default |
---|---|---|---|---|---|---|
begin group | settings | Préférences → Géométries | field-list | |||
select_one boolean | utiliser_geopoint | Saisir des points ? | yes | columns | coalesce(${last-saved#utiliser_geopoint},’true’) | |
select_one boolean | utiliser_geotrace | Saisir des lignes ? | yes | columns | coalesce(${last-saved#utiliser_geotrace},’true’) | |
select_one boolean | utiliser_geoshape | Saisir des polygones ? | yes | columns | coalesce(${last-saved#utiliser_geoshape},’true’) | |
end group | ||||||
begin group | settings2 | Préférences → Thématiques | field-list | |||
select_one boolean | animalia | Données de faune ? | yes | columns | coalesce(${last-saved#animalia},’true’) | |
select_one boolean | plantae | Données de flore ? | yes | columns | coalesce(${last-saved#plantae},’true’) | |
select_one boolean | fungi | Données de champignons ? | yes | columns | coalesce(${last-saved#fungi},’true’) | |
select_one boolean | habitat | Données sur les habitats ? | yes | columns | coalesce(${last-saved#habitat},’true’) | |
select_one boolean | pression_menace | Pressions / menaces ? | yes | columns | coalesce(${last-saved#pression_menace},’true’) | |
select_one boolean | observation_generale | Observations générales / jalons ? | yes | columns | coalesce(${last-saved#observation_generale},’true’) | |
calculate | user_settings | concat(if(${utiliser_geopoint} = 'true','point',''),if(${utiliser_geotrace} = 'true','line',''),if(${utiliser_geoshape} = 'true','polygon',''),if(${animalia} = 'true','animalia',''),if(${plantae} = 'true','plantae',''),if(${fungi} = 'true','fungi',''),if(${habitat} = 'true','habitat',''),if(${pression_menace} = 'true','pression_menace',''),if(${observation_generale} = 'true','observation_generale','')) | ||||
end group | ||||||
begin group | protocole_etude | Protocole et Ă©tude | field_list | |||
select_one list_etude | id_etude | Etude | yes | quick search('etudes') | ||
select_one list_protocole | id_protocole | Protocole | yes | quick search('protocoles') | ||
end group |
2 - How to select species in a list by typing first letters of its name or a code
This code consists in concatenate the 3 first letters of the genus with the 3 firsts letters of the species (for example the little bird Pheonicurus ochruros is coded with those 6 letters "pho och")
And as a bonus users wanted the list to show first official names, not synonyms : genus firsts, followed by species and in the end subspecies, alphabetically ordered.
This was finally easy to do, even if I didn't had any idea about how to do it before I read once again the serach() function documentation. It mention that you can search in one or more columns - I ignored or forgot that - and also the possibility to arbitrary order the list with a column named "sortby" in the csv file.
\3. "search(csvName, 'startswith', columnsToSearch, searchText)": This search expression includes all distinct rows that start with the specified text in the specified column(s) (e.g., "search('hhplotdata', 'startswith', 'respondentname', ${nameprefix})"). The third parameter specifies either a single column name to search, or a comma-separated list of column names to search. Rows with matches in any specified column will be included.
There are just two additional notes on usage:
\1. Choices will be ordered, by default, in the order that they appear in your .csv file. If you want to specify a different ordering, include a numeric column in your .csv file named sortby; choices will be ordered numerically, according to the sortby column (if present).
So I just had to create a new column in the csv file for the species code (code_espece_key), and another one "sortby" containing the rank of the species once the list is order by official/taxonomic rank/name
SELECT lb_nom_key, cd_nom_key, lb_cd_nom_key, regne as regne_key, groupe, group1_inpn, code_espece_key, rank() OVER(ORDER BY CASE WHEN rang ='GN' THEN 1 else 2 END, CASE WHEN lb_nom_key ILIKE '%nom valide%' THEN 3 ELSE 4 END, lb_nom_key ) AS sortby
FROM total
WHERE ...
the filter columns looks like this :
quick search('espece_animale', 'startswith', 'code_espece_key,lb_nom_key', ${recherche_espece_animale})
Select a tax with its name
or its code
3 how to facilitate checking or modifying collected data on the field
In other words how to enhance repeat group naming and form navigation.
Thanks to @LN I was able to reproduce what I did achieved in a simple form.
Each place (geo-widget question) is now named using creation time (ex. place at 18:06)
And within each location instances, observation are named using the species or habitat name or pressure/threat type
Things to investigate before the field season :
for species lists : having a "last_saved value like" behavior over preloaded data and search() function, or being able to do the same (with search() function) over external csv files (form datasets, select_one from external / select_one_from_file), more standard compliant way) and then query 2 columns (starts with) and order the result in the proposed list.
Here is the new form and its media files (truncated to few lines).
sicen_2021.zip (68.8 KB)
And the sql code to generate taxonomic csv files from the french reference (https://inpn.mnhn.fr/programme/referentiel-taxonomique-taxref)
vue_espece_animale.txt (4.8 KB)