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
commitc91558898921c2063762c3b346eaa36a259b6391 (patch)
tree31a9c712a3409a3d1b558550f815a4afa680d49e /src/com/p4square
parent8c6d308cc269e568c05b79ead2d06f6b16595386 (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++;