org.activemath.exercises.model
Class Exercise

java.lang.Object
  extended by org.activemath.exercises.model.Exercise

public class Exercise
extends Object


Constructor Summary
Exercise(String id)
           
 
Method Summary
 void addInteraction(Interaction interaction)
          Adds an interaction to this exercise.
protected  void addKey(String key)
           
 void addTransition(Transition transition)
          Adds a transition to the exercise.
 Interaction createInteraction(String id)
          Create a new Interaction for this exercise.
 void deleteInteraction(Interaction interaction)
          Delete an interaction from this exercise.
 void deleteTransition(Transition transition)
          Delete a transition from this exercise.
 String generateKey()
          This method generate an unique (in exercise's scope) key.
 Interaction getCurrentInteraction()
           
 org.jdom.Element getGenerator()
           
 String getId()
           
 Interaction getInteraction(String id)
           
 List getInteractionKeys()
           
 org.jdom.Element getMetadata()
           
 List getOutgoingTransitions(Interaction interaction)
           
 PresentationBlock getProblemstatement()
           
 Transition getTransition(Interaction source, Interaction target, String key)
           
 void pushTransition(Interaction interaction, boolean down, Transition transition)
           
 Interaction run(Interaction interaction, List userInput)
           
 void setCurrentInteraction(Interaction interaction)
           
 void setGenerator(org.jdom.Element generator)
           
 void setMetadata(org.jdom.Element metadata)
           
 void setProblemstatement(PresentationBlock problem)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Exercise

public Exercise(String id)
Method Detail

createInteraction

public Interaction createInteraction(String id)
Create a new Interaction for this exercise. If an interaction with the same id is already present returns an existing interaction without creating a new one.

Parameters:
id - of the creating interaction.
Returns:
an interaction

addInteraction

public void addInteraction(Interaction interaction)
Adds an interaction to this exercise. The createInteraction doesn't add a new interaction to the exercise. It should be done explicitly.

Parameters:
interaction - an interaction to be added.

addTransition

public void addTransition(Transition transition)
Adds a transition to the exercise.

Parameters:
transition - to be added.

generateKey

public String generateKey()
This method generate an unique (in exercise's scope) key. Needed for retrieving components of the exercise during authoring.

Returns:
the key

deleteInteraction

public void deleteInteraction(Interaction interaction)
Delete an interaction from this exercise.

Parameters:
interaction - to be deleted.

deleteTransition

public void deleteTransition(Transition transition)
Delete a transition from this exercise.

Parameters:
source -
target -
key -

getCurrentInteraction

public Interaction getCurrentInteraction()
Returns:
a current interaction, in other words return the surrent state of the finite state machine.

getGenerator

public org.jdom.Element getGenerator()

getId

public String getId()

getInteraction

public Interaction getInteraction(String id)

getInteractionKeys

public List getInteractionKeys()

getMetadata

public org.jdom.Element getMetadata()

getProblemstatement

public PresentationBlock getProblemstatement()

getTransition

public Transition getTransition(Interaction source,
                                Interaction target,
                                String key)

getOutgoingTransitions

public List getOutgoingTransitions(Interaction interaction)

pushTransition

public void pushTransition(Interaction interaction,
                           boolean down,
                           Transition transition)

setCurrentInteraction

public void setCurrentInteraction(Interaction interaction)

setGenerator

public void setGenerator(org.jdom.Element generator)

setMetadata

public void setMetadata(org.jdom.Element metadata)

setProblemstatement

public void setProblemstatement(PresentationBlock problem)

addKey

protected void addKey(String key)

run

public Interaction run(Interaction interaction,
                       List userInput)