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.
Please sign in to leave a comment.