diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2013-12-14 17:13:50 -0800 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2013-12-14 17:13:50 -0800 |
commit | e38de23db148ffb47bd5f076764ebbd5f2a35812 (patch) | |
tree | 39f85d9e84c12535715ba8f3b8e748bfa94503f1 | |
parent | d6cbb1d951012d6a0977ef2eba8774d14212172f (diff) |
Adding Group Leader training videos
-rw-r--r-- | devfiles/videos/leader/leader-1.json | 10 | ||||
-rw-r--r-- | devfiles/videos/leader/leader-2.json | 10 | ||||
-rw-r--r-- | devfiles/videos/leader/leader-3.json | 10 | ||||
-rw-r--r-- | devfiles/videos/leader/leader-4.json | 10 | ||||
-rw-r--r-- | devfiles/videos/leader/leader-5.json | 10 | ||||
-rw-r--r-- | devfiles/videos/leader/leader-6.json | 10 | ||||
-rw-r--r-- | devfiles/videos/playlist.json | 10 | ||||
-rw-r--r-- | src/com/p4square/grow/backend/resources/TrainingRecordResource.java | 2 | ||||
-rw-r--r-- | src/com/p4square/grow/frontend/GroupLeaderTrainingPageResource.java | 26 | ||||
-rw-r--r-- | src/com/p4square/grow/frontend/GrowFrontend.java | 1 | ||||
-rw-r--r-- | src/com/p4square/grow/frontend/TrainingPageResource.java | 64 | ||||
-rw-r--r-- | src/templates/templates/training.ftl | 8 |
12 files changed, 138 insertions, 33 deletions
diff --git a/devfiles/videos/leader/leader-1.json b/devfiles/videos/leader/leader-1.json new file mode 100644 index 0000000..c145db2 --- /dev/null +++ b/devfiles/videos/leader/leader-1.json @@ -0,0 +1,10 @@ +{ + "id": "leader-1", + "number": "1", + "title": "Purpose", + "length": 423, + "image": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%201%20-%20Purpose.png", + "pdf": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%201%20-%20Purpose%20Final.pdf", + "urls": [{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%201%20-%20Purpose-low.mp4", "type":"video/mp4"}, +{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%201%20-%20Purpose.webmhd.webm", "type":"video/webm"}] +}
\ No newline at end of file diff --git a/devfiles/videos/leader/leader-2.json b/devfiles/videos/leader/leader-2.json new file mode 100644 index 0000000..5f57a7c --- /dev/null +++ b/devfiles/videos/leader/leader-2.json @@ -0,0 +1,10 @@ +{ + "id": "leader-2", + "number": "2", + "title": "Organization", + "length": 359, + "image": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%202%20-%20Organization.png", + "pdf": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%202%20-%20Organization.pdf", + "urls": [{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%202%20-%20Organization-low.mp4", "type":"video/mp4"}, +{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%202%20-%20Organization.webmhd.webm", "type":"video/webm"}] +}
\ No newline at end of file diff --git a/devfiles/videos/leader/leader-3.json b/devfiles/videos/leader/leader-3.json new file mode 100644 index 0000000..59ad0fe --- /dev/null +++ b/devfiles/videos/leader/leader-3.json @@ -0,0 +1,10 @@ +{ + "id": "leader-3", + "number": "3", + "title": "Qualifications", + "length": 616, + "image": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%203%20-%20Qualifications.png", + "pdf": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%203%20-%20Qualifications.pdf", + "urls": [{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%203%20-%20Qualifications-low.mp4", "type":"video/mp4"}, +{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%203%20-%20Qualifications.webmhd.webm", "type":"video/webm"}] +}
\ No newline at end of file diff --git a/devfiles/videos/leader/leader-4.json b/devfiles/videos/leader/leader-4.json new file mode 100644 index 0000000..896e9dd --- /dev/null +++ b/devfiles/videos/leader/leader-4.json @@ -0,0 +1,10 @@ +{ + "id": "leader-4", + "number": "4", + "title": "Characteristics", + "length": 287, + "image": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%204%20-%20Characteristics.png", + "pdf": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%204%20-%20Characteristics.pdf", + "urls": [{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%204%20-%20Characteristics-low.mp4", "type":"video/mp4"}, +{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%204%20-%20Characteristics.webmhd.webm", "type":"video/webm"}] +}
\ No newline at end of file diff --git a/devfiles/videos/leader/leader-5.json b/devfiles/videos/leader/leader-5.json new file mode 100644 index 0000000..f9e8a72 --- /dev/null +++ b/devfiles/videos/leader/leader-5.json @@ -0,0 +1,10 @@ +{ + "id": "leader-5", + "number": "5", + "title": "Dos and Don'ts", + "length": 485, + "image": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%205%20-%20Do%27s%20%26%20Don%27ts.png", + "pdf": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%205%20-%20Do%27s%20%26%20Don%27ts.pdf", + "urls": [{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%205%20-%20Do%27s%20%26%20Don%27ts-low.mp4", "type":"video/mp4"}, +{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%205%20-%20Do%27s%20%26%20Don%27ts.webmhd.webm", "type":"video/webm"}] +}
\ No newline at end of file diff --git a/devfiles/videos/leader/leader-6.json b/devfiles/videos/leader/leader-6.json new file mode 100644 index 0000000..8df1988 --- /dev/null +++ b/devfiles/videos/leader/leader-6.json @@ -0,0 +1,10 @@ +{ + "id": "leader-6", + "number": "6", + "title": "Nuts and Bolts", + "length": 450, + "image": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%206%20-%20Nuts%20%26%20Bolts.png", + "pdf": "http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%206%20-%20Nuts%20%26%20Bolts.pdf", + "urls": [{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%206%20-%20Nuts%20%26%20Bolts-low.mp4", "type":"video/mp4"}, +{"src":"http://d12xq7pqelpwt.cloudfront.net/Group%20Leader%20Video%206%20-%20Nuts%20%26%20Bolts.webmhd.webm", "type":"video/webm"}] +}
\ No newline at end of file diff --git a/devfiles/videos/playlist.json b/devfiles/videos/playlist.json index 1d8fc8d..5e44223 100644 --- a/devfiles/videos/playlist.json +++ b/devfiles/videos/playlist.json @@ -42,5 +42,13 @@ "teacher-6":{ "required": true }, "teacher-7":{ "required": true } }, - "lastUpdated": 1383798629000 + "leader":{ + "leader-1":{ "required": true }, + "leader-2":{ "required": true }, + "leader-3":{ "required": true }, + "leader-4":{ "required": true }, + "leader-5":{ "required": true }, + "leader-6":{ "required": true } + }, + "lastUpdated": 1387066523000 } diff --git a/src/com/p4square/grow/backend/resources/TrainingRecordResource.java b/src/com/p4square/grow/backend/resources/TrainingRecordResource.java index e42456e..388f2fa 100644 --- a/src/com/p4square/grow/backend/resources/TrainingRecordResource.java +++ b/src/com/p4square/grow/backend/resources/TrainingRecordResource.java @@ -44,8 +44,6 @@ import com.p4square.grow.model.Score; * @author Jesse Morgan <jesse@jesterpm.net> */ public class TrainingRecordResource extends ServerResource { - 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(); diff --git a/src/com/p4square/grow/frontend/GroupLeaderTrainingPageResource.java b/src/com/p4square/grow/frontend/GroupLeaderTrainingPageResource.java new file mode 100644 index 0000000..3ab140e --- /dev/null +++ b/src/com/p4square/grow/frontend/GroupLeaderTrainingPageResource.java @@ -0,0 +1,26 @@ +/* + * Copyright 2013 Jesse Morgan + */ + +package com.p4square.grow.frontend; + +/** + * Display the Group Leader training videos. + * + * @author Jesse Morgan <jesse@jesterpm.net> + */ +public class GroupLeaderTrainingPageResource extends TrainingPageResource { + private static final String[] CHAPTERS = { "leader" }; + + @Override + public void doInit() { + super.doInit(); + + mChapter = "leader"; + } + + @Override + public String[] getChaptersInOrder() { + return CHAPTERS; + } +} diff --git a/src/com/p4square/grow/frontend/GrowFrontend.java b/src/com/p4square/grow/frontend/GrowFrontend.java index f6db9b8..8f145b1 100644 --- a/src/com/p4square/grow/frontend/GrowFrontend.java +++ b/src/com/p4square/grow/frontend/GrowFrontend.java @@ -107,6 +107,7 @@ public class GrowFrontend extends FMFacade { accountRouter.attach("/assessment", SurveyPageResource.class); accountRouter.attach("/training/{chapter}/completed", ChapterCompletePage.class); accountRouter.attach("/training/{chapter}/videos/{videoId}.json", VideosResource.class); + accountRouter.attach("/training/leader", GroupLeaderTrainingPageResource.class); accountRouter.attach("/training/{chapter}", TrainingPageResource.class); accountRouter.attach("/training", TrainingPageResource.class); diff --git a/src/com/p4square/grow/frontend/TrainingPageResource.java b/src/com/p4square/grow/frontend/TrainingPageResource.java index a8245c2..0706ead 100644 --- a/src/com/p4square/grow/frontend/TrainingPageResource.java +++ b/src/com/p4square/grow/frontend/TrainingPageResource.java @@ -45,7 +45,7 @@ import com.p4square.grow.provider.Provider; * @author Jesse Morgan <jesse@jesterpm.net> */ public class TrainingPageResource extends FreeMarkerPageResource { - private static Logger cLog = Logger.getLogger(TrainingPageResource.class); + private static final Logger LOG = Logger.getLogger(TrainingPageResource.class); private static final String[] CHAPTERS = { "introduction", "seeker", "believer", "disciple", "teacher" }; private static final Comparator<Map<String, Object>> VIDEO_COMPARATOR = new Comparator<Map<String, Object>>() { @@ -72,8 +72,8 @@ public class TrainingPageResource extends FreeMarkerPageResource { private Provider<String, TrainingRecord> mTrainingRecordProvider; // Fields pertaining to this request. - private String mChapter; - private String mUserId; + protected String mChapter; + protected String mUserId; @Override public void doInit() { @@ -83,7 +83,7 @@ public class TrainingPageResource extends FreeMarkerPageResource { mConfig = growFrontend.getConfig(); mTrainingTemplate = growFrontend.getTemplate("templates/training.ftl"); if (mTrainingTemplate == null) { - cLog.fatal("Could not find training template."); + LOG.fatal("Could not find training template."); setStatus(Status.SERVER_ERROR_INTERNAL); } @@ -122,29 +122,40 @@ public class TrainingPageResource extends FreeMarkerPageResource { boolean allowUserToSkip = mConfig.getBoolean("allowUserToSkip", true); String defaultChapter = null; boolean userTriedToSkip = false; + int overallProgress = 0; boolean foundRequired = false; - for (String chapterId : CHAPTERS) { + for (String chapterId : getChaptersInOrder()) { boolean allowed = true; - if (!foundRequired) { - if (!chapters.get(chapterId)) { - // The first incomplete chapter is the highest allowed chapter. - foundRequired = true; - defaultChapter = chapterId; - } + Boolean completed = chapters.get(chapterId); + if (completed != null) { + if (!foundRequired) { + if (!completed) { + // The first incomplete chapter is the highest allowed chapter. + foundRequired = true; + defaultChapter = chapterId; + } + + } else { + allowed = allowUserToSkip; + + if (!allowUserToSkip && chapterId.equals(mChapter)) { + userTriedToSkip = true; + } + } - } else { - allowed = allowUserToSkip; + allowedChapters.put(chapterId, allowed); - if (!allowUserToSkip && chapterId.equals(mChapter)) { - userTriedToSkip = true; + if (completed) { + overallProgress++; } } - - allowedChapters.put(chapterId, allowed); } + // Overall progress is the percentage of chapters complete + overallProgress = (int) ((double) overallProgress / getChaptersInOrder().length * 100); + if (defaultChapter == null) { // Everything is completed... send them back to introduction. defaultChapter = "introduction"; @@ -177,9 +188,9 @@ public class TrainingPageResource extends FreeMarkerPageResource { for (Map<String, Object> video : videos) { boolean completed = false; VideoRecord record = playlist.find((String) video.get("id")); - cLog.info("VideoId: " + video.get("id")); + LOG.info("VideoId: " + video.get("id")); if (record != null) { - cLog.info("VideoRecord: " + record.getComplete()); + LOG.info("VideoRecord: " + record.getComplete()); completed = record.getComplete(); } video.put("completed", completed); @@ -192,21 +203,30 @@ public class TrainingPageResource extends FreeMarkerPageResource { Map root = getRootObject(); root.put("chapter", mChapter); + root.put("chapters", allowedChapters.keySet()); root.put("isChapterAllowed", allowedChapters); root.put("chapterProgress", chapterProgress); + root.put("overallProgress", overallProgress); root.put("videos", videos); root.put("allowUserToSkip", allowUserToSkip); return new TemplateRepresentation(mTrainingTemplate, root, MediaType.TEXT_HTML); } catch (Exception e) { - cLog.fatal("Could not render page: " + e.getMessage(), e); + LOG.fatal("Could not render page: " + e.getMessage(), e); setStatus(Status.SERVER_ERROR_INTERNAL); return ErrorPage.RENDER_ERROR; } } /** + * This method returns a list of chapters in the correct order. + */ + protected String[] getChaptersInOrder() { + return CHAPTERS; + } + + /** * @return The backend endpoint URI */ private String getBackendEndpoint() { @@ -217,12 +237,12 @@ public class TrainingPageResource extends FreeMarkerPageResource { * Helper method to send a GET to the backend. */ private JsonResponse backendGet(final String uri) { - cLog.debug("Sending backend GET " + uri); + LOG.debug("Sending backend GET " + uri); final JsonResponse response = mJsonClient.get(getBackendEndpoint() + uri); final Status status = response.getStatus(); if (!status.isSuccess() && !Status.CLIENT_ERROR_NOT_FOUND.equals(status)) { - cLog.warn("Error making backend request for '" + uri + "'. status = " + response.getStatus().toString()); + LOG.warn("Error making backend request for '" + uri + "'. status = " + response.getStatus().toString()); } return response; diff --git a/src/templates/templates/training.ftl b/src/templates/templates/training.ftl index cf230b6..f40f4ce 100644 --- a/src/templates/templates/training.ftl +++ b/src/templates/templates/training.ftl @@ -10,19 +10,11 @@ </@noticebox> <div id="progressbar"> - <#switch chapter> - <#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> - </#switch> <div class="progress" style="width: ${overallProgress}%"></div> </div> <div id="content"> <nav> - <#assign chapters = ["introduction", "seeker", "believer", "disciple", "teacher"]> <#list chapters as x> <#if isChapterAllowed[x]> <a href="${dynamicRoot}/account/training/${x}" <#if x == chapter>class="current"</#if>>${x?capitalize}</a> |