use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project OpenOLAT by OpenOLAT.
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>");
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class FeedbackResultComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
FeedbackResultComponent cmp = (FeedbackResultComponent) source;
ResolvedAssessmentItem resolvedAssessmentItem = cmp.getResolvedAssessmentItem();
ItemSessionState itemSessionState = cmp.getItemSessionState();
AssessmentRenderer assessmentRenderer = new AssessmentRenderer(renderer);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
for (ModalFeedback modalFeedback : assessmentItem.getModalFeedbacks()) {
Identifier outcomeIdentifier = modalFeedback.getOutcomeIdentifier();
if (QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(outcomeIdentifier)) {
sb.append("<div class='modalFeedback'>");
renderAssessmentItemCorrectSolutionModalFeedback(assessmentRenderer, sb, modalFeedback, cmp, resolvedAssessmentItem, itemSessionState, ubu, translator);
sb.append("</div>");
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project OpenOLAT by OpenOLAT.
the class LobAssessmentItemBuilder method appendCorrectSolutionAndIncorrectModalFeedback.
@Override
protected void appendCorrectSolutionAndIncorrectModalFeedback(List<ModalFeedback> modalFeedbacks, List<ResponseRule> responseRules) {
if (correctSolutionFeedback != null) {
ModalFeedback modalFeedback = AssessmentItemFactory.createModalFeedback(assessmentItem, QTI21Constants.CORRECT_SOLUTION_IDENTIFIER, correctSolutionFeedback.getIdentifier(), correctSolutionFeedback.getTitle(), correctSolutionFeedback.getText());
modalFeedbacks.add(modalFeedback);
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project OpenOLAT by OpenOLAT.
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);
}
}
}
}
Aggregations