Scoring Engine Syntax Reference

Note: The Custom Logic/Scoring Engine is available as a REFERENCE and in most cases requires programming from our Professional Service Team. SurveyAnalytics technical support cannot answer questions related to custom scripting.

System Input Variables
${responseID} Unique Identifier for each response
${custom1} External Data Interface 1
${custom2} External Data Interface 2
${custom3} External Data Interface 3
${custom4} External Data Interface 4
Dynamic Survey Variables
${<QUESTION_CODE>} This is the response value for the question with the corresponding question code.
${<QUESTION_CODE_piping_text>} If you have Piping_Text enabled (Branching) then the value of the piped text is assigned to this variable.
Computed Variables
${score} Computed Score (Saved along with the results)
$survey.isDuplicateEntry("<QUESTION_CODE>", "test") Assuming <QUESTION_CODE> is a text input question, isDuplicateEntry will return a true if any previous respondent has entered "test"
$survey.extractAnswers("<QUESTION_CODE>", [1,2,3,4]) Displays question extracted from <QUESTION_CODE> as if answer options 1, 2, 3 and 4 were selected.
$survey.branchTo("<QUESTION_CODE>") Branch to a Question based on Logic
$survey.branchTo("<QUESTION_CODE>", "Piping Text") Branch to a Question based on Logic, and Pipe the text into ${piping_text}
$survey.sumValues() Adds all the values for all analytical (Multiple Choice, Matrix Rating etc.) questions.
$survey.sumValues("<QUESTION_CODE>") Adds all the values for the question code.
survey.sumValuesWithPrefix(String prefixCode) Adds all the values for all analytical (Multiple Choice) questions with a question code prefix. For example calling sumValuesWithPrefix("Q") will sum all the questions with question codes that start with a "Q"
survey.questionCountWithPrefix(String prefixCode) Counts the number of questions with that Prefix Code. This is meant to be used with the sumValuesWithPrefix -- This only accounts questions that have been answered and the question code starts with the prefix.
$survey.computeAverage("<QUESTION_CODE>") Computes the average values for the question code.
$survey.chainTo(<survey_id>) Chains to another survey
Conjoint Variable Syntax
$CONJOINT.get(0) Gets the Reference to the First Attribute, Replace 0 with 1 to get the second attribute etc.
$CONJOINT.get(0).getLevelAt(0) Gets the Reference the first Level (within the first Attribute)
$CONJOINT.get(0).getLevelAt(0).getAverageUtility() Gets the value for the Utility Score computed for that user/response - for the first level within the first attribute
$CONJOINT.get(0).getRelativeImportance() Gets the relative importance score for the first attribute
Survey Logic/Branching Syntax
$survey.branchTo("Q10") Branches to question with Question Code = Q10
$survey.chainTo(23451) Branches to SURVEY with ID = 23451
Analysis
$survey.getCustomScore(<QUESTION_CODE>) Gets the "AVERAGE" value of the Custom Score for the question with the specific Code
$survey.getCustomScore(<QUESTION_CODE>, <DATA_SEGMENT_CODE>) Gets the "AVERAGE" value of the Custom Score for the question with the specific Code for a particular data segment
$survey.getResponseCount(<QUESTION_CODE>, <ANSWER_INDEX>, <RESPONSE_STATUS>) Gets the number of respondents who have responded to the question identified with <QUESTION_CODE> with the answer identified with <ANSWER_INDEX>
Charting
$survey.drawCustomChart(<QUESTION_CODE>, <DATA_SEGMENT_CODE>, max) Draw's a Horizontal Bar Graph for the given question, and data segment.
$survey.drawCustomChart(<QUESTION_CODE>, <DATA_SEGMENT_CODE>, max, colorIndex) Draw's a Horizontal Bar Graph for the given question, and data segment. The colorIndex (0-9) specifies the color to use for displaying the chart.
$survey.drawSpotlightChart(<QUESTION_CODE>, <DATA_SEGMENT_CODE>, max, colorIndex) Draw's a Horizontal Bar Graph for the given question with spotlight reporting, and data segment. The colorIndex (0-9) specifies the color to use for displaying the chart.

Checking if an open-ended text is answered or not and then branching based on that:

Let us assume that there is an Open-Ended text question with QuestionCode : Q1.

#if (${Q1_1})
  $survey.branchTo("Q10")
#end
  • ${Q1_1} - Represents the First Open-Ended Text Box in the Question
  • $survey.branchTo("Q10") - Represents the branching directive

Custom1-5 and External Reference Data Population

$survey.updateCustom1("Value")
  • Updates the ${custom1} [Custom Variable 1] variable with the value
$survey.updateExternalReference("Value") 
  • Updates the ${ext_ref} [External Reference] variable with the value

Custom6 and above. Up to 255

$survey.updateHighCustomVariable(6, "Value")
  • Updates the ${custom6} variable with the value

Summing all the values for the Multiple Choice/Ratings Questions

#set ($score = $survey.sumValues())
  • The sumValues() method calculates the sum and assigns to the $score variable.

Chaining to multiple surveys

$survey.chainTo(3342)

In the example above, 3342 is the Survey ID you want to chain to.