org.activemath.sequencer
Class ExerciseSequencer

java.lang.Object
  extended by org.activemath.sequencer.ExerciseSequencer
All Implemented Interfaces:
EventListener, ActivemathEventListener, AppSessionShutdownHook
Direct Known Subclasses:
SimpleExerciseSequencer, TutorialExerciseSequencer

public abstract class ExerciseSequencer
extends Object
implements ActivemathEventListener, AppSessionShutdownHook

Show a sequence of exercise to the user. Provides logic of the different ways of defining and fetching the proper exercises within the sub classes.


Field Summary
protected  AppSession appSession
           
protected  String bookId
           
protected  Iterator<ExerciseArgumentSetting> exerciseListIterator
           
protected  List<String> exercisesSkipped
           
protected  List<String> exercisesSolved
           
protected  String exerciseStrategy
           
protected  List<String> exericsesFailed
           
static String FINISHED_NOCONTENTABORT
           
static String FINISHED_SESSION_EXPIRED
           
static String FINISHED_SUCCESS
           
static String FINISHED_TIMEEXPIRED
           
static String FINISHED_USERABORT
           
protected  String finishReason
           
protected  String id
           
protected  List<String> itemsSeen
           
 
Constructor Summary
ExerciseSequencer(AppSession appSession)
          Generate the unique Id for the object and initialize all lists.
 
Method Summary
 void addItemsAlreadySeen(List<String> itemIds)
           
 void addItemShown(String id)
           
abstract  void exerciseFinished(String exerciseId, double successRate)
          Whenever we know that an exercise is finished, we need to update our knowledge
 String getBookId()
           
 List<String> getExercisesSkipped()
           
 List<String> getExercisesSolved()
           
 String getExerciseStrategy()
           
 List<String> getExericsesFailed()
           
 String getFinishReason()
           
 String getId()
          Provide the unique identifier
 List<String> getItemsSeen()
           
abstract  ExerciseArgumentSetting getNextExercise()
          Prepare the next exercise.
 void initExerciseListIterator(List<String> exerciseIdList)
           
protected abstract  boolean isGoalAchieved()
          Checks if the goal of exercise sequencer is achieved.
 void onActivemathEvent(ActivemathEvent event)
          Override the event listener method to react on ExerciseFinished event We need to be sure that every time user finished an exercise, we can fetch the event.
 void sessionShutdown(AppSession appSession)
          Session shutdown hook, so that even by lost of session, we can do something.
 void setExercisesSkipped(List<String> exercisesSkipped)
           
 void setExercisesSolved(List<String> exercisesSolved)
           
 void setExerciseStrategy(String exerciseStrategy)
           
 void setExericsesFailed(List<String> exericsesFailed)
           
 void setFinishReason(String finishReason)
          We need to be able to provide the information, why a sequencer will terminate (or "killed") before we really clean the object.
 void setItemsSeen(List<String> itemsSeen)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FINISHED_SUCCESS

public static String FINISHED_SUCCESS

FINISHED_USERABORT

public static String FINISHED_USERABORT

FINISHED_NOCONTENTABORT

public static String FINISHED_NOCONTENTABORT

FINISHED_TIMEEXPIRED

public static String FINISHED_TIMEEXPIRED

FINISHED_SESSION_EXPIRED

public static String FINISHED_SESSION_EXPIRED

id

protected String id

bookId

protected String bookId

appSession

protected AppSession appSession

finishReason

protected String finishReason

exercisesSkipped

protected List<String> exercisesSkipped

exercisesSolved

protected List<String> exercisesSolved

exericsesFailed

protected List<String> exericsesFailed

exerciseStrategy

protected String exerciseStrategy

itemsSeen

protected List<String> itemsSeen

exerciseListIterator

protected Iterator<ExerciseArgumentSetting> exerciseListIterator
Constructor Detail

ExerciseSequencer

public ExerciseSequencer(AppSession appSession)
Generate the unique Id for the object and initialize all lists.

Parameters:
appSession -
Method Detail

onActivemathEvent

public void onActivemathEvent(ActivemathEvent event)
Override the event listener method to react on ExerciseFinished event We need to be sure that every time user finished an exercise, we can fetch the event. TODO: test the cases when user lost the session or windows closed.

Specified by:
onActivemathEvent in interface ActivemathEventListener
Parameters:
event - the event to respond to

sessionShutdown

public void sessionShutdown(AppSession appSession)
Session shutdown hook, so that even by lost of session, we can do something. We might extend this method to provide more useful information stating how exercise sequencer has been executed. e.g. showing the 3 lists or compute a accomplishing rate.

Specified by:
sessionShutdown in interface AppSessionShutdownHook

exerciseFinished

public abstract void exerciseFinished(String exerciseId,
                                      double successRate)
Whenever we know that an exercise is finished, we need to update our knowledge

Parameters:
exerciseId -
successRate - "-1" tells us we don't know about successRate, otherwise, the number the semantic of positive value is defined in implementing classes.

getNextExercise

public abstract ExerciseArgumentSetting getNextExercise()
                                                 throws NoAvailableExercisesException
Prepare the next exercise. By override this method, make sure you check if goal is achieved by calling isGoalAchieved().

Returns:
Throws:
NoAvailableExercisesException - if we can't find one

isGoalAchieved

protected abstract boolean isGoalAchieved()
Checks if the goal of exercise sequencer is achieved. This controls when the exercise Sequencer terminates. This method must be always involved by getNextExerciseId()

Returns:
true if learning goal is achieved false if we still need to continue with showing the next exercise

getId

public String getId()
Provide the unique identifier

Returns:
id as String

addItemsAlreadySeen

public void addItemsAlreadySeen(List<String> itemIds)

addItemShown

public void addItemShown(String id)

getExercisesSkipped

public List<String> getExercisesSkipped()

setExercisesSkipped

public void setExercisesSkipped(List<String> exercisesSkipped)

getExercisesSolved

public List<String> getExercisesSolved()

setExercisesSolved

public void setExercisesSolved(List<String> exercisesSolved)

getExericsesFailed

public List<String> getExericsesFailed()

setExericsesFailed

public void setExericsesFailed(List<String> exericsesFailed)

getItemsSeen

public List<String> getItemsSeen()

setItemsSeen

public void setItemsSeen(List<String> itemsSeen)

getFinishReason

public String getFinishReason()

setFinishReason

public void setFinishReason(String finishReason)
We need to be able to provide the information, why a sequencer will terminate (or "killed") before we really clean the object. Here we define the reason


initExerciseListIterator

public void initExerciseListIterator(List<String> exerciseIdList)

getExerciseStrategy

public String getExerciseStrategy()

setExerciseStrategy

public void setExerciseStrategy(String exerciseStrategy)

getBookId

public String getBookId()