org.problets.domain.model.expression.step
Class ExpressionViewStep

java.lang.Object
  extended by org.problets.domain.line.AbstractLine
      extended by org.problets.domain.line.AbstractExplanationLine
          extended by org.problets.domain.model.expression.step.AbstractExpressionStep
              extended by org.problets.domain.model.expression.step.ExpressionViewStep
All Implemented Interfaces:
java.lang.Cloneable

public class ExpressionViewStep
extends AbstractExpressionStep

To hold one step in the solution to an expression

Author:
Amruth Kumar

Field Summary
 
Fields inherited from class org.problets.domain.line.AbstractLine
UNASSIGNED_LINE
 
Constructor Summary
ExpressionViewStep(NodeView inNodeView)
          This constructor is called for the correct answer
 
Method Summary
 boolean checkStepCorrect(java.util.Vector correctAnswer)
          Method to see if an ExpressionViewStep matches the corresponding entry in the correct answer vector.
 int getAttemptedOrder(java.util.Vector studentAnswer)
          Returns the order of attempt if the nodeView of this step was attempted by the student, and -1 otherwise.
 int getLeftX()
           
 NodeModel getNode()
           
 NodeView getNodeView()
           
 int getOrder()
          getOrder(), getResult() and equals() methods are being redefined here as a first step towards not inheriting any data members from the base class - For correct answer, order and result are already stored in NodeModel referred to by NodeView For student answer, order and result are now stored in NodeModel referred to by StudentNodeView
 java.lang.String getResult()
           
 boolean getResultCorrect()
          Returns whether the intermediate result is correct or not.
 int getRightX()
           
 boolean getSideEffectCorrect()
          Returns whether the side effects are completely correct or not.
 java.lang.String getSideEffectString()
          Returns a string of variable names and the values to which they were changed
 boolean getStepCorrect()
          Returns whether the step, i.e., operator and operand selection is correct or not.
 boolean hasSideEffect()
          This expression step has side effect if the model of the nodeView is an assignment
 boolean isInOrder(ExpressionViewStep right)
          Returns true if the order of the node of the original operator of the StudentNodeView that is a part of this step is less than that of the right operand, and false otherwise.
static void main(java.lang.String[] args)
           
 void print()
          Prints all the fields of the class
 void restoreAvailable(java.util.Vector operatorVector, java.util.Vector operandVector)
          Updates the operatorViewVector and operandViewVector based on which operators and operands were used for this node when this node is deleted from the student model
 void setNCheckResult(java.lang.String inResult, java.util.Vector correctAnswer)
          Sets the value of an expressionViewStep and sets whether it is correct or not.
 void setNCheckSideEffects(java.util.Vector inSideEffectVector)
           
 void setOrder(int inOrder)
          setOrder(), setResult() methods are being redefined here as a first step towards not inheriting any data members from the base class - For correct answer, order and result are already stored in NodeModel referred to by NodeView For student answer, order and result are now stored in NodeModel referred to by StudentNodeView
 void setResult(java.lang.String inResult)
           
 java.lang.String toString()
          Returns this operator and its two operands.
 void updateAvailable(java.util.Vector operatorVector, java.util.Vector operandVector)
          Updates the operatorViewVector and operandViewVector based on which operators and operands were used for this node when this node is added to the student model
 boolean valueEquals(ExpressionViewStep right)
          This method attempts to match based on the data type of the correct operand.
 
Methods inherited from class org.problets.domain.model.expression.step.AbstractExpressionStep
replaceTagDelimiters
 
Methods inherited from class org.problets.domain.line.AbstractExplanationLine
getEvent, getExplainer, getFeedbackAmount, setFeedbackAmount
 
Methods inherited from class org.problets.domain.line.AbstractLine
clone, getLineNumber, setLineNumber
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpressionViewStep

public ExpressionViewStep(NodeView inNodeView)
This constructor is called for the correct answer

Method Detail

getLeftX

public int getLeftX()

getRightX

public int getRightX()

getStepCorrect

public boolean getStepCorrect()
Returns whether the step, i.e., operator and operand selection is correct or not.


getSideEffectCorrect

public boolean getSideEffectCorrect()
Returns whether the side effects are completely correct or not.


getResultCorrect

public boolean getResultCorrect()
Returns whether the intermediate result is correct or not.


getNode

public NodeModel getNode()

getNodeView

public NodeView getNodeView()

hasSideEffect

public boolean hasSideEffect()
This expression step has side effect if the model of the nodeView is an assignment


getSideEffectString

public java.lang.String getSideEffectString()
Returns a string of variable names and the values to which they were changed


checkStepCorrect

public boolean checkStepCorrect(java.util.Vector correctAnswer)
Method to see if an ExpressionViewStep matches the corresponding entry in the correct answer vector. The step is graded as being correct if the models of operator+operands match. This method will always be called with student answer step as left operand.


valueEquals

public boolean valueEquals(ExpressionViewStep right)
This method attempts to match based on the data type of the correct operand. It should be called with the correct answer as the left operand so that we can access the data type of the result This method correctly handles the following cases: 13 vs 013 - equal 45.0 vs 45.00 - equal true vs TRUE - equal 'A' vs 'a' - NOT equal It handles the following cases uniquely: Correct answer Student answer 45 45.0 - NOT equal - OK since users seldom use real instead of integer 45 true - NOT Equal 45.0 45 - NOT Equal - needed to check whether user understands coercion 45.0 true - NOT Equal true 1/2/3 - Equal true 12.3 - NOT Equal - OK since users seldom use real instead of boolean 'A' 65 - NOT Equal - never happens since char exprsn return CInteger value 'A' 65.0 - NOT Equal 'A' true - NOT Equal - never happens since char exprsn return CInteger value 65 'A' - NOT Equal - User expected to realize char exprsns return CInteger 65.0 'A' - NOT Equal true 'A' - NOT Equal Assumes that the correct answer uses the following types for results: In 3 * 4 && 10, 3 * 4 returns 12, not true 4 < 5 returns true - a bool object, not 1 or 0 'A' + 3 returns CInteger, and user is expected to enter an integer value


toString

public java.lang.String toString()
Returns this operator and its two operands. Used to print the result of each step in the evaluation of the expression

Overrides:
toString in class AbstractExpressionStep

getOrder

public int getOrder()
getOrder(), getResult() and equals() methods are being redefined here as a first step towards not inheriting any data members from the base class - For correct answer, order and result are already stored in NodeModel referred to by NodeView For student answer, order and result are now stored in NodeModel referred to by StudentNodeView

Overrides:
getOrder in class AbstractExpressionStep

getResult

public java.lang.String getResult()
Overrides:
getResult in class AbstractExpressionStep

getAttemptedOrder

public int getAttemptedOrder(java.util.Vector studentAnswer)
Returns the order of attempt if the nodeView of this step was attempted by the student, and -1 otherwise. Left operand is a step in the correct answer, right operand is a step in the student's answer.


isInOrder

public boolean isInOrder(ExpressionViewStep right)
Returns true if the order of the node of the original operator of the StudentNodeView that is a part of this step is less than that of the right operand, and false otherwise. This is to be used only for StudentNodeViews.


updateAvailable

public void updateAvailable(java.util.Vector operatorVector,
                            java.util.Vector operandVector)
Updates the operatorViewVector and operandViewVector based on which operators and operands were used for this node when this node is added to the student model


restoreAvailable

public void restoreAvailable(java.util.Vector operatorVector,
                             java.util.Vector operandVector)
Updates the operatorViewVector and operandViewVector based on which operators and operands were used for this node when this node is deleted from the student model


setOrder

public void setOrder(int inOrder)
setOrder(), setResult() methods are being redefined here as a first step towards not inheriting any data members from the base class - For correct answer, order and result are already stored in NodeModel referred to by NodeView For student answer, order and result are now stored in NodeModel referred to by StudentNodeView

Overrides:
setOrder in class AbstractExpressionStep

setResult

public void setResult(java.lang.String inResult)
Overrides:
setResult in class AbstractExpressionStep

setNCheckResult

public void setNCheckResult(java.lang.String inResult,
                            java.util.Vector correctAnswer)
Sets the value of an expressionViewStep and sets whether it is correct or not.


setNCheckSideEffects

public void setNCheckSideEffects(java.util.Vector inSideEffectVector)

print

public void print()
Description copied from class: AbstractExplanationLine
Prints all the fields of the class

Overrides:
print in class AbstractExpressionStep

main

public static void main(java.lang.String[] args)