|
With Custom Scripting very complex scoring requirements can be fulfilled.
Take for example a Quiz with 5 question. For each correct answer you wish to give 1 point and at the end calculate the total points that is the score.
The Script for the above requirement is as follows:
#set($tot=0)
#if (${Q1} == 3)
#set($tot = $tot + 1)
#end
#if (${Q2} == 3)
#set($tot = $tot + 1)
#end
#if (${Q3} == 2)
#set($tot = $tot + 1)
#end
#if (${Q4} == 1)
#set($tot = $tot + 1)
#end
#if (${Q5} == 2)
#set($tot = $tot + 1)
#end
#set($score = $tot)
$survey.updateCustom5("$tot")
This is how the above script works: We set the score variable as "tot" and set it to 0. In the first if statement we check if the correct answer is chosen. If it is then we increment the score by 1. In the second if statement we check if the answer to the second question was correct and if it is then increment the score. Similarly for the third, fourth and the fith question. At the end the total score is copied to the variable "score". This score is later displayed using the Macro. In the last line we update Custom Variable 5 with the score so it is available in the database along with the responses. You can use any of the Custom Variable from 1 to 5 that you are not using.
Following are the steps for setting this up:
- Setup the basic survey with all the questions
- Add the Custom Scripting/Scoring logic question after Q5 in the Survey
- Setup the above Script in the Logic Question
- Make sure there is a page break on Q5
To display the Score to the respondents along with the average score you need to enable Macro Processing.
Go to Integration >> Macros / Data Post
Screenshot
Set up the script for displaying the Score and save the Macro.
License Restrictions
This feature/tool [Custom Scoring Logic and Dynamic Scripting] is not available as part of any of our standard self-service licenses. It is part of our Enterprise Service License. Please contact your Account Manager for pricing and options for purchasing the Enterprise Service License.
|