summaryrefslogtreecommitdiff
path: root/src/com/p4square
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2014-02-08 15:49:03 -0800
committerJesse Morgan <jesse@jesterpm.net>2014-02-08 15:49:03 -0800
commit8f1a754e8e8f316f1b82f68901e1a404daf1915f (patch)
tree719eba97df39c0637f474e7bba911344c990e94d /src/com/p4square
parent21f317af89b1dde997874a60d3958970205b956d (diff)
Changing the scoring process for slider questions.
Previously sliders were scored as a value between 1 and 4 based on the percentage across the screen that the slider was slid. This required you to slide fully to the right to get a 4. Now the slider is divided into n sections, where n is the number of answers on the slider. With 4 answers the score will be exactly 1, 2, 3, or 4. With more answers you may get a decimals, but the last section of the slider will always result in a 4.
Diffstat (limited to 'src/com/p4square')
-rw-r--r--src/com/p4square/grow/model/SliderScoringEngine.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/com/p4square/grow/model/SliderScoringEngine.java b/src/com/p4square/grow/model/SliderScoringEngine.java
index 76811b3..2961e95 100644
--- a/src/com/p4square/grow/model/SliderScoringEngine.java
+++ b/src/com/p4square/grow/model/SliderScoringEngine.java
@@ -15,12 +15,18 @@ public class SliderScoringEngine extends ScoringEngine {
@Override
public boolean scoreAnswer(Score score, Question question, RecordedAnswer userAnswer) {
- float delta = Float.valueOf(userAnswer.getAnswerId()) * 3 + 1;
+ int numberOfAnswers = question.getAnswers().size();
+ if (numberOfAnswers == 0) {
+ throw new IllegalArgumentException("Question has no answers.");
+ }
- if (delta < 0 || delta > 4) {
+ double answer = Double.valueOf(userAnswer.getAnswerId());
+ if (answer < 0 || answer > 1) {
throw new IllegalArgumentException("Answer out of bounds.");
}
+ double delta = Math.max(1, Math.ceil(answer * numberOfAnswers) / numberOfAnswers * 4);
+
score.sum += delta;
score.count++;