org.problets.domain.model.expression.node.student
Class StudentNodeView

java.lang.Object
  extended by org.problets.domain.model.expression.node.NodeView
      extended by org.problets.domain.model.expression.node.student.StudentNodeView
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
MultiOperatorStudentNodeView, ParenthesizedStudentNodeView

public class StudentNodeView
extends NodeView

To hold intermediate nodes in the student's evaluation tree.

Author:
Amruth Kumar

Field Summary
static int DUMMY
           
 
Constructor Summary
StudentNodeView(NodeView inOperator)
          This constructor is called by BailedOutStudentNodeView when constructing the right hand side expression short circuited by the student.
StudentNodeView(NodeView inOperator, java.util.Vector inOperandsCovered, int inLeftX, int inRightX, int inOrder)
          The constructor called by ExpressionProblemView
StudentNodeView(NodeView inOperator, java.util.Vector inOperandsCovered, int inLeftX, int inRightX, int inOrder, boolean setupOperandsFlag)
          The constructor called by BailedOutStudentNodeView
 
Method Summary
 java.lang.String getExpression()
          Returns a string representation of the expression after properly ordering the operands and operators
 NodeView getOriginalNodeView()
          Returns the nodeView of which this StudentNodeView is a copy
 java.lang.String getValue()
          Overrides the method defined in NodeView, so that it returns an empty string if value is null
 boolean isCovered(int leftCoord, int rightCoord)
          This method overrides NodeView.isCovered().
 boolean isResultLocallyCorrect()
          This method will evaluate the 1 operator, up to 2 operands subexpression selected by the student and find out whether the partial answer provided by the student is correct according to the subexpression chosen by the student.
static void main(java.lang.String[] args)
           
 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
 int setNCheckSideEffects(java.util.Vector inSideEffectVector)
          Records any side effects of this step, returns true if all are correct, and false otherwise.
 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.
 
Methods inherited from class org.problets.domain.model.expression.node.NodeView
classifyNodes, clone, explain, getBackupLeftX, getBackupRightX, getContent, getContentWidth, getCopyIfExists, getFontMetrics, getLeftChild, getLeftMax, getLeftMin, getLeftX, getNode, getNodeView, getRightChild, getRightMax, getRightMin, getRightX, getSideEffects, paintExpression, print, setLeftChild, setRightChild, toString, typeset
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DUMMY

public static final int DUMMY
See Also:
Constant Field Values
Constructor Detail

StudentNodeView

public StudentNodeView(NodeView inOperator,
                       java.util.Vector inOperandsCovered,
                       int inLeftX,
                       int inRightX,
                       int inOrder)
The constructor called by ExpressionProblemView


StudentNodeView

public StudentNodeView(NodeView inOperator,
                       java.util.Vector inOperandsCovered,
                       int inLeftX,
                       int inRightX,
                       int inOrder,
                       boolean setupOperandsFlag)
The constructor called by BailedOutStudentNodeView


StudentNodeView

public StudentNodeView(NodeView inOperator)
This constructor is called by BailedOutStudentNodeView when constructing the right hand side expression short circuited by the student. As such, it will use the leftX and rightX values of the original operator, since the StudentNodeView is synthetically constructed rather than specified by the student drawing an underbrace

Method Detail

getExpression

public java.lang.String getExpression()
Returns a string representation of the expression after properly ordering the operands and operators


getValue

public java.lang.String getValue()
Overrides the method defined in NodeView, so that it returns an empty string if value is null

Overrides:
getValue in class NodeView

isCovered

public boolean isCovered(int leftCoord,
                         int rightCoord)
This method overrides NodeView.isCovered(). Returns true if the intermediate result of this node is covered by leftX and rightX, and false otherwise. This method is used by ExpressionProblemView to check which StudentNodeView objects in the correct answer were covered by an underbrace drawn by a student. Since StudentNodeViews will save the extent of the student's underbraces, we use leftX and rightX for comparison.

Overrides:
isCovered in class NodeView

getOriginalNodeView

public NodeView getOriginalNodeView()
Returns the nodeView of which this StudentNodeView is a copy


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


isResultLocallyCorrect

public boolean isResultLocallyCorrect()
This method will evaluate the 1 operator, up to 2 operands subexpression selected by the student and find out whether the partial answer provided by the student is correct according to the subexpression chosen by the student. This method is called by ExpressionViewExpert to find out whether an intermediate result is correct. This method will: 1) create a copy of the two operands with the correct value in order to prevent any recursive evaluation of operand subexpressions in the original; 2) create a copy of the operator so that original's value is not altered 3) evaluate the 1-operator upto-2-operands subexpression model so created 4) return true if the calcualted value is the same as the value entered by the student and false otherwise. This will affect student's grade when called for correct steps, and will affect ONLY error-flagging when called for incorrect steps. Note: class variable Operator references the VIEW of the node in the actual answer class variable node is a studentcopy of the correct node Its value is set by ExpressionViewStep.setResult() after this object is created to the value entered by the student. tempOperator is a clone of node, used to build a temporary expression and evaluate it to see if the student's answer is locally correct.


setNCheckSideEffects

public int setNCheckSideEffects(java.util.Vector inSideEffectVector)
Records any side effects of this step, returns true if all are correct, and false otherwise. Must be called after isResultLocallyCorrect() since it uses the simulationOperator created in that method.


main

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