Search in sources :

Example 11 with ModalFeedback

use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.

the class AssessmentItemFactory method createModalFeedback.

public static ModalFeedback createModalFeedback(AssessmentItem assessmentItem, Identifier outcomeIdentifier, Identifier identifier, String title, String text) {
    /*
		<modalFeedback identifier="Feedback1041659806" outcomeIdentifier="FEEDBACKMODAL" showHide="show" title="Wrong answer">
			<p>Feedback answer</p>
		</modalFeedback>
		*/
    ModalFeedback modalFeedback = new ModalFeedback(assessmentItem);
    modalFeedback.setIdentifier(identifier);
    modalFeedback.setOutcomeIdentifier(outcomeIdentifier);
    modalFeedback.setVisibilityMode(VisibilityMode.parseVisibilityMode("show"));
    modalFeedback.getAttributes().getStringAttribute(ModalFeedback.ATTR_TITLE_NAME).setValue(title);
    new AssessmentHtmlBuilder().appendHtml(modalFeedback, text);
    return modalFeedback;
}
Also used : ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback)

Example 12 with ModalFeedback

use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.

the class AlienItemAnalyzer method checkFeedbackModalResponseProcessing.

private void checkFeedbackModalResponseProcessing(Report report) {
    if (report.getType() != QTI21QuestionType.unkown) {
        boolean allOk = true;
        List<ModalFeedback> feedbacks = item.getModalFeedbacks();
        for (ModalFeedback feedback : feedbacks) {
            ModalFeedbackBuilder feedbackBuilder = new ModalFeedbackBuilder(item, feedback);
            if (feedbackBuilder.isCorrectRule() || feedbackBuilder.isIncorrectRule()) {
            // ok
            } else if (feedbackBuilder.isCorrectSolutionRule() || (feedback.getOutcomeIdentifier() != null && QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(feedback.getOutcomeIdentifier()))) {
            // ok
            } else if (feedbackBuilder.isEmptyRule() || feedbackBuilder.isAnsweredRule() || feedbackBuilder.isHint()) {
            // ok
            } else {
                List<ModalFeedbackCondition> conditions = feedbackBuilder.getFeedbackConditons();
                if (conditions == null || conditions.isEmpty()) {
                    allOk &= false;
                }
            }
        }
        if (!allOk) {
            report.addWarning(ReportWarningEnum.unsupportedFeedbacks);
        }
    }
}
Also used : ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback)

Example 13 with ModalFeedback

use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.

the class AlienItemAnalyzer method checkFeedback.

private void checkFeedback(Report report) {
    if (item.getModalFeedbacks() != null && item.getModalFeedbacks().size() > 0) {
        Set<Identifier> outcomeIdentifiers = new HashSet<>();
        List<ModalFeedback> feedbacks = item.getModalFeedbacks();
        for (ModalFeedback feedback : feedbacks) {
            if (feedback.getOutcomeIdentifier() != null) {
                outcomeIdentifiers.add(feedback.getOutcomeIdentifier());
            }
        }
        if (outcomeIdentifiers.size() == 1) {
            if (outcomeIdentifiers.iterator().next().equals(QTI21Constants.FEEDBACKMODAL_IDENTIFIER)) {
                checkFeedbackModalResponseProcessing(report);
            } else {
                report.addWarning(ReportWarningEnum.alienFeedbacks);
            }
        } else {
            // Onyx and OpenOLAT only use one outcome identifier for the feedbacks
            // Taotesting use several different identifiers. And we don't
            // understand feedbacks without outcome identifiers
            report.addWarning(ReportWarningEnum.alienFeedbacks);
        }
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) HashSet(java.util.HashSet)

Example 14 with ModalFeedback

use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.

the class QTI21WordExport method renderCorrectSolutionForWord.

private static void renderCorrectSolutionForWord(AssessmentItem item, OpenXMLDocument document, Translator translator, AssessmentHtmlBuilder htmlBuilder) {
    List<ModalFeedback> feedbacks = item.getModalFeedbacks();
    if (feedbacks != null && feedbacks.size() > 0) {
        for (ModalFeedback feedback : feedbacks) {
            if (feedback.getOutcomeIdentifier() != null && QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(feedback.getOutcomeIdentifier())) {
                Attribute<?> title = feedback.getAttributes().get("title");
                String feedbackTitle = null;
                if (title != null && title.getValue() != null) {
                    feedbackTitle = title.getValue().toString();
                }
                if (!StringHelper.containsNonWhitespace(feedbackTitle)) {
                    feedbackTitle = translator.translate("correct.solution");
                }
                document.appendHeading2(feedbackTitle, null);
                String html = htmlBuilder.flowStaticString(feedback.getFlowStatics());
                document.appendHtmlText(html, true);
            }
        }
    }
}
Also used : ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback)

Example 15 with ModalFeedback

use of uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback in project openolat by klemens.

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)

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