From af7517c44c967ca29e12df52d2fe13b2a067c5fe Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sun, 15 Sep 2013 16:57:53 -0700 Subject: Adding Introduction Chapter. Introduction chapter is always required and thus after the assessment the user is taken directly to the introduction. After the introduction training continues with whichever section the user assessed in to. --- .../grow/backend/resources/TrainingRecordResource.java | 13 ++++++++++--- src/com/p4square/grow/frontend/ChapterCompletePage.java | 8 ++++++++ src/com/p4square/grow/frontend/TrainingPageResource.java | 8 +++++--- src/templates/templates/assessment-results.ftl | 2 +- src/templates/templates/training.ftl | 13 +++++++------ 5 files changed, 31 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/com/p4square/grow/backend/resources/TrainingRecordResource.java b/src/com/p4square/grow/backend/resources/TrainingRecordResource.java index 8447c16..009d0fe 100644 --- a/src/com/p4square/grow/backend/resources/TrainingRecordResource.java +++ b/src/com/p4square/grow/backend/resources/TrainingRecordResource.java @@ -32,7 +32,7 @@ import com.p4square.grow.backend.db.CassandraDatabase; * @author Jesse Morgan */ public class TrainingRecordResource extends ServerResource { - private static final String[] CHAPTERS = { "seeker", "believer", "disciple", "teacher" }; + private static final String[] CHAPTERS = { "introduction", "seeker", "believer", "disciple", "teacher" }; private static final Logger LOG = Logger.getLogger(TrainingRecordResource.class); private static final ObjectMapper MAPPER = new ObjectMapper(); @@ -211,8 +211,15 @@ public class TrainingRecordResource extends ServerResource { // Get videos for each section and build playlist for (String chapter : CHAPTERS) { - // Chapter required if the floor of the score is <= the chapter's numeric value. - boolean required = score < Score.numericScore(chapter) + 1; + boolean required; + + if ("introduction".equals(chapter)) { + // Introduction chapter is always required + required = true; + } else { + // Chapter required if the floor of the score is <= the chapter's numeric value. + required = score < Score.numericScore(chapter) + 1; + } ColumnList row = mDb.getRow("strings", "/training/" + chapter); if (!row.isEmpty()) { diff --git a/src/com/p4square/grow/frontend/ChapterCompletePage.java b/src/com/p4square/grow/frontend/ChapterCompletePage.java index 5cc4724..efcde38 100644 --- a/src/com/p4square/grow/frontend/ChapterCompletePage.java +++ b/src/com/p4square/grow/frontend/ChapterCompletePage.java @@ -102,6 +102,14 @@ public class ChapterCompletePage extends FreeMarkerPageResource { } } + // Skip the chapter complete message for "Introduction" + if ("introduction".equals(mChapter)) { + String nextPage = mConfig.getString("dynamicRoot", ""); + nextPage += "/account/training/" + nextChapter; + getResponse().redirectSeeOther(nextPage); + return new StringRepresentation("Redirecting to " + nextPage); + } + root.put("stage", mChapter); root.put("nextstage", nextChapter); return new TemplateRepresentation(t, root, MediaType.TEXT_HTML); diff --git a/src/com/p4square/grow/frontend/TrainingPageResource.java b/src/com/p4square/grow/frontend/TrainingPageResource.java index 61dcce0..6a0fc10 100644 --- a/src/com/p4square/grow/frontend/TrainingPageResource.java +++ b/src/com/p4square/grow/frontend/TrainingPageResource.java @@ -96,8 +96,8 @@ public class TrainingPageResource extends FreeMarkerPageResource { } if (mChapter == null) { - // Everything is completed... send them back to seeker. - mChapter = "seeker"; + // Everything is completed... send them back to introduction. + mChapter = "introduction"; } String nextPage = mConfig.getString("dynamicRoot", ""); @@ -185,8 +185,10 @@ public class TrainingPageResource extends FreeMarkerPageResource { return 3; } else if ("believer".equals(chapter)) { return 2; - } else { + } else if ("seeker".equals(chapter)) { return 1; + } else { + return 0; } } } diff --git a/src/templates/templates/assessment-results.ftl b/src/templates/templates/assessment-results.ftl index 2bbe8a5..95ee7af 100644 --- a/src/templates/templates/assessment-results.ftl +++ b/src/templates/templates/assessment-results.ftl @@ -27,7 +27,7 @@ diff --git a/src/templates/templates/training.ftl b/src/templates/templates/training.ftl index a2bf5ea..62379a7 100644 --- a/src/templates/templates/training.ftl +++ b/src/templates/templates/training.ftl @@ -11,17 +11,18 @@
<#switch chapter> - <#case "seeker"><#assign overallProgress = 0><#break> - <#case "believer"><#assign overallProgress = 25><#break> - <#case "disciple"><#assign overallProgress = 50><#break> - <#case "teacher"><#assign overallProgress = 75><#break> + <#case "introduction"><#assign overallProgress = 0><#break> + <#case "seeker"><#assign overallProgress = 20><#break> + <#case "believer"><#assign overallProgress = 40><#break> + <#case "disciple"><#assign overallProgress = 60><#break> + <#case "teacher"><#assign overallProgress = 80><#break>