Home > Studio Manual > Chapter 8 – Start/End Scripts

Chapter 8 – Start/End Scripts

Back to Table Of Contents
Back to Chapter 7 – Rules 
    

About Scripts

A script is a set of one or more user written instructions that form a block of instructions for SurveyToGo to process. You can write question start/end scripts and chapter start/end scripts. Common usage for scripts can be a script that initializes certain question texts based on the answers of previous questions. You can write a question-start-script that sets the current question text to include answers from previous questions.

Question Start/End scripts

Questions support start/end scripts. The question-start-script is executed whenever the page containing the question is shown. The question-end-script is executed when the subject leaves the page containing the question.

Chapter Start/End Scripts

Chapters also support start/end scripts. The chapter-start-script is executed when the first question of that chapter is shown. The chapter-end-script is executed when the subject leaves the chapter (before the first question of the next chapter is shown). Chapter start-end scripts are smart enough to handle situations of jumping into the middle of a chapter, and jumping out of a chapter to a different chapter.

Relationship between scripts and rules

Scripts and rules co-exist and collaborate to give you complete control over the flow of the questions and chapter. The diagram below shows the logical relationship between rules and scripts.

Rules are shown in gray while scripts are shown in green.

As you can see, the start-script is executed after the entrance rule has determined the question should be shown. The end-script is executed after the answer has been validated by the validation rule and right before the jump rule takes place.


Writing start/end scripts

To write start/end scripts you simply select the question/chapter and switch to the “Scripts” tab.

The syntax for writing start/end scripts is the same syntax as for writing expressions, survey-init-scripts etc… you can use all the functions available in SurveyToGo.

Go To Chapter 9 – Child Surveys or running surveys from within surveys 
Back to Table Of Contents
Visit us at:  http://www.dooblo.net

Categories: Studio Manual
  1. Ivan
    July 22, 2015 at 9:45 am

    Please tell me how to write a SKIPPING script

  1. December 14, 2009 at 12:38 pm
  2. December 14, 2009 at 12:40 pm
  3. May 23, 2012 at 2:32 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: