diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2013-09-10 00:06:54 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2013-09-10 00:06:54 -0700 |
commit | 64c13e3235e32344a0c7c5febbefe802e9102ace (patch) | |
tree | d54ba5593c63b806906533b57345c39a8c344e5c /src/com/p4square/grow/frontend/SurveyPageResource.java | |
parent | 46c3639530d200b70f63994d4016fae37dc2e994 (diff) |
Adding redirect page /account.
/account redirects to either the assessment or the training page, as
appropriate.
This change adds the /accounts/UID backend resource, which simply stores
an arbitrary json document for now.
Diffstat (limited to 'src/com/p4square/grow/frontend/SurveyPageResource.java')
-rw-r--r-- | src/com/p4square/grow/frontend/SurveyPageResource.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/com/p4square/grow/frontend/SurveyPageResource.java b/src/com/p4square/grow/frontend/SurveyPageResource.java index b6c53f5..4d87027 100644 --- a/src/com/p4square/grow/frontend/SurveyPageResource.java +++ b/src/com/p4square/grow/frontend/SurveyPageResource.java @@ -195,6 +195,24 @@ public class SurveyPageResource extends FreeMarkerPageResource { } } + private Map<?, ?> getAccount(String id) { + try { + Map<?, ?> account = null; + + JsonResponse response = backendGet("/accounts/" + id); + if (!response.getStatus().isSuccess()) { + return null; + } + account = response.getMap(); + + return account; + + } catch (ClientException e) { + LOG.warn("Error fetching account.", e); + return null; + } + } + private Map<?, ?> getQuestion(String id) { try { Map<?, ?> questionData = null; @@ -217,6 +235,14 @@ public class SurveyPageResource extends FreeMarkerPageResource { String nextQuestionId = (String) questionData.get("nextQuestion"); if (nextQuestionId == null) { + // Just finished the last question. Update the user's account + Map account = getAccount(mUserId); + if (account == null) { + account = new HashMap(); + } + account.put("landing", "training"); + backendPut("/accounts/" + mUserId, account); + String nextPage = mConfig.getString("dynamicRoot", ""); nextPage += "/account/assessment/results"; getResponse().redirectSeeOther(nextPage); |