Feature update – *searchable answers, store data in a custom column of the CSV file

Here’s what’s new:

Searchable answers


Often we want to ask users a question with a large set of predefined answers (e.g. the country where they are in). A multiple-choice question will do the job but will be awkward to use because finding the desired answer may require a lot of scrolling.

In such cases, *searchable questions are a more user-friendly solution. Here, you still have a list of valid answers, but the user initially sees a box where they can start typing their answer. As they do, a drop-down list appears with matches for what the user is entering.



This is the syntax you would use:

*question: Please, select the country where you were born:
	*searchable
	Andorra
	Angola
	Antigua and Barbuda
	Argentina
	Armenia
	...
You will find some programs in the program library that use this functionality:
  • country of birth (code, preview)
  • US state of birth (code, preview): This program asks in what state or territory of the US the user was born. If they were not born in the US, then the program asks for their country of birth, but you can deactivate this follow-up question if you wish.
  • country question (code, preview): By default, this program asks what country the user is in, but you can set the variable `in_countryQuestion` to whatever question you need to ask that requires a country for an answer. For example, “What country has the best cuisine in the world?”
  • US state question (code, preview): Use this program to ask in what state or territory the user is. There is a follow-up question if the user says they are not in the US to ask the country they are in, which can optionally be deactivated. Like in the country question, here you can also change the text of the question.

Storing data in a custom column of the CSV file that stores all user responses

Any variable in your program will show as a column in the CSV file when you download the generated data. The name of the column will be the variable name. But sometimes it’s useful to store data in a column whose name is determined while the program is running. The new `data::store` feature lets you do exactly this by calling:
`>> data::store(columnName, value)`

Here is how you would use it:

>> columnToPutData = "my new column"
>> myValue = 24

>> data::store(columnToPutData, myValue)


As an example, below is the code of a program where you ask users to enter the last three movies they watched and save it into a variable called movies:

*question: Please, type in the last three movies you watched:
	*save: movies
	*multiple

Then you ask the users to rate each movie that they entered:
*for: movie in movies
	*question: How many stars would you give the movie {movie}?
		*answers: [5,4,3,2,1]
		*save: answer

When you download the CSV file, you will have a column with the name “How many stars would you give the movie {movie}?” and for each run, you will have all the ratings that the user provided separated by a pipe(|). The variable `answer` will also be in the CSV file, and it will only have the last rating the user provided (since its value gets overwritten in every iteration).

Ideally, you should have a separate column for each movie, with its corresponding rating if a particular user selected that movie. You can accomplish this using >>data::store(columnName, value):
*for: movie in movies
	*question: How many stars would you give the movie {movie}?
		*answers: [5,4,3,2,1]
		*save: answer
	>>data::store(movie, answer)

This way, if the value of movies is [“Titanic”, “Easy Rider”, “Dune”], there will be three columns on the CSV file with the names “Titanic”, “Easy Rider” and “Dune”, with the ratings provided by the users who watched either of those movies.