Search in sources :

Example 1 with ForeignElement

use of uk.ac.ed.ph.jqtiplus.node.ForeignElement in project OpenOLAT by OpenOLAT.

the class AssessmentObjectComponentRenderer method renderMath.

protected void renderMath(AssessmentRenderer renderer, StringOutput out, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, QtiNode mathElement) {
    if (mathElement instanceof ForeignElement) {
        ForeignElement fElement = (ForeignElement) mathElement;
        boolean mi = fElement.getQtiClassName().equals("mi");
        boolean ci = fElement.getQtiClassName().equals("ci");
        if (ci || mi) {
            AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
            String text = contentAsString(fElement);
            Identifier identifier = Identifier.assumedLegal(text);
            Value templateValue = getTemplateValue(itemSessionState, text);
            Value outcomeValue = getOutcomeValue(itemSessionState, text);
            Value responseValue = getResponseValue(assessmentItem, itemSessionState, identifier, renderer.isSolutionMode());
            if (templateValue != null && isTemplateDeclarationAMathVariable(assessmentItem, text)) {
                if (ci) {
                    substituteCi(out, templateValue);
                } else if (mi) {
                    substituteMi(out, templateValue);
                }
            } else if (outcomeValue != null) {
                if (ci) {
                    substituteCi(out, outcomeValue);
                } else if (mi) {
                    substituteMi(out, outcomeValue);
                }
            } else if (responseValue != null) {
                if (ci) {
                    substituteCi(out, responseValue);
                } else if (mi) {
                    substituteMi(out, responseValue);
                }
            } else {
                renderStartHtmlTag(out, component, resolvedAssessmentItem, fElement, null);
                fElement.getChildren().forEach((child) -> renderMath(renderer, out, component, resolvedAssessmentItem, itemSessionState, child));
                renderEndTag(out, fElement);
            }
        } else {
            renderStartHtmlTag(out, component, resolvedAssessmentItem, fElement, null);
            fElement.getChildren().forEach((child) -> renderMath(renderer, out, component, resolvedAssessmentItem, itemSessionState, child));
            renderEndTag(out, fElement);
        }
    } else if (mathElement instanceof TextRun) {
        out.append(((TextRun) mathElement).getTextContent());
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ForeignElement(uk.ac.ed.ph.jqtiplus.node.ForeignElement) AssessmentRenderFunctions.getOutcomeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getOutcomeValue) AssessmentRenderFunctions.extractRecordFieldValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractRecordFieldValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) AssessmentRenderFunctions.getHtmlAttributeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getHtmlAttributeValue) AssessmentRenderFunctions.renderOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderOrderedCardinalityValue) AssessmentRenderFunctions.isMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMultipleCardinalityValue) AssessmentRenderFunctions.renderSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderSingleCardinalityValue) AssessmentRenderFunctions.renderMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderMultipleCardinalityValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) AssessmentRenderFunctions.getTemplateValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getTemplateValue) AssessmentRenderFunctions.renderRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderRecordCardinalityValue) AssessmentRenderFunctions.getResponseValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseValue) AssessmentRenderFunctions.isNullValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isNullValue) AssessmentRenderFunctions.isSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isSingleCardinalityValue) AssessmentRenderFunctions.isRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isRecordCardinalityValue) AssessmentRenderFunctions.isOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isOrderedCardinalityValue) AssessmentRenderFunctions.isMathsContentValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMathsContentValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)

Example 2 with ForeignElement

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

the class AssessmentObjectComponentRenderer method renderMath.

protected void renderMath(AssessmentRenderer renderer, StringOutput out, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, QtiNode mathElement) {
    if (mathElement instanceof ForeignElement) {
        ForeignElement fElement = (ForeignElement) mathElement;
        boolean mi = fElement.getQtiClassName().equals("mi");
        boolean ci = fElement.getQtiClassName().equals("ci");
        if (ci || mi) {
            AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
            String text = contentAsString(fElement);
            Identifier identifier = Identifier.assumedLegal(text);
            Value templateValue = getTemplateValue(itemSessionState, text);
            Value outcomeValue = getOutcomeValue(itemSessionState, text);
            Value responseValue = getResponseValue(assessmentItem, itemSessionState, identifier, renderer.isSolutionMode());
            if (templateValue != null && isTemplateDeclarationAMathVariable(assessmentItem, text)) {
                if (ci) {
                    substituteCi(out, templateValue);
                } else if (mi) {
                    substituteMi(out, templateValue);
                }
            } else if (outcomeValue != null) {
                if (ci) {
                    substituteCi(out, outcomeValue);
                } else if (mi) {
                    substituteMi(out, outcomeValue);
                }
            } else if (responseValue != null) {
                if (ci) {
                    substituteCi(out, responseValue);
                } else if (mi) {
                    substituteMi(out, responseValue);
                }
            } else {
                renderStartHtmlTag(out, component, resolvedAssessmentItem, fElement, null);
                fElement.getChildren().forEach((child) -> renderMath(renderer, out, component, resolvedAssessmentItem, itemSessionState, child));
                renderEndTag(out, fElement);
            }
        } else {
            renderStartHtmlTag(out, component, resolvedAssessmentItem, fElement, null);
            fElement.getChildren().forEach((child) -> renderMath(renderer, out, component, resolvedAssessmentItem, itemSessionState, child));
            renderEndTag(out, fElement);
        }
    } else if (mathElement instanceof TextRun) {
        out.append(((TextRun) mathElement).getTextContent());
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ForeignElement(uk.ac.ed.ph.jqtiplus.node.ForeignElement) AssessmentRenderFunctions.getOutcomeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getOutcomeValue) AssessmentRenderFunctions.extractRecordFieldValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractRecordFieldValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) AssessmentRenderFunctions.getHtmlAttributeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getHtmlAttributeValue) AssessmentRenderFunctions.renderOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderOrderedCardinalityValue) AssessmentRenderFunctions.isMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMultipleCardinalityValue) AssessmentRenderFunctions.renderSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderSingleCardinalityValue) AssessmentRenderFunctions.renderMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderMultipleCardinalityValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) AssessmentRenderFunctions.getTemplateValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getTemplateValue) AssessmentRenderFunctions.renderRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderRecordCardinalityValue) AssessmentRenderFunctions.getResponseValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseValue) AssessmentRenderFunctions.isNullValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isNullValue) AssessmentRenderFunctions.isSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isSingleCardinalityValue) AssessmentRenderFunctions.isRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isRecordCardinalityValue) AssessmentRenderFunctions.isOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isOrderedCardinalityValue) AssessmentRenderFunctions.isMathsContentValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMathsContentValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)

Aggregations

AssessmentRenderFunctions.contentAsString (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)2 AssessmentRenderFunctions.extractRecordFieldValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractRecordFieldValue)2 AssessmentRenderFunctions.getHtmlAttributeValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getHtmlAttributeValue)2 AssessmentRenderFunctions.getOutcomeValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getOutcomeValue)2 AssessmentRenderFunctions.getResponseValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseValue)2 AssessmentRenderFunctions.getTemplateValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getTemplateValue)2 AssessmentRenderFunctions.isMathsContentValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMathsContentValue)2 AssessmentRenderFunctions.isMultipleCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMultipleCardinalityValue)2 AssessmentRenderFunctions.isNullValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isNullValue)2 AssessmentRenderFunctions.isOrderedCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isOrderedCardinalityValue)2 AssessmentRenderFunctions.isRecordCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isRecordCardinalityValue)2 AssessmentRenderFunctions.isSingleCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isSingleCardinalityValue)2 AssessmentRenderFunctions.renderMultipleCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderMultipleCardinalityValue)2 AssessmentRenderFunctions.renderOrderedCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderOrderedCardinalityValue)2 AssessmentRenderFunctions.renderRecordCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderRecordCardinalityValue)2 AssessmentRenderFunctions.renderSingleCardinalityValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderSingleCardinalityValue)2 ForeignElement (uk.ac.ed.ph.jqtiplus.node.ForeignElement)2 TextRun (uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)2 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)2 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)2