public interface QuestionInstance extends Serializable
Modifier and Type | Method and Description |
---|---|
boolean |
areAllAnswersCorrect()
Returns whether all the answers included in this question instance are correct
according to a previously given
QuestionResponse from the quizzes service. |
boolean |
areVariablesReady()
Check whether the images cache is ready or it must be rebuilt.
|
java.lang.String |
expandVariables(java.lang.String html)
Given a html with placeholders #a, #b for variables, it replaces each
placeholder for its value.
|
java.lang.String |
expandVariablesMathML(java.lang.String mathml)
Like
expandVariables(String) but the result is a single MathML
equation. |
java.lang.String |
expandVariablesText(java.lang.String text)
Like
expandVariables(String) but only text variables are used and
the result is plain text (not escaped for XML/HTML). |
double |
getAnswerGrade(int correctAnswer,
int studentAnswer,
Question question)
Deprecated.
Use
getGrade(Slot, AuthorAnswer) instead. |
AssertionCheck[] |
getAssertionChecks(int correctAnswer,
int studentAnswer)
Deprecated.
Use
getChecks(Slot, AuthorAnswer) instead. |
AssertionCheck[] |
getChecks(Slot slot,
AuthorAnswer authorAnswer)
Returns the evaluation of the set of assertions resulting of using the grading
criteria contained in the
AuthorAnswer object to grade the answer entered
into a given Slot . |
double |
getCompoundAnswerGrade(int correctAnswer,
int studentAnswer,
int index,
Question question)
Deprecated.
Use
getCompoundGrade(Slot, AuthorAnswer, int) instead. |
double |
getCompoundGrade(Slot slot,
AuthorAnswer authorAnswer,
int index)
Returns the grade associated to the answer of one of the subquestions in a
compound answer question type.
|
double |
getGrade(Slot slot,
AuthorAnswer authorAnswer)
Returns the grade associated to the comparison between a student answer and
a correct answer between 0 (incorrect) and 1 (correct).
|
java.lang.String |
getProperty(PropertyName name)
Get a question instance property.
|
java.lang.String |
getSlotAnswer(Slot slot)
Gets the value of the student answer entered in the given slot.
|
java.lang.String |
getStudentAnswer(int index)
Deprecated.
Use
getSlotAnswer(Slot) instead. |
int |
getStudentAnswersLength()
Deprecated.
|
QuestionInstance |
getStudentQuestionInstance()
Creates a new
QuestionInstance only with the data needed to properly render
the student's answer page. |
boolean |
isAnswerCorrect(int studentAnswer)
Deprecated.
Use
isSlotAnswerCorrect(Slot) instead. |
boolean |
isSlotAnswerCorrect(Slot slot)
Returns whether the answer entered in a given
slot is correct according to previously given
QuestionResponse from the quizzes service. |
void |
setAuxiliarText(java.lang.String text)
Deprecated.
Use
setAuxiliaryText(String) instead. |
void |
setAuxiliaryText(java.lang.String text)
Sets the auxiliary text of this question instance.
|
void |
setCasSession(java.lang.String session)
Sets the CAS session of this question instance.
|
void |
setParameter(java.lang.String name,
java.lang.String value)
Set a parameter value.
|
void |
setProperty(PropertyName name,
java.lang.String value)
Set a question instance property.
|
void |
setRandomSeed(int seed)
Sets a random seed for this instance.
|
void |
setSlotAnswer(Slot slot,
java.lang.String answer)
Sets the student's answer in a given slot.
|
void |
setStudentAnswer(int index,
java.lang.String answer)
Deprecated.
Use
setSlotAnswer(Slot, String) instead. |
void |
update(QuestionResponse response)
It saves the evaluation or variables contained in the given
QuestionResponse object.
|
void |
updateFromStudentQuestionInstance(QuestionInstance qi)
Saves the content in given question instance that may be changed by the
student.
|
serialize
void update(QuestionResponse response)
QuizzesService.execute(com.wiris.quizzes.api.QuestionRequest)
.
If response contains evaluation data, the evaluation data will be reset.
And the same for variables: old variables will not be maintained.void updateFromStudentQuestionInstance(QuestionInstance qi)
qi
- The student question instance edited by the user.getStudentQuestionInstance().
@Deprecated boolean isAnswerCorrect(int studentAnswer)
isSlotAnswerCorrect(Slot)
instead.studentAnswer
- The index of the answer to check, starting from 0.getAnswerGrade(int,int,Question)
boolean areAllAnswersCorrect()
QuestionResponse
from the quizzes service.boolean isSlotAnswerCorrect(Slot slot)
slot
is correct according to previously given
QuestionResponse
from the quizzes service.slot
- The slot that corresponds to the answer being graded.getGrade(Slot, AuthorAnswer)
java.lang.String expandVariables(java.lang.String html)
html
- The source html with placeholders.java.lang.String expandVariablesMathML(java.lang.String mathml)
expandVariables(String)
but the result is a single MathML
equation.
This method should be used to produce pure mathematical items such as the
correct answer.mathml
- The source mathml (or plain text) with placeholders.expandVariables(String)
,
expandVariablesText(String)
java.lang.String expandVariablesText(java.lang.String text)
expandVariables(String)
but only text variables are used and
the result is plain text (not escaped for XML/HTML).
This method should be used to put formulas where MathML is not allowed such
as elements in a drop-down list or in an HTML text input.text
- The source text with placeholders.expandVariables(String)
,
expandVariablesMathML(String)
@Deprecated double getAnswerGrade(int correctAnswer, int studentAnswer, Question question)
getGrade(Slot, AuthorAnswer)
instead.correctAnswer
- The index of the correct answer, starting from 0.studentAnswer
- The index of the student answer, starting from 0.question
- Optional. The question object where to find the grading
configuration. If null is given then the default options are used.double getGrade(Slot slot, AuthorAnswer authorAnswer)
slot
- The slot for the student answer being graded.authorAnswer
- The author answer that contains the grading criteria that
has been used to obtain the requested grade.@Deprecated double getCompoundAnswerGrade(int correctAnswer, int studentAnswer, int index, Question question)
getCompoundGrade(Slot, AuthorAnswer, int)
instead.correctAnswer
- The index of the correct answer, starting from 0.studentAnswer
- The index of the student answer, starting from 0.index
- The position of the subquestion to be evaluated.question
- The question object where to find the grading
configuration.java.lang.Exception
- If the question is not compound answer or the grading
method is grading function.double getCompoundGrade(Slot slot, AuthorAnswer authorAnswer, int index)
slot
- The slot for the student answer being graded.authorAnswer
- The author answer that contains the grading criteria that
has been used to obtain the requested grade.index
- The position of the subquestion to be evaluated.java.lang.Exception
- If the question is not compound answer or the grading
method is grading function.QuestionInstance getStudentQuestionInstance()
QuestionInstance
only with the data needed to properly render
the student's answer page. In particular, it hides all sensible information
that would give some information to the student. The result of this method
is not intended to be stored but outputted to html.
Note that while the object returned is new, it need not to be a full
in-depth copy so the contained objects may be shared with this
QuestionInstance
.void setRandomSeed(int seed)
void setCasSession(java.lang.String session)
@Deprecated void setAuxiliarText(java.lang.String text)
setAuxiliaryText(String)
instead.void setAuxiliaryText(java.lang.String text)
@Deprecated void setStudentAnswer(int index, java.lang.String answer)
setSlotAnswer(Slot, String)
instead.index
- The index of the student answer, starting from 0. For
single-answer questions it is always 0.answer
- The MathML or plain text with the answer math expression.@Deprecated java.lang.String getStudentAnswer(int index)
getSlotAnswer(Slot)
instead.index
- The index of the student answer starting from 0.getStudentAnswersLength()
java.lang.String getSlotAnswer(Slot slot)
slot
- The slot where requested student answer is set to.void setSlotAnswer(Slot slot, java.lang.String answer)
slot
- The slot where to set the student's answer.answer
- The MathML or plain text with the answer math expression.@Deprecated int getStudentAnswersLength()
getStudentAnswer(int)
@Deprecated AssertionCheck[] getAssertionChecks(int correctAnswer, int studentAnswer)
getChecks(Slot, AuthorAnswer)
instead.correctAnswer
- The index of the correct answer, starting from 0.studentAnswer
- The index of the student answer, starting from 0.AssertionCheck[] getChecks(Slot slot, AuthorAnswer authorAnswer)
AuthorAnswer
object to grade the answer entered
into a given Slot
.slot
- The slot for the student answer being graded.authorAnswer
- The author answer that contains the grading criteria that
has been used to obtain the assertion checks.boolean areVariablesReady()
void setProperty(PropertyName name, java.lang.String value)
name
- The property name, from QuizzesConstants
.value
- The property value.getProperty(PropertyName)
java.lang.String getProperty(PropertyName name)
name
- The property name, from QuizzesConstants
.setProperty(PropertyName, String)
void setParameter(java.lang.String name, java.lang.String value)
Question
algorithm should have an initialization
command like:
parameter name = value
so the variable "name" is used later in the algorithm. On this instance,
the value of the parameter "name" will be overrided by the value given in
this method.
A particular use of this method is the localization of algorithms. In such
case, the mathml <ms>
tag should be used.name
- The name of the parameter. Must be a valid Wiris Cas identifier.value
- A mathematical expression, to be parsed using the default syntax context.
If null or empty string is passed, then a parameter with given name will
be removed.Question.setAlgorithm(java.lang.String)
,
Quizzes.newVariablesRequest(java.lang.String, com.wiris.quizzes.api.QuestionInstance)
Copyright © 2021 Maths for More S.L. All Rights Reserved.