diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2013-08-04 16:09:29 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2013-08-04 16:09:29 -0700 |
commit | 52539d7aaba96b7997a3c5a07e4a1ad234af7d04 (patch) | |
tree | 2686f56bc37656c0824a05e28472f7334ed39028 /src/com/p4square/grow/frontend/SurveyPageResource.java | |
parent | 69e2512750dd75fce43a21226979996c3cd7da1d (diff) |
Committing everything since its long overdue.
Diffstat (limited to 'src/com/p4square/grow/frontend/SurveyPageResource.java')
-rw-r--r-- | src/com/p4square/grow/frontend/SurveyPageResource.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/com/p4square/grow/frontend/SurveyPageResource.java b/src/com/p4square/grow/frontend/SurveyPageResource.java index 280184b..8145c0d 100644 --- a/src/com/p4square/grow/frontend/SurveyPageResource.java +++ b/src/com/p4square/grow/frontend/SurveyPageResource.java @@ -115,6 +115,7 @@ public class SurveyPageResource extends FreeMarkerPageResource { protected Representation post(Representation entity) { final Form form = new Form(entity); final String answerId = form.getFirstValue("answer"); + final String direction = form.getFirstValue("direction"); if (mQuestionId == null || answerId == null || answerId.length() == 0) { // Something is wrong. @@ -154,9 +155,26 @@ public class SurveyPageResource extends FreeMarkerPageResource { // Find the next question or finish the assessment. String nextPage = mConfig.getString("dynamicRoot", ""); { - String nextQuestionId = (String) questionData.get("nextQuestion"); + String nextQuestionId = null; + if ("previous".equals(direction)) { + nextQuestionId = (String) questionData.get("previousQuestion"); + } else { + nextQuestionId = (String) questionData.get("nextQuestion"); + } + if (nextQuestionId == null) { - nextPage += "/account/assessment/results"; + //nextPage += "/account/assessment/results"; + // TODO: Remove this hack: + JsonResponse response = backendGet("/accounts/" + mUserId + "/assessment"); + if (!response.getStatus().isSuccess()) { + nextPage += "/account/assessment/results"; + } else { + final String score = (String) response.getMap().get("result"); + if (score != null) { + nextPage += "/account/training/" + score; + } + } + } else { nextPage += "/account/assessment/question/" + nextQuestionId; } |