From 48af9ac4779b2d60889b0159f47442b5d6d9c8ce 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. --- devfiles/videos/chapter/chapter-number.json | 8 -------- devfiles/videos/introduction/intro-1.json | 8 ++++++++ .../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 +++++++------ 7 files changed, 39 insertions(+), 21 deletions(-) delete mode 100644 devfiles/videos/chapter/chapter-number.json create mode 100644 devfiles/videos/introduction/intro-1.json diff --git a/devfiles/videos/chapter/chapter-number.json b/devfiles/videos/chapter/chapter-number.json deleted file mode 100644 index 4b0a626..0000000 --- a/devfiles/videos/chapter/chapter-number.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "chapter-number", - "number": "Number", - "title": "Title", - "length": Length (seconds), - "pdf": "http://foursquaregrow.s3-website-us-east-1.amazonaws.com/PDF", - "urls": [{"src":"http://foursquaregrow.s3-website-us-east-1.amazonaws.com/H.264%20File", "type":"video/mp4"}] -} \ No newline at end of file diff --git a/devfiles/videos/introduction/intro-1.json b/devfiles/videos/introduction/intro-1.json new file mode 100644 index 0000000..4c1ba09 --- /dev/null +++ b/devfiles/videos/introduction/intro-1.json @@ -0,0 +1,8 @@ +{ + "id": "intro-1", + "number": "1", + "title": "Introduction", + "length": 140, + "pdf": "http://foursquaregrow.s3-website-us-east-1.amazonaws.com/Grow%20-%20Introduction.pdf", + "urls": [{"src":"http://foursquaregrow.s3-website-us-east-1.amazonaws.com/Grow%20-%20Introduction.mov", "type":"video/mp4"}] +} 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 671e45e..2f981ae 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 af49bc0..b27d86e 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>