public abstract class AnswerValuePart extends java.lang.Object implements java.lang.Comparable<AnswerValuePart>
Each problem type defines the number of value parts that define a teacher (or content builder) answer value and the number of value parts expected in each student response to that problem type.
Each AnswerValuePart is composed of a value, represented as a String and a type which specifies how to evaluate the value.
AnswerEvalType,
AnswerValue| Modifier | Constructor and Description |
|---|---|
protected |
AnswerValuePart()
Constructor
|
protected |
AnswerValuePart(AnswerEvalType type,
java.lang.String value)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(AnswerValuePart other)
Compares another value part to this value part.
|
boolean |
equals(java.lang.Object other)
Returns whether the specified object is equivalent to this AnswerValuePart.
|
AnswerEvalType |
getType()
Returns this part's evaluation type.
|
java.lang.String |
getValue()
Returns this part's data value
|
protected abstract boolean |
isMatch(AnswerValuePart response,
java.util.Map<java.lang.String,java.lang.String> args)
Determines whether the provided value part (that is to say a value part from the student's
response to a question) matches this value part.
|
protected boolean |
isMatchDefault(AnswerValuePart response,
java.util.Map<java.lang.String,java.lang.String> args)
Default method to determine whether a value part from a student's response matches this
value part.
|
static Pair<BooleanResult,java.lang.Boolean> |
isValid(AnswerValuePart avp)
Calls isValid with the second parameter set to true.
|
static Pair<BooleanResult,java.lang.Boolean> |
isValid(AnswerValuePart avp,
boolean appendAnswer)
Validates that the evaluation type specified in an answer value part is a known type
and that the value (the data) is of that type.
|
void |
setType(AnswerEvalType type)
Sets this part's evaluation type.
|
protected void |
setValue(java.lang.String value)
Sets this part's data value
|
java.lang.String |
toString()
Returns a string representation of this value part.
|
protected AnswerValuePart()
protected AnswerValuePart(AnswerEvalType type, java.lang.String value)
type - The part's evaluation typevalue - The part's valuepublic void setType(AnswerEvalType type)
type - The evaluation type.getType()public AnswerEvalType getType()
setType(AnswerEvalType)protected void setValue(java.lang.String value)
value - The part's valuegetValue()public java.lang.String getValue()
setValue(String)public static Pair<BooleanResult,java.lang.Boolean> isValid(AnswerValuePart avp) throws java.lang.IllegalStateException, java.lang.UnsupportedOperationException
java.lang.IllegalStateExceptionjava.lang.UnsupportedOperationExceptionpublic static Pair<BooleanResult,java.lang.Boolean> isValid(AnswerValuePart avp, boolean appendAnswer) throws java.lang.IllegalStateException, java.lang.UnsupportedOperationException
avp - The answer value part to validateappendAnswer - boolean to decide whether or not to append the value of the
answerValuePart to the end of the error message.java.lang.IllegalStateException - on an unknown or undefined evaluation type.java.lang.UnsupportedOperationException - if the evaluation type is a defined type, but not currently supported
by the application.protected abstract boolean isMatch(AnswerValuePart response, java.util.Map<java.lang.String,java.lang.String> args)
Your subclass can implement this method by calling the default method
#isMatchDefault(AnswerValuePart).
response - An answer value part from the student's response.args - Map for problem specific properties that will
be used in calculating correctness for the problem.#isMatchDefault(AnswerValuePart),
Answer.preventIsMatch(String),
TeacherAnswerValue#isMatch(StudentResponseValue),
Answer#isMatch(StudentResponseValue)protected boolean isMatchDefault(AnswerValuePart response, java.util.Map<java.lang.String,java.lang.String> args)
isMatchDefault() assumes that the evaluation types of both value parts are compatible. That is to say isMatchDefault() expects:
AnswerEvalType.STRING, or
AnswerEvalType.ALGEBRA, or
AnswerEvalType.NUMERIC, or
AnswerEvalType.EXPRESSION, or
AnswerEvalType.NUMERIC_OR_EXPRESSION, or
AnswerEvalType.NUMERIC and the other value part to be
AnswerEvalType.NUMERIC_OR_EXPRESSION
response - The response value part to compare to this answer value part.args - Map for problem specific properties that will
be used in calculating correctness for the problem.#isMatch(AnswerValuePart),
TeacherAnswerValue#isMatchDefault(StudentResponseValue),
Answer#isMatchDefault(StudentResponseValue)public int compareTo(AnswerValuePart other)
compareTo in interface java.lang.Comparable<AnswerValuePart>other - The other value partComparable.compareTo(Object)public boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - The object to compare to this instance.public java.lang.String toString()
toString in class java.lang.Object