Merge pull request #85 from mayhew64/master

Added a lesson restart for lesson specific restart actions
This commit is contained in:
Nanne 2015-09-18 22:11:00 +02:00
commit 3535626ad9
3 changed files with 15 additions and 0 deletions

View File

@ -676,6 +676,12 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
*/ */
public abstract String getCurrentAction(WebSession s); public abstract String getCurrentAction(WebSession s);
/**
* Initiates lesson restart functionality
*/
public abstract void restartLesson();
/** /**
* <p>setCurrentAction.</p> * <p>setCurrentAction.</p>
* *

View File

@ -111,6 +111,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);
/** /**

View File

@ -1126,6 +1126,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;