P
- A subclass of AnswerValuePart
representing a single part of an answer's or response's value.V
- A subclass of TeacherAnswerValue
implementing a problem type-specific answer value.R
- A subclass of StudentResponseValue
implementing a problem type-specific student response.public abstract class Answer<P extends AnswerValuePart,V extends TeacherAnswerValue<P,R>,R extends StudentResponseValue<P>> extends Content implements HasBuggyMessage
Modifier | Constructor and Description |
---|---|
protected |
Answer(java.lang.String classType,
java.lang.String uid)
Constructor
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getBuggyMessage()
Returns the message text
|
boolean |
getIsCorrect()
Returns whether this Answer is a correct answer.
|
V |
getTeacherValue()
Returns the value for this Answer.
|
protected Pair<java.lang.Boolean,java.lang.Boolean> |
isCorrect(R response,
java.util.Map<java.lang.String,java.lang.String> args)
Determines whether the submitted response is correct.
|
protected abstract boolean |
isMatch(R response,
java.util.Map<java.lang.String,java.lang.String> args)
Determines whether the provided response (that is to say the student's response to a question)
matches this Answer.
|
protected boolean |
isMatchDefault(R response,
java.util.Map<java.lang.String,java.lang.String> args)
Provides a default implementation for
#isMatch(StudentResponseValue) . |
protected static boolean |
preventIsMatch(java.lang.String className)
Provides a default method to be called from a subclass implementation of
Answer#isMatch(StudentResponseValue) , TeacherAnswerValue#isMatch(StudentResponseValue) ,
or AnswerValuePart#isMatch(AnswerValuePart)
when that subclass' problem type by-passes the need for any one (or more) of those isMatch()
implementation. |
void |
setBuggyMessage(java.lang.String buggyMessage)
Sets the buggy message associated with an object.
|
void |
setCorrect(boolean correct)
Specifies whether this Answer is a correct answer.
|
void |
setTeacherValue(V value)
Specifies this Answer's value
|
java.lang.String |
toString()
Returns a string representation of this object.
|
getDescription, getName, setDescription, setName
createKey, createKey, equals, extractType, extractUID, getKey, getShortKey, getShortKey, getType, getUID, getValidatorUtilities, setValidatorUtilities, validate, validateKey
protected Answer(java.lang.String classType, java.lang.String uid)
classType
- Concrete subclass' fully specified class typeuid
- Unique identifier for this Answerpublic void setTeacherValue(V value)
value
- An AnswerValue concrete subclassgetTeacherValue()
public V getTeacherValue()
setTeacherValue(TeacherAnswerValue)
public boolean getIsCorrect()
setCorrect(boolean)
public void setCorrect(boolean correct)
correct
- true if this Answer is correct; otherwise falsepublic java.lang.String getBuggyMessage()
HasBuggyMessage
getBuggyMessage
in interface HasBuggyMessage
HasBuggyMessage.setBuggyMessage(String)
public void setBuggyMessage(java.lang.String buggyMessage)
HasBuggyMessage
setBuggyMessage
in interface HasBuggyMessage
buggyMessage
- The error messageHasBuggyMessage.getBuggyMessage()
protected abstract boolean isMatch(R response, java.util.Map<java.lang.String,java.lang.String> args)
response
- A subclass of AnswerValueargs
- Map for problem specific properties that will
be used in calculating correctness for the problem.#isMatchDefault(StudentResponseValue)
,
#isCorrect(StudentResponseValue)
protected boolean isMatchDefault(R response, java.util.Map<java.lang.String,java.lang.String> args)
#isMatch(StudentResponseValue)
.
A student's response matches this answer if all the value parts match.
response
- The student's response to match to this answer.args
- Map for problem specific properties that will
be used in calculating correctness for the problem.#isMatch(StudentResponseValue)
,
TeacherAnswerValue#isMatch(StudentResponseValue)
protected static boolean preventIsMatch(java.lang.String className) throws java.lang.IllegalStateException
Answer#isMatch(StudentResponseValue)
, TeacherAnswerValue#isMatch(StudentResponseValue)
,
or AnswerValuePart#isMatch(AnswerValuePart)
when that subclass' problem type by-passes the need for any one (or more) of those isMatch()
implementation.
For example: If AnswerableProblem.isCorrect(StudentResponseValue)
fully processes the
student's response without the need to call isMatch(), then the Answer subclass
implementation of Answer#isMatch(StudentResponseValue)
would call preventIsMatch().className
- The subclass' class name.java.lang.IllegalStateException
- If a call is made to isMatch() since the
current problem type implementation does not expect that to happen.protected Pair<java.lang.Boolean,java.lang.Boolean> isCorrect(R response, java.util.Map<java.lang.String,java.lang.String> args)
response
- Value to be compared to the expected answer.args
- Map for problem specific properties that will
be used in calculating correctness for the problem.#isMatch(StudentResponseValue)
,
setCorrect(boolean)
public java.lang.String toString()
Persistable
toString
in interface IsPersistable
toString
in class Persistable