use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.
the class AssessmentItemBuilder method appendAdditionalFeedback.
protected void appendAdditionalFeedback(ModalFeedbackBuilder feedback, List<ModalFeedback> modalFeedbacks, List<ResponseRule> responseRules) {
Identifier feedbackIdentifier = feedback.getIdentifier();
ModalFeedback modalFeedback = AssessmentItemFactory.createModalFeedback(assessmentItem, feedbackIdentifier, feedback.getTitle(), feedback.getText());
modalFeedbacks.add(modalFeedback);
Cardinality cardinality = null;
Identifier responseIdentifier = null;
if (this instanceof ResponseIdentifierForFeedback) {
responseIdentifier = ((ResponseIdentifierForFeedback) this).getResponseIdentifier();
cardinality = assessmentItem.getResponseDeclaration(responseIdentifier).getCardinality();
}
ResponseCondition feedbackCondition = AssessmentItemFactory.createModalFeedbackRuleWithConditions(assessmentItem.getResponseProcessing(), feedbackIdentifier, responseIdentifier, cardinality, feedback.getFeedbackConditons());
responseRules.add(feedbackCondition);
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.
the class AssessmentItemBuilder method buildHint.
/**
* @param outcomeDeclarations
* @param responseRules
*/
protected void buildHint(List<OutcomeDeclaration> outcomeDeclarations, List<ResponseRule> responseRules) {
if (hint == null)
return;
// response declaration -> identifier=HINTREQUEST -> for the end attempt interaction
ResponseDeclaration hintResponseDeclaration = AssessmentItemFactory.createHintRequestResponseDeclaration(assessmentItem);
assessmentItem.getResponseDeclarations().add(hintResponseDeclaration);
// outcome declaration -> identifier=HINTFEEDBACKMODAL -> for processing and feedback
OutcomeDeclaration modalOutcomeDeclaration = AssessmentItemFactory.createOutcomeDeclarationForHint(assessmentItem);
outcomeDeclarations.add(modalOutcomeDeclaration);
// the body
P paragraph = new P(assessmentItem.getItemBody());
assessmentItem.getItemBody().getBlocks().add(paragraph);
EndAttemptInteraction endAttemptInteraction = new EndAttemptInteraction(paragraph);
endAttemptInteraction.setResponseIdentifier(QTI21Constants.HINT_REQUEST_IDENTIFIER);
endAttemptInteraction.setTitle(hint.getTitle());
paragraph.getInlines().add(endAttemptInteraction);
// the feedback
ModalFeedback emptyModalFeedback = AssessmentItemFactory.createModalFeedback(assessmentItem, QTI21Constants.HINT_FEEDBACKMODAL_IDENTIFIER, QTI21Constants.HINT_IDENTIFIER, hint.getTitle(), hint.getText());
assessmentItem.getModalFeedbacks().add(emptyModalFeedback);
// the response processing
ResponseCondition rule = new ResponseCondition(assessmentItem.getResponseProcessing());
responseRules.add(0, rule);
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
/*
<responseIf>
<variable identifier="HINTREQUEST"/>
<setOutcomeValue identifier="FEEDBACK">
<baseValue baseType="identifier">HINT</baseValue>
</setOutcomeValue>
</responseIf>
*/
Variable variable = new Variable(responseIf);
variable.setIdentifier(QTI21Constants.HINT_REQUEST_CLX_IDENTIFIER);
responseIf.getExpressions().add(variable);
SetOutcomeValue hintVar = new SetOutcomeValue(responseIf);
hintVar.setIdentifier(QTI21Constants.HINT_FEEDBACKMODAL_IDENTIFIER);
BaseValue hintVal = new BaseValue(hintVar);
hintVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
hintVal.setSingleValue(new IdentifierValue(QTI21Constants.HINT));
hintVar.setExpression(hintVal);
responseIf.getResponseRules().add(hintVar);
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.
the class AssessmentItemBuilder method buildModalFeedbacksAndHints.
/**
* Add feedbackbasic and feedbackmodal outcomes
* @param outcomeDeclarations
* @param responseRules
*/
protected void buildModalFeedbacksAndHints(List<OutcomeDeclaration> outcomeDeclarations, List<ResponseRule> responseRules) {
if (correctFeedback != null || incorrectFeedback != null || emptyFeedback != null || answeredFeedback != null || correctSolutionFeedback != null || additionalFeedbacks.size() > 0) {
ensureFeedbackBasicOutcomeDeclaration();
OutcomeDeclaration modalOutcomeDeclaration = AssessmentItemFactory.createOutcomeDeclarationForFeedbackModal(assessmentItem);
outcomeDeclarations.add(modalOutcomeDeclaration);
List<ModalFeedback> modalFeedbacks = assessmentItem.getModalFeedbacks();
if (correctFeedback != null) {
appendModalFeedback(correctFeedback, QTI21Constants.CORRECT, modalFeedbacks, responseRules);
}
// correct solution must be set before the "incorrect" feedback
if (correctSolutionFeedback != null) {
OutcomeDeclaration correctSolutionOutcomeDeclaration = AssessmentItemFactory.createOutcomeDeclarationForCorrectSolutionFeedbackModal(assessmentItem);
outcomeDeclarations.add(correctSolutionOutcomeDeclaration);
}
if (incorrectFeedback != null || correctSolutionFeedback != null) {
appendCorrectSolutionAndIncorrectModalFeedback(modalFeedbacks, responseRules);
}
if (emptyFeedback != null) {
appendModalFeedback(emptyFeedback, QTI21Constants.EMPTY, modalFeedbacks, responseRules);
}
if (answeredFeedback != null) {
appendModalFeedback(answeredFeedback, QTI21Constants.ANSWERED, modalFeedbacks, responseRules);
}
if (additionalFeedbacks.size() > 0) {
for (ModalFeedbackBuilder feedback : additionalFeedbacks) {
appendAdditionalFeedback(feedback, modalFeedbacks, responseRules);
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.
the class AssessmentTestComponent method willShowFeedbacks.
/**
* Check if the assessment item will show some
* form of feedback like feedbackElement, modalFeedback
* or message as invalid or bad response.
*
* @param itemNode
* @return
*/
public boolean willShowFeedbacks(TestPlanNode itemNode) {
if (isHideFeedbacks()) {
return false;
}
try {
URI itemSystemId = itemNode.getItemSystemId();
ResolvedAssessmentItem resolvedAssessmentItem = getResolvedAssessmentTest().getResolvedAssessmentItemBySystemIdMap().get(itemSystemId);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
if (assessmentItem.getAdaptive()) {
return true;
}
ItemSessionState itemSessionState = getItemSessionState(itemNode.getKey());
if (!itemSessionState.isResponded()) {
return true;
}
ItemProcessingContext itemContext = getTestSessionController().getItemProcessingContext(itemNode);
if (itemContext instanceof ItemSessionController) {
ItemSessionController itemSessionController = (ItemSessionController) itemContext;
List<Interaction> interactions = itemSessionController.getInteractions();
for (Interaction interaction : interactions) {
if (AssessmentRenderFunctions.isBadResponse(itemSessionState, interaction.getResponseIdentifier())) {
return true;
}
if (AssessmentRenderFunctions.isInvalidResponse(itemSessionState, interaction.getResponseIdentifier())) {
return true;
}
}
}
if (assessmentItem.getItemBody().willShowFeedback(itemContext)) {
return true;
}
List<ModalFeedback> modalFeedbacks = assessmentItem.getModalFeedbacks();
for (ModalFeedback modalFeedback : modalFeedbacks) {
if (isFeedback(modalFeedback, itemSessionState)) {
return true;
}
}
} catch (Exception e) {
log.error("", e);
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.
the class AssessmentObjectComponentRenderer method renderTestItemModalFeedback.
protected void renderTestItemModalFeedback(AssessmentRenderer renderer, StringOutput sb, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, URLBuilder ubu, Translator translator) {
if (component.isHideFeedbacks())
return;
List<ModalFeedback> modalFeedbacks = new ArrayList<>();
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
for (ModalFeedback modalFeedback : assessmentItem.getModalFeedbacks()) {
if (component.isFeedback(modalFeedback, itemSessionState)) {
modalFeedbacks.add(modalFeedback);
}
}
if (modalFeedbacks.size() > 0) {
sb.append("<div class='modalFeedback'>");
for (ModalFeedback modalFeedback : modalFeedbacks) {
Identifier outcomeIdentifier = modalFeedback.getOutcomeIdentifier();
if (QTI21Constants.FEEDBACKMODAL_IDENTIFIER.equals(outcomeIdentifier)) {
renderTestItemModalFeedback_feedbackModal(renderer, sb, modalFeedback, component, resolvedAssessmentItem, itemSessionState, ubu, translator);
} else if (QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(outcomeIdentifier)) {
renderTestItemModalFeedback_correctSolution(renderer, sb, modalFeedback, component, resolvedAssessmentItem, itemSessionState, ubu, translator);
} else {
renderTestItemModalFeedback_standard(renderer, sb, modalFeedback, component, resolvedAssessmentItem, itemSessionState, ubu, translator);
}
}
sb.append("</div>");
}
}
Aggregations