Custom Actions: WeightedScore

 


This custom action allows calculating a score based on how a visitor answers a series of questions with numeric answers. Each question can be assigned a specific weight. The result can be the sum or an average.

WeightedScore target.decimalplaces,op,question*weight,question*weight,...

The value entered in each question listed is multiplied by its optional weight. The values are added if "op" is "sum", or averaged if "op" is "average".

The result s rounded to the indicated number of decimal places or to the nearest integer if decimalplaces is not specified. The result is stored in question "target", which is usually defined as a hidden question.

The target question can be saved, used as a piped question, and used in Univariate and Crosstabulation analyses.

Example:

  No      Some Lots
Do you smoke?
Do you drink?
Are you overweight?
     

Hidden Question: combined_risk_score

Custom Action:
WeightedScore combined_risk_score,sum,smoke*.4,drink*.3,overweight*.3

Three questions of type radio are named smoke, drink, and overweight. The three questions have values 1, 2, and 4 corresponding to No, Some, and Lots. Note that the value 4 (rather than 3) indicates the aggravated importance of an excessive risk factor. When calculating a combined health risk score, "smoke" is given a higher weight to account for its specially pernicious toxicity. Note how the weights are decimal numbers, .4 and .3. Because no decimal points are indicated, the combined_risk_score hidden question will store the score rounded to the nearest integer.

Custom Actioon:
WeightedScore combined_risk_score.2,average,smoke*4,drink*3,overweight*2

In this example, each of the questions's values will be multiplied by the appropriate factor, and the result will be averaged. If a question was not answered, it will not be used when calculating the average.

For an additional example, see Branching.

Next: Event Notification