org.activemath.exercises
Class Interpreter

java.lang.Object
  extended byorg.activemath.exercises.Interpreter

public class Interpreter
extends Object

Interpreter for exercises.

Version:
$Revision: 1.63 $ $Date: 2006/07/20 18:21:20 $
Author:
Alberto González Palomo

Nested Class Summary
static class Interpreter.UserInputHistoryEntry
           
 
Constructor Summary
Interpreter()
           
 
Method Summary
 double getEvaluationResult()
          Deprecated. get the value from the Learner Model.
 String getExercisetype()
           
 List getLastStepFeedbackContent()
          Get the feedback produced for the last step.
 List getLastStepMetadata()
          Get the metadata record list for the last step.
 List getLastStepUserInput()
          Get the user input for the last step.
 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, Element output)
          Run the exercise, and output the result to a JDOM object.
 void selectExercise(Document exercise)
          Set the exercise description.
 void selectExercise(String exerciseId)
          Load the exercise description.
 void selectExercise(String exerciseId, String strategy)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Interpreter

public Interpreter()
Method Detail

run

public void run(ListIterator userInputIterator,
                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 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.

getExercisetype

public String getExercisetype()

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)
                    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)
                    throws IOException
Throws:
IOException

selectExercise

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

Parameters:
exercise - exercise document.