Custom survey scores allow you to restructure survey responses in order to generate your own scoring mechanism within results. Computations for custom scores are written using Groovy DSL scripts. (See below for example syntax.)
Let’s create custom scoring for the following scenario. Assign a behind-the-scene score to the following two questions. Then generate a total “Staff Superstar” score based on the average of those individual scores. Once you have the scores, you can rank your top locations for each.
If you are adding scores to a live survey, you cannot edit the scripts after exiting out of the survey designer.
To create custom scores:
- From the Surveys > All Surveys tab, click Edit next to the survey you want to apply scores to.
- From the Survey Designer, click the Scores tab.
- Click Add a Score.
A default script appears in the scripting box:
return sq19
- Enter a Score Label. In our example, the first score will be for the Empathy question.
- At the top of the script, expand the Variables available for scripting are link.
All of the available variables and values within the survey are listed for you to reference in your script. Since our Empathy question is the first question in the survey, we’ll start with referencing sq19 (variable) and all of its possible values (o20, o21, o22, o23, o24).
- Modify the script to the following, where ‘a’ is the variable assigned to the Empathy score:
if (sq19.contains('o20')) a=100
else if (sq19.contains('o21')) a=75
else if (sq19.contains('o22')) a=50
else if (sq19.contains('o23')) a=25
else if (sq19.contains('o24')) a=0
else a = null
if (a!=null)return Math.round(a/20 * 10)/10
else return null - Click Test.
The final score can be a custom scale but defaults to 0-5. The example uses a 0-100 point score for purposes of showing syntax for calculation. This is useful if the questions have 3, 4, or 5 options to choose from, and you need to convert it to common scale.
Within the Test Computed Question window, randomly selected survey answers/values are generated for you. If there are no errors in the script, the test results should return a score based on the random value chosen. Click Test Again to generate new random values and ensure the score updates accordingly.
- Click Done to return to the Script page.
- Click Add a Score.
- Repeat the steps above to create another score for Communication using the following script, where ‘b’ is the variable assigned to the Communication score:
if (sq26.contains('o27')) b=100
else if (sq26.contains('o28')) b=75
else if (sq26.contains('o29')) b=50
else if (sq26.contains('o30')) b=25
else if (sq26.contains('o31')) b=0
else b = null
if (b!=null)return Math.round(b/20 * 10)/10
else return null - Click Add a Score.
- Repeat the steps above to create another score for Staff Superstar, which averages the Empathy and Communication scores:
if (sq19.contains('o20')) a=100
else if (sq19.contains('o21')) a=75
else if (sq19.contains('o22')) a=50
else if (sq19.contains('o23')) a=25
else if (sq19.contains('o24')) a=0
else a = null
if (sq26.contains('o27')) b=100
else if (sq26.contains('o28')) b=75
else if (sq26.contains('o29')) b=50
else if (sq26.contains('o30')) b=25
else if (sq26.contains('o31')) b=0
else b = null
return ((Math.round((a+b)/20 * 10)/10)/2 - Click Save.
The next time someone completes the survey, score information will be included in the results.
- Return to the Surveys > All Surveys tab, and click Results under the survey you just modified.
- Click the Scores tab.
Locations are ranked according to the scores: