org.qtitools.qti.node.test
Class TemplateDefault

java.lang.Object
  extended by org.qtitools.qti.node.AbstractNode
      extended by org.qtitools.qti.node.AbstractObject
          extended by org.qtitools.qti.node.test.TemplateDefault
All Implemented Interfaces:
java.io.Serializable, ExpressionParent, XmlNode, XmlObject, Validatable

public class TemplateDefault
extends AbstractObject
implements ExpressionParent

The default value of A template variable in an item can be overridden based on the test context in which the template is instantiated. The value is obtained by evaluating an expression defined within the reference to the item at test level and which may therefore depend on the values of variables taken from other items in the test or from outcomes defined at test level itself.

Author:
Jiri Kajaba, Jonathon Hare
See Also:
Serialized Form

Field Summary
static java.lang.String ATTR_TEMPLATE_IDENTIFIER_NAME
          Name of templateIdentifier attribute in xml schema.
static java.lang.String CLASS_TAG
          Name of this class in xml schema.
 
Fields inherited from interface org.qtitools.qti.node.XmlNode
INDENT, NEW_LINE, SIMPLE_NAME_INNER_SEPARATOR, SIMPLE_NAMES_SEPARATOR
 
Constructor Summary
TemplateDefault(AssessmentItemRef parent)
          Constructs object.
 
Method Summary
 Value evaluate()
          Evaluates this object.
 java.lang.String getClassTag()
          Gets QTI class name of this node.
 Expression getExpression()
          Gets expression child.
 AssessmentItemRef getParent()
          Gets parent of this node or null (if node is root; for example AssessmentTest).
 BaseType[] getRequiredBaseTypes(int index)
          Gets list of all acceptable baseTypes which can child expression at given position produce.
 Cardinality[] getRequiredCardinalities(int index)
          Gets list of all acceptable cardinalities which can child expression at given position produce.
 java.lang.String getTemplateIdentifier()
          Gets value of templateIdentifier attribute.
 Value getValue()
          Gets last result of evaluation or null if this object was not evaluated yet.
 void setExpression(Expression expression)
          Sets new expression child.
 void setTemplateIdentifier(java.lang.String templateIdentifier)
          Sets new value of templateIdentifier attribute.
 
Methods inherited from class org.qtitools.qti.node.AbstractObject
getParentItem, getParentResult, getParentTest, setParent
 
Methods inherited from class org.qtitools.qti.node.AbstractNode
attrToXmlString, bodyToXmlString, getAttributes, getFullName, getIndent, getNode, getNode, getNode, getNodeGroups, getParentRoot, getSimpleName, getSourceFile, getSourceNode, getSourceString, getSourceUrl, hasChildNodes, load, load, load, load, loadAttributes, readChild, readChildren, setParent, setSourceFile, setSourceNode, setSourceString, setSourceUrl, toXmlString, toXmlString, validate, validateAttributes, validateChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.qtitools.qti.node.XmlObject
getParentItem, getParentResult, getParentTest, setParent
 
Methods inherited from interface org.qtitools.qti.node.XmlNode
getAttributes, getFullName, getNodeGroups, getParentRoot, getSimpleName, getSourceFile, getSourceNode, getSourceString, getSourceUrl, hasChildNodes, load, load, load, load, setSourceFile, setSourceNode, setSourceString, setSourceUrl, toXmlString, toXmlString
 
Methods inherited from interface org.qtitools.qti.validation.Validatable
validate
 

Field Detail

CLASS_TAG

public static final java.lang.String CLASS_TAG
Name of this class in xml schema.

See Also:
Constant Field Values

ATTR_TEMPLATE_IDENTIFIER_NAME

public static final java.lang.String ATTR_TEMPLATE_IDENTIFIER_NAME
Name of templateIdentifier attribute in xml schema.

See Also:
Constant Field Values
Constructor Detail

TemplateDefault

public TemplateDefault(AssessmentItemRef parent)
Constructs object.

Parameters:
parent - parent of created object
Method Detail

getClassTag

public java.lang.String getClassTag()
Description copied from interface: XmlNode
Gets QTI class name of this node.

QTI class name has very important role during loading/saving nodes.

For example: Java class name is AssessmentTest; QTI class name is assessmentTest.

Specified by:
getClassTag in interface XmlNode
Specified by:
getClassTag in class AbstractNode
Returns:
QTI class name of this node

getParent

public AssessmentItemRef getParent()
Description copied from interface: XmlNode
Gets parent of this node or null (if node is root; for example AssessmentTest).

While testing some nodes (for example expressions) don't have properly set parent, but it is usable only for testing. (Some nodes cannot exists without parent even for testing).

Specified by:
getParent in interface XmlNode
Specified by:
getParent in interface XmlObject
Overrides:
getParent in class AbstractObject
Returns:
parent of this node or null (if node is root; for example AssessmentTest)

getTemplateIdentifier

public java.lang.String getTemplateIdentifier()
Gets value of templateIdentifier attribute.

Returns:
value of templateIdentifier attribute
See Also:
setTemplateIdentifier(java.lang.String)

setTemplateIdentifier

public void setTemplateIdentifier(java.lang.String templateIdentifier)
Sets new value of templateIdentifier attribute.

Parameters:
templateIdentifier - new value of templateIdentifier attribute
See Also:
getTemplateIdentifier()

getExpression

public Expression getExpression()
Gets expression child.

Returns:
expression child
See Also:
setExpression(org.qtitools.qti.node.expression.Expression)

setExpression

public void setExpression(Expression expression)
Sets new expression child.

Parameters:
expression - new expression child
See Also:
getExpression()

getRequiredCardinalities

public Cardinality[] getRequiredCardinalities(int index)
Description copied from interface: ExpressionParent
Gets list of all acceptable cardinalities which can child expression at given position produce.

For example delete expression returns single cardinality for index 0 and list of multiple and ordered cardinality for index 1.

Result of this method can change in time.

Static example is expression or. Expression or accepts only single cardinality for any index.

Dynamic example is expression match. Expression match accepts any cardinality of its children, but this cardinality must be same for all its children.

Specified by:
getRequiredCardinalities in interface ExpressionParent
Parameters:
index - position of child expression in this parent
Returns:
list of all possible cardinalities which can child expression at given position produce

getRequiredBaseTypes

public BaseType[] getRequiredBaseTypes(int index)
Description copied from interface: ExpressionParent
Gets list of all acceptable baseTypes which can child expression at given position produce.

Result of this method can change in time.

Static example is expression or. Expression or accepts only boolean baseType for any index.

Dynamic example is expression match. Expression match accepts any baseType of its children. but this baseType must be same for all its children.

Specified by:
getRequiredBaseTypes in interface ExpressionParent
Parameters:
index - position of child expression in this parent
Returns:
list of all acceptable baseTypes which can child expression at given position produce

evaluate

public Value evaluate()
Evaluates this object.

Returns:
result of evaluation

getValue

public Value getValue()
Gets last result of evaluation or null if this object was not evaluated yet.

Returns:
last result of evaluation or null if this object was not evaluated yet


Copyright © 2009. All Rights Reserved.