public abstract class TeacherAnswerValue<P extends AnswerValuePart,R extends StudentResponseValue<P>> extends AnswerValue<P>
Constructor and Description |
---|
TeacherAnswerValue() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
isAllowedEvalType(AnswerEvalType evalType)
Returns whether an evaluation type is allowed for responses to this problem.
|
protected abstract boolean |
isMatch(R response,
java.util.Map<java.lang.String,java.lang.String> args)
Determines whether a student's response matches this answer value.
|
protected boolean |
isMatchDefault(R response,
java.util.Map<java.lang.String,java.lang.String> args)
Default method to determine whether a student's response matches this AnswerValue.
|
protected void |
validatePartsCount()
Validates whether count of value parts in this answer value match the
expected count for this type of answer value.
|
protected 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.
|
equals, getValuePart, getValuePart, getValueParts, getValuePartsCount, getValuePartType, getValuePartType, getValuePartValue, getValuePartValue, hashCode, partsToList, setValueParts, setValueParts, toString, toViewString
protected abstract boolean isMatch(R response, java.util.Map<java.lang.String,java.lang.String> args)
A matching response does not imply the given response is correct.
Your subclass can implement this method by calling the default method
#isMatchDefault(StudentResponseValue)
.
The semantics of your problem type might prevent your AnswerValue subclass from calling the isMatchDefault(StudentResponseValue) method.
One case is when the problem type does not implement a 1:1 matching of answer value parts to response value parts.
For example: A range problem is not going to match the student's response (with a single value part) to the answer value parts (which represent a lower- and upper-limit). Rather the range problem must provide an isMatch() implementation that checks if the student's response, a single-part answer value, falls between the two limits.
response
- The response to compare to this answer value.args
- Map for problem specific properties that will
be used in calculating correctness for the problem.#isMatchDefault(StudentResponseValue)
,
Answer#isMatch(StudentResponseValue)
,
AnswerValuePart#isMatch(AnswerValuePart)
protected boolean isMatchDefault(R response, java.util.Map<java.lang.String,java.lang.String> args)
The response matches if and only if every response value part matches its corresponding answer value part.
NOTE: This method calls AnswerValuePart#isMatch(AnswerValuePart)
for each
value part. This means that if you provide a custom implementation for AnswerValuePart#isMatch()
(you don't simply call AnswerValuePart#isMatchDefault(AnswerValuePart)
),
this default method invokes your custom implementation.
response
- The response to compare to this answer value.args
- Map for problem specific properties that will
be used in calculating correctness for the problem.#isMatch(StudentResponseValue)
,
Answer#isMatchDefault(StudentResponseValue)
,
AnswerValuePart#isMatchDefault(AnswerValuePart)
protected void validatePartsCount(java.util.List<P> valueParts) throws java.lang.IllegalArgumentException
AnswerValue
validatePartsCount
in class AnswerValue<P extends AnswerValuePart>
valueParts
- List of value partsjava.lang.IllegalArgumentException
- if the number of value parts found was unexpectedAnswerableProblemAttributes.getAnswerValuePartsCount()
,
AnswerableProblemAttributes.getResponseValuePartsCount()
protected void validatePartsCount() throws java.lang.IllegalArgumentException
AnswerValue
validatePartsCount
in class AnswerValue<P extends AnswerValuePart>
java.lang.IllegalArgumentException
- if the number of value parts found was unexpectedAnswerableProblemAttributes.getAnswerValuePartsCount()
,
AnswerableProblemAttributes.getResponseValuePartsCount()
protected boolean isAllowedEvalType(AnswerEvalType evalType)
AnswerValue
isAllowedEvalType
in class AnswerValue<P extends AnswerValuePart>
evalType
- Evaluation type to checkAnswerEvalType
,
AnswerableProblem.registerProblemTypeAttributes(String, String, String, String, int, int, int, List, List)