org.activemath.exercises
Class InteractionManager

java.lang.Object
  extended by org.activemath.exercises.InteractionManager

public class InteractionManager
extends Object

Interaction manager for exercises: http://www.w3.org/TR/mmi-framework/#s2

Version:
$Revision: 1.118 $ $Date: 2012/04/24 12:28:57 $

Nested Class Summary
static class InteractionManager.UserInputHistoryEntry
           
 
Field Summary
protected  boolean debugCMP
           
protected  boolean debugInteractions
           
protected static Logger log
           
protected static org.jdom.Namespace omdocNamespace
           
protected static org.jdom.Namespace openmathNamespace
           
 
Constructor Summary
InteractionManager(User user)
           
 
Method Summary
 double getEvaluationResult()
          Deprecated. get the value from the Learner Model.
 List<String> getExercisetypes()
           
 List getLastStepFeedbackContent()
          Get the feedback produced for the last step.
 List<org.jdom.Element> getLastStepMetadata()
          Get the metadata record list for the last step.
 List getLastStepUserInput()
          Get the user input for the last step.
 PresentationStrategy getPresentationStrategy()
           
 AppSession getSession()
           
 String getStrategy()
           
 boolean hasOnlySpecialActions()
          Tell whether the answer map contains only special actions, not answers to the problem statement.
 boolean hasSpecialAction(String name)
          Tell whether the answer map contains a specific action requested by the user, such as a hint.
 boolean isExerciseFinished()
          Tell whether the exercise is finished or not.
 void run(ListIterator userInputIterator, org.jdom.Element output)
          Run the exercise, and output the result to a JDOM object.
 void selectExercise(org.jdom.Document exercise)
          Set the exercise description.
 void selectExercise(String exerciseId, String lang)
          Load the exercise description.
 void selectExercise(String exerciseId, String strategy, String lang)
           
 void setLogFile(File logfile)
          setting the logfile in which the result of the exercise will be output
 void setSession(AppSession session)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Logger log

openmathNamespace

protected static final org.jdom.Namespace openmathNamespace

omdocNamespace

protected static final org.jdom.Namespace omdocNamespace

debugInteractions

protected boolean debugInteractions

debugCMP

protected boolean debugCMP
Constructor Detail

InteractionManager

public InteractionManager(User user)
Method Detail

getStrategy

public String getStrategy()

setLogFile

public void setLogFile(File logfile)
setting the logfile in which the result of the exercise will be output

Parameters:
logfile -

run

public void run(ListIterator userInputIterator,
                org.jdom.Element output)
Run the exercise, and output the result to a JDOM object.

Parameters:
userInputIterator - iterator for the list of strings with user answers.
output - container element for execution result (OMDoc fragment).

isExerciseFinished

public boolean isExerciseFinished()
Tell whether the exercise is finished or not.

Returns:
true if the exercise was finished, or false if it expects more input from the user.

getLastStepUserInput

public List getLastStepUserInput()
Get the user input for the last step.

Returns:
the user input as a list of OpenMath "OMOBJ" elements (JDOM), or null if there has been no input yet.

getLastStepMetadata

public List<org.jdom.Element> getLastStepMetadata()
Get the metadata record list for the last step.

Returns:
list of metadata records (metadata elements, JDOM) from the exercise content.

getLastStepFeedbackContent

public List getLastStepFeedbackContent()
Get the feedback produced for the last step. This only includes the feedback content (CMP) produced during the last step, not the content that remains from previous steps (those feedback elements marked with the attribute "keep"). The CMPs returned are all those present in the content, in each language. They are to be filtered later by the caller. The elements must be handled as constants, that is, any modification must be done after cloning them, in the copies. The exercise system would not be affected by modifying them directly, but other callers of this function would get the same objects until the exercise is run again in the next step.

Returns:
the feedback content as a list of "CMP" elements (JDOM).

hasSpecialAction

public boolean hasSpecialAction(String name)
Tell whether the answer map contains a specific action requested by the user, such as a hint.

Parameters:
name - Name of the user request to check.
Returns:
true if the answer map can handle such action, or false.

hasOnlySpecialActions

public boolean hasOnlySpecialActions()
Tell whether the answer map contains only special actions, not answers to the problem statement.

Returns:
true if the answer map contains only special actions and is not empty.

getExercisetypes

public List<String> getExercisetypes()

getEvaluationResult

public double getEvaluationResult()
Deprecated. get the value from the Learner Model.

Get the current evaluation result for the exercise.

Returns:
a value between 0.0 (failure) and 1.0 (success).

selectExercise

public void selectExercise(String exerciseId,
                           String lang)
                    throws IOException
Load the exercise description.

Parameters:
exerciseId - identifier for the exercise.
Throws:
IOException - can happen in case of direct loading.

selectExercise

public void selectExercise(String exerciseId,
                           String strategy,
                           String lang)
                    throws IOException
Throws:
IOException

selectExercise

public void selectExercise(org.jdom.Document exercise)
Set the exercise description.

Parameters:
exercise - exercise document.

getPresentationStrategy

public PresentationStrategy getPresentationStrategy()

getSession

public AppSession getSession()

setSession

public void setSession(AppSession session)