Setting Up Your Survey

In this activity, you will begin creating your survey in Snap! by adding your questions.

    What is "Dos"?

    The word "dos" means "two" in Spanish.

  1. Open this Data Dos project, and save it to your account. It includes the following script at the top:
    if (survey (my survey) is not set up?) {
	set (my survey) to (make survey with questions ())
}

A variable is like a box that can store a value, such as a word, a number, or a list.

In Snap!, a table is a list of lists (a list with lists inside it).

This script:

How does survey () is not set up? work?

survey () is not set up? {
report ((not (is (survey) a ('list')?)) or (is (survey) empty?))
}
The survey () is not set up? block takes a list as input and reports true if either of the following are true:

How does make survey with questions () work?

make survey with questions (questions) {
report (list (questions))
}
The make survey with questions block takes a set of questions as input and reports a list containing one item: the list of questions. So, it sets up a table for the survey data as a list with one row containing the list of questions.

Like the join () () and list () blocks, you can add an input slot to make survey with questions () by clicking the right-facing triangle at the end (▸).

  1. Add your survey questions to the make survey with questions block, and run the script to set up your survey.
  2. If you want to reset your survey at any point, use the reset survey 'list input slot'. How does reset survey work?

    reset survey (survey) {
	if (ask ('Are you sure?') = 'yes'){
		delete ('all') of (survey)
	} else {
		say ('Survey not changed.') for (2) secs
	}
}

    The reset survey block takes a survey as input. If the response to "Are you sure" is "yes," then everything in the survey is deleted. Otherwise (that is, if there is any other response to the question), the sprite says "Survey not changed."

    You'll need to drag the my survey variable out of the palette on the left and into the empty input slot.

  3. Now Is a Good Time to Save

A watcher is a window that lets you see what value is stored in a variable.

On the Snap! stage, you will see your questions appear as the first row of a table in a watcher for the my survey variable. As you add responses to your survey, they will appear as additional rows in the table.
'my survey' watcher: a table with one row and two columns. Row 1 column 1 has the text: 'How many years have you been playing music?' and row 1 column 2 has the text: 'How many hours do you listen to music each day?'

You can expand the "watcher" by clicking and dragging its lower right corner.
my survey watcher with mouse pointer over expansion drag area in lower right corner

You can expand a column by clicking and dragging column headers at the top (the letter will turn into a number that you can drag it to the right).
my survey watcher with mouse pointer exactly between two column headers 'A' and 'B' indicating column expansion drag area

In this activity, you set up a survey to use for data collection.