Added a lesson restart call to allow lesson specific restart functionality

This commit is contained in:
mayhew64 2015-09-18 13:30:32 -04:00
parent 7ce8273376
commit 5365f632e7
3 changed files with 14 additions and 0 deletions

View File

@ -201,6 +201,11 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
protected abstract Category getDefaultCategory(); protected abstract Category getDefaultCategory();
/**
* Initiates lesson restart functionality
*/
public abstract void restartLesson();
protected abstract boolean getDefaultHidden(); protected abstract boolean getDefaultHidden();
/** /**

View File

@ -108,6 +108,14 @@ public abstract class LessonAdapter extends AbstractLesson {
return false; return false;
} }
/**
* Initiates lesson restart functionality. Lessons should override this for
* lesson specific actions
*/
public void restartLesson() {
// Do Nothing - called when restart lesson is pressed. Each lesson can do something
}
private final static Integer DEFAULT_RANKING = new Integer(1000); private final static Integer DEFAULT_RANKING = new Integer(1000);
protected Integer getDefaultRanking() { protected Integer getDefaultRanking() {

View File

@ -949,6 +949,7 @@ public class WebSession {
public void restartLesson(int lessonId) { public void restartLesson(int lessonId) {
AbstractLesson al = getLesson(lessonId); AbstractLesson al = getLesson(lessonId);
System.out.println("Restarting lesson: " + al); System.out.println("Restarting lesson: " + al);
al.restartLesson();
al.getLessonTracker(this).setCompleted(false); al.getLessonTracker(this).setCompleted(false);
if (al instanceof SequentialLessonAdapter) { if (al instanceof SequentialLessonAdapter) {
SequentialLessonAdapter sla = (SequentialLessonAdapter) al; SequentialLessonAdapter sla = (SequentialLessonAdapter) al;