org.activemath.exercises
Class Evaluator

java.lang.Object
  extended by org.activemath.exercises.openmath.OpenMath
      extended by org.activemath.exercises.Evaluator
Direct Known Subclasses:
ALOENoFeedbackStrategy.ATuFEvaluator, ALOEStrategy.ALOEEvaluator, ALOEStrategyAssessment.AloeDefaultEvaluator, ALOEStrategyDefault.AloeDefaultEvaluator, CompositeExercise.CompositeEvaluator, DefaultGenerator.DefaultEvaluator, DRGenerator.DREvaluator, FractionsGenerator.FractionsEvaluator, HTWGenerator.HtwEvaluator, KRKCR.KRKCREvaluator, MAPSMossaicControl.SelfRegulatedEvaluator, MAPSMossaicFremdPlannung.SelfRegulatedEvaluator, MathDoxInteractionManager.MathDoxEvaluator, SelfRegulateStrategy.SelfRegulatedEvaluator, SelfRegulateStrategy2.SelfRegulatedEvaluator, SelfRegulateStrategyTest.SelfRegulatedEvaluator

public class Evaluator
extends OpenMath

Expression evaluator. Used for comparing expressions.

Version:
$Revision: 1.67 $ $Date: 2010/07/30 13:49:11 $

Field Summary
 org.jdom.Element diagnosisFromCondition
           
 LocalUserModel localUserModel
           
protected static Logger log
           
protected static OpenMath om
           
protected static org.jdom.Namespace omdocNamespace
           
protected static org.jdom.Element omobjFalse
           
protected static org.jdom.Element omobjTrue
           
protected static org.jdom.Element omobjZero
           
 
Fields inherited from class org.activemath.exercises.openmath.OpenMath
openmathNamespace
 
Constructor Summary
Evaluator()
           
Evaluator(LocalUserModel localUserModel)
           
 
Method Summary
protected  boolean booleanTrivialComparison(org.jdom.Element element, List<org.jdom.Element> reply, ArrayList<Boolean> lastEvaluationResult)
           
protected  boolean booleanTrivialComparison(org.jdom.Element element, List<org.jdom.Element> reply, int index, ArrayList<Boolean> lastEvaluationResult)
           
protected  boolean booleanTrivialCompositeComparison(List<org.jdom.Element> reference, List<org.jdom.Element> reply, String unordered, ArrayList<Boolean> lastEvaluationResult)
           
protected  boolean booleanTrivialElementCondition(List<org.jdom.Element> reply, org.jdom.Element element, ArrayList<Boolean> lastEvaluationResult)
           
protected  ArrayList booleanTrivialEvaluateAnswerMap(org.jdom.Element answerMapElement, List<org.jdom.Element> userAnswer)
           
 boolean elementCondition(List<org.jdom.Element> reply, org.jdom.Element element)
          Evaluate a condition, and return its boolean value.
 double getAchievement()
           
 org.jdom.Element getDiagnosis(org.jdom.Element answerMapElement, List userAnswer)
          Produce a diagnosis for the given answer map and answer.
protected  boolean isNumericallyEqual(org.jdom.Element a, org.jdom.Element b, double epsilon)
          Compare two elements numerically.
protected  boolean isSemanticallyEqual(org.jdom.Element a, org.jdom.Element b, String context)
          Compare two elements semantically.
protected  boolean isSyntacticallyEqual(org.jdom.Element a, org.jdom.Element b)
          Compare two elements syntactically.
 String pickNextInteraction(org.jdom.Element answerMapElement, List userAnswer)
          Pick the interaction identifier for the condition that holds.
 
Methods inherited from class org.activemath.exercises.openmath.OpenMath
applyBinding, getOmobjContents, oma, oma, oma, oma, oma, ombind, ombind, ombind, ombind, ombind, ombvar, ombvar, ombvar, ombvar, ome, ome, ome, ome, omf, omf, omi, omi, omobj, oms, omstr, omv, output, setOmNamespace, substituteVariables, tidyForOpenMath1, toDouble, toInt
 
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

omdocNamespace

protected static final org.jdom.Namespace omdocNamespace

om

protected static OpenMath om

omobjTrue

protected static org.jdom.Element omobjTrue

omobjFalse

protected static org.jdom.Element omobjFalse

omobjZero

protected static org.jdom.Element omobjZero

diagnosisFromCondition

public org.jdom.Element diagnosisFromCondition

localUserModel

public LocalUserModel localUserModel
Constructor Detail

Evaluator

public Evaluator(LocalUserModel localUserModel)

Evaluator

public Evaluator()
Method Detail

pickNextInteraction

public String pickNextInteraction(org.jdom.Element answerMapElement,
                                  List userAnswer)
Pick the interaction identifier for the condition that holds.

Parameters:
answerMapElement - "answer_map" element.
userAnswer - list of OMOBJs that form the answer from the user.
Returns:
identifier for next interaction.

getDiagnosis

public org.jdom.Element getDiagnosis(org.jdom.Element answerMapElement,
                                     List userAnswer)
Produce a diagnosis for the given answer map and answer.

Returns:
diagnosis as a JDOM element. The element is built after each call, even when the only diagnosis comes from the content.

elementCondition

public boolean elementCondition(List<org.jdom.Element> reply,
                                org.jdom.Element element)
Evaluate a condition, and return its boolean value. Comparisons are combined with a "shortcut and" operator ("&&" in Java). A void condition is always false.

Parameters:
reply - user's answer to the current question.
element - assumed to be valid.
Returns:
whether the user input matches this condition or not.

isSemanticallyEqual

protected boolean isSemanticallyEqual(org.jdom.Element a,
                                      org.jdom.Element b,
                                      String context)
Compare two elements semantically.

Parameters:
a - first element.
b - second element.
context - semantical context for the comparison.
Returns:
true if equal, false otherwise.

isSyntacticallyEqual

protected boolean isSyntacticallyEqual(org.jdom.Element a,
                                       org.jdom.Element b)
Compare two elements syntactically. This is done by recursively matching all subelements and attributes defined in OpenMath. Extra elements or attributes are ignored. If any of the elements is null, the result is "false". OM errors are treated specially: if the head symbol matches, they are considered equivalent regardless of the rest. This allows to match an error class ignoring the accompanying context information.

Parameters:
a - first element.
b - second element.
Returns:
true if equal, false otherwise.

isNumericallyEqual

protected boolean isNumericallyEqual(org.jdom.Element a,
                                     org.jdom.Element b,
                                     double epsilon)
Compare two elements numerically. OMIs are converted to double floats, since it is absurd asking the user for an integer greater than those storable as Java double float numbers, so we do not care about overflow. If any of the elements is null, the result is "false".

Parameters:
a - first element.
b - second element.
epsilon - maximum difference. Should be a positive number.
Returns:
true if equal, false otherwise.

booleanTrivialEvaluateAnswerMap

protected ArrayList booleanTrivialEvaluateAnswerMap(org.jdom.Element answerMapElement,
                                                    List<org.jdom.Element> userAnswer)

booleanTrivialElementCondition

protected boolean booleanTrivialElementCondition(List<org.jdom.Element> reply,
                                                 org.jdom.Element element,
                                                 ArrayList<Boolean> lastEvaluationResult)

booleanTrivialComparison

protected boolean booleanTrivialComparison(org.jdom.Element element,
                                           List<org.jdom.Element> reply,
                                           ArrayList<Boolean> lastEvaluationResult)

booleanTrivialComparison

protected boolean booleanTrivialComparison(org.jdom.Element element,
                                           List<org.jdom.Element> reply,
                                           int index,
                                           ArrayList<Boolean> lastEvaluationResult)

booleanTrivialCompositeComparison

protected boolean booleanTrivialCompositeComparison(List<org.jdom.Element> reference,
                                                    List<org.jdom.Element> reply,
                                                    String unordered,
                                                    ArrayList<Boolean> lastEvaluationResult)

getAchievement

public double getAchievement()