From b14ec9a9282cb49951b790ce1b48b1a078616926 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sun, 15 Oct 2017 19:00:56 -0700 Subject: Refactor Chapter Ordering Logic The bug impacting the CCB integration was due to the "Introduction" chapter having a higher "score" than every other chapter. It was a mistake to use Score to compared chapter progress, particularly since there are more chapters than scores. This change gathers the chapter ordering logic, which was scattered throughout the code into a new Chapters enum. Playlist and Chapter now use Chapters as a key, instead of loose strings. Same for the ProgressReporter interface. --- src/main/java/com/p4square/f1oauth/F1ProgressReporter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/p4square/f1oauth') diff --git a/src/main/java/com/p4square/f1oauth/F1ProgressReporter.java b/src/main/java/com/p4square/f1oauth/F1ProgressReporter.java index 8382020..1514043 100644 --- a/src/main/java/com/p4square/f1oauth/F1ProgressReporter.java +++ b/src/main/java/com/p4square/f1oauth/F1ProgressReporter.java @@ -1,6 +1,7 @@ package com.p4square.f1oauth; import com.p4square.grow.frontend.ProgressReporter; +import com.p4square.grow.model.Chapters; import org.apache.log4j.Logger; import org.restlet.security.User; @@ -29,8 +30,8 @@ public class F1ProgressReporter implements ProgressReporter { } @Override - public void reportChapterComplete(final User user, final String chapter, final Date date) { - final String attributeName = "Training Complete - " + chapter; + public void reportChapterComplete(final User user, final Chapters chapter, final Date date) { + final String attributeName = "Training Complete - " + chapter.toString().toLowerCase(); final Attribute attribute = new Attribute(attributeName); attribute.setStartDate(date); addAttribute(user, attribute); -- cgit v1.2.3