# Algorithm of “level of happiness” for a poll/surveys website

I have a surveys website. I want to add a feature "level of happiness/unhappiness".

Database schema is something like this:

``````1) Question

2) Answer options (for some questions single, for some multiple ones allowed)

3) User's answers (question_id <--> answer option id)
``````

Namely, I'd probably need to assign a special constant to each answer option "level of happiness". It could be with "+" or "-"

And then, probably, sum them up for each actual user's answer and .... I'm confused, how would I actually implement this in terms of algorithm?

How about multiple-allowed questions?

Should the constants be just "+1", 0 and "-1"?

How would I introduce the normal/low/high happiness level? Based on what? Just a constant?

Any help would be appreciated.

## 1 Answer

It sounds like you want to have a set of questions and translate the answers into a metric that quantifies level of satisfaction? You can do this by assigning points to each answer and add them up.

Add the total possible -- which is the number of points if the person answered the highest level of satisfaction for each question, and then add up the actual total and use these two numbers to calculate % satisfied.

This is simple and will be limited in usefulness because you really need to also assign a weight to each question or area. If I am a customer and not satisfied with the product selection, that is probably less important than being unsatisfied with the website aesthetics. So you would weight the questions having to do with finding products higher than app cosmetics.

This gets into survey design more than software design. But from a software design perspective, I'd not hard code the questions, values, and weights because there will be tuning and tweaking of these parameters in order to model satisfaction.

• yeah, I think I'll add X of weight to some answer options, X + 1 to others, 0 to others, X - 1 to negative ones and so on. what do you think? – Tony Jul 13 '17 at 8:35