Search in sources :

Example 16 with ModalFeedback

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>");
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ArrayList(java.util.ArrayList) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)

Example 17 with ModalFeedback

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;
}
Also used : ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) ItemSessionController(uk.ac.ed.ph.jqtiplus.running.ItemSessionController) URI(java.net.URI) ItemProcessingContext(uk.ac.ed.ph.jqtiplus.running.ItemProcessingContext)

Example 18 with ModalFeedback

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>");
        }
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback)

Example 19 with ModalFeedback

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);
    }
}
Also used : ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback)

Example 20 with 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);
            }
        }
    }
}
Also used : ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Aggregations

ModalFeedback (uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback)30 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)10 ResponseCondition (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)8 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)6 OutcomeDeclaration (uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)6 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)6 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)4 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)4 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ModalFeedbackType (org.olat.ims.qti21.model.xml.ModalFeedbackBuilder.ModalFeedbackType)2 P (uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P)2 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)2 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)2 EndAttemptInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction)2 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)2 ResponseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf)2 ResponseProcessing (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing)2 ResponseRule (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseRule)2