From 8c3a2478c36a998189f69f69e466c257be450a87 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Mon, 9 Sep 2013 23:31:57 -0700 Subject: Adding the progress bar to the assessment. Also adding a header to the Assessment Results page. --- .../p4square/grow/backend/resources/SurveyResource.java | 3 ++- src/com/p4square/grow/frontend/SurveyPageResource.java | 15 +++++++++++++++ src/templates/templates/assessment-results.ftl | 2 ++ src/templates/templates/survey.ftl | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/com/p4square/grow/backend/resources/SurveyResource.java b/src/com/p4square/grow/backend/resources/SurveyResource.java index 76cbe30..83c4cad 100644 --- a/src/com/p4square/grow/backend/resources/SurveyResource.java +++ b/src/com/p4square/grow/backend/resources/SurveyResource.java @@ -65,7 +65,8 @@ public class SurveyResource extends ServerResource { // Get the first question id from db? Map questionSummary = getQuestionsSummary(); - return new StringRepresentation(String.valueOf((Integer) questionSummary.get("count"))); + return new StringRepresentation("{\"count\":" + + String.valueOf((Integer) questionSummary.get("count")) + "}"); } if (mQuestionId != null) { diff --git a/src/com/p4square/grow/frontend/SurveyPageResource.java b/src/com/p4square/grow/frontend/SurveyPageResource.java index 787314a..1389f11 100644 --- a/src/com/p4square/grow/frontend/SurveyPageResource.java +++ b/src/com/p4square/grow/frontend/SurveyPageResource.java @@ -110,6 +110,21 @@ public class SurveyPageResource extends FreeMarkerPageResource { root.put("question", questionData); root.put("selectedAnswerId", selectedAnswer); + // Get the question count and compute progress + Map countData = getQuestion("count"); + if (countData != null) { + JsonResponse response = backendGet("/accounts/" + mUserId + "/assessment"); + if (response.getStatus().isSuccess()) { + Integer completed = (Integer) response.getMap().get("count"); + Integer total = (Integer) countData.get("count"); + + if (completed != null && total != null && total != 0) { + root.put("percentComplete", String.valueOf((int) (100.0 * completed) / total)); + } + } + } + + return new TemplateRepresentation(mSurveyTemplate, root, MediaType.TEXT_HTML); } catch (Exception e) { diff --git a/src/templates/templates/assessment-results.ftl b/src/templates/templates/assessment-results.ftl index f426a7f..2bbe8a5 100644 --- a/src/templates/templates/assessment-results.ftl +++ b/src/templates/templates/assessment-results.ftl @@ -6,6 +6,8 @@ <@content class="text"> +

Congratulations!

+

Congratulations for completing your GROW assessment!

Based on your responses you have been identified as a ${stage?cap_first}.

diff --git a/src/templates/templates/survey.ftl b/src/templates/templates/survey.ftl index 2885d7b..d770461 100644 --- a/src/templates/templates/survey.ftl +++ b/src/templates/templates/survey.ftl @@ -9,7 +9,7 @@
-
+
-- cgit v1.2.3