public abstract class AnswerValue<P extends AnswerValuePart>
extends java.lang.Object
An AnswerValue contains one or more data parts kept as a List of
AnswerValuePart
s.
The direct subclasses of AnswerValue, TeacherAnswerValue
and StudentResponseValue
provide base classes to separately define concrete classes representing teacher (or content builder)
provided answer values vs the expected form of a student's response.
Modifier | Constructor and Description |
---|---|
|
AnswerValue()
Constructor
|
protected |
AnswerValue(java.util.List<P> valueParts)
Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
protected P |
getValuePart()
Returns the first value part of this answer.
|
protected P |
getValuePart(int index)
Returns the value part, at the specified position, of this answer.
|
java.util.List<P> |
getValueParts()
Returns the list of AnswerValueParts making up this AnswerValue.
|
int |
getValuePartsCount()
Returns the number of value parts in this answer value.
|
protected AnswerEvalType |
getValuePartType()
Returns the evaluation type of the first value part of this answer.
|
protected AnswerEvalType |
getValuePartType(int index)
Returns the evaluation type of the value part, at the specified position, of this answer.
|
protected java.lang.String |
getValuePartValue()
Returns the data value of the first value part of this answer.
|
protected java.lang.String |
getValuePartValue(int index)
Returns the data value of the value part, at the specified position, of this answer.
|
int |
hashCode() |
protected abstract boolean |
isAllowedEvalType(AnswerEvalType evalType)
Returns whether an evaluation type is allowed for responses to this problem.
|
java.util.List<P> |
partsToList(P... parts)
Creates and returns a List of AnswerValueParts.
|
void |
setValueParts(java.util.List<P> valueParts)
Specifies the value parts that makes up this answer value.
|
void |
setValueParts(P... valueParts)
Specifies the value parts that makes up this answer value.
|
java.lang.String |
toString() |
java.lang.String |
toViewString()
Returns an end-user readable representation of the String value of each AnswerValuePart
|
protected abstract void |
validatePartsCount()
Validates whether count of value parts in this answer value match the
expected count for this type of answer value.
|
protected abstract void |
validatePartsCount(java.util.List<P> valueParts)
Validates whether specified list contains exactly the correct number of value parts
expected for this type of answer value.
|
public AnswerValue()
protected AnswerValue(java.util.List<P> valueParts)
valueParts
- The list of AnswerValueParts making up this AnswerValue.getValueParts()
public java.util.List<P> getValueParts()
public int getValuePartsCount()
public void setValueParts(P... valueParts)
valueParts
- The value parts making up this answer value.setValueParts(List)
public void setValueParts(java.util.List<P> valueParts) throws java.lang.IllegalArgumentException
valueParts
- The value parts making up this answer value.java.lang.IllegalArgumentException
setValueParts(AnswerValuePart...)
protected abstract void validatePartsCount(java.util.List<P> valueParts) throws java.lang.IllegalArgumentException
valueParts
- List of value partsjava.lang.IllegalArgumentException
- if the number of value parts found was unexpectedAnswerableProblemAttributes.getAnswerValuePartsCount()
,
AnswerableProblemAttributes.getResponseValuePartsCount()
protected abstract void validatePartsCount() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the number of value parts found was unexpectedAnswerableProblemAttributes.getAnswerValuePartsCount()
,
AnswerableProblemAttributes.getResponseValuePartsCount()
protected abstract boolean isAllowedEvalType(AnswerEvalType evalType)
evalType
- Evaluation type to checkAnswerEvalType
,
AnswerableProblem.registerProblemTypeAttributes(String, String, String, String, int, int, int, List, List)
protected P getValuePart()
getValuePart(int)
protected java.lang.String getValuePartValue()
getValuePartValue(int)
protected AnswerEvalType getValuePartType()
getValuePartType(int)
protected P getValuePart(int index)
index
- index of the value part to returngetValuePart()
protected java.lang.String getValuePartValue(int index)
index
- index of the value part to returngetValuePartValue()
protected AnswerEvalType getValuePartType(int index)
index
- index of the value part to returngetValuePartType()
public java.util.List<P> partsToList(P... parts)
parts
- One or more AnswerValueParts. You can pass each part as a separate argument, or
you can pass an array where each element is a single answer part.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toViewString()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object