Search in sources :

Example 26 with ModalFeedback

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);
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)

Example 27 with ModalFeedback

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);
}
Also used : P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)

Example 28 with ModalFeedback

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

Example 29 with ModalFeedback

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;
}
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 30 with ModalFeedback

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>");
    }
}
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)

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