Search in sources :

Example 11 with TextRun

use of uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun in project openolat by klemens.

the class AssessmentItemFactory method appendMatchInteractionForKPrim.

public static MatchInteraction appendMatchInteractionForKPrim(ItemBody itemBody, Identifier responseDeclarationId, String defaultAnswer) {
    MatchInteraction matchInteraction = new MatchInteraction(itemBody);
    matchInteraction.setResponseIdentifier(responseDeclarationId);
    matchInteraction.setMaxAssociations(4);
    matchInteraction.setShuffle(false);
    itemBody.getBlocks().add(matchInteraction);
    PromptGroup prompts = new PromptGroup(matchInteraction);
    matchInteraction.getNodeGroups().add(prompts);
    SimpleMatchSet questionMatchSet = new SimpleMatchSet(matchInteraction);
    matchInteraction.getSimpleMatchSets().add(questionMatchSet);
    String[] classic = new String[] { "a", "b", "c", "d" };
    for (int i = 0; i < 4; i++) {
        SimpleAssociableChoice correctChoice = new SimpleAssociableChoice(questionMatchSet);
        correctChoice.setMatchMax(1);
        correctChoice.setMatchMin(1);
        correctChoice.setIdentifier(IdentifierGenerator.newNumberAsIdentifier(classic[i]));
        P question = getParagraph(correctChoice, defaultAnswer + " " + classic[i]);
        correctChoice.getFlowStatics().add(question);
        questionMatchSet.getSimpleAssociableChoices().add(correctChoice);
    }
    SimpleMatchSet correctWrongMatchSet = new SimpleMatchSet(matchInteraction);
    matchInteraction.getSimpleMatchSets().add(correctWrongMatchSet);
    SimpleAssociableChoice correctChoice = new SimpleAssociableChoice(correctWrongMatchSet);
    correctChoice.setMatchMax(4);
    correctChoice.setFixed(Boolean.TRUE);
    correctChoice.setIdentifier(QTI21Constants.CORRECT_IDENTIFIER);
    correctChoice.getFlowStatics().add(new TextRun(correctChoice, "+"));
    correctWrongMatchSet.getSimpleAssociableChoices().add(correctChoice);
    SimpleAssociableChoice wrongChoice = new SimpleAssociableChoice(correctWrongMatchSet);
    wrongChoice.setMatchMax(4);
    wrongChoice.setFixed(Boolean.TRUE);
    wrongChoice.setIdentifier(QTI21Constants.WRONG_IDENTIFIER);
    wrongChoice.getFlowStatics().add(new TextRun(correctChoice, "-"));
    correctWrongMatchSet.getSimpleAssociableChoices().add(wrongChoice);
    return matchInteraction;
}
Also used : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) PromptGroup(uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)

Example 12 with TextRun

use of uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun in project openolat by klemens.

the class AssessmentItemFactory method appendHottext.

public static Hottext appendHottext(P parent, Identifier responseId, String text) {
    Hottext hottext = new Hottext(parent);
    hottext.setIdentifier(responseId);
    hottext.getInlineStatics().add(new TextRun(hottext, text));
    parent.getInlines().add(hottext);
    return hottext;
}
Also used : Hottext(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)

Example 13 with TextRun

use of uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun in project openolat by klemens.

the class AssessmentItemFactory method getParagraph.

public static P getParagraph(QtiNode parent, String content) {
    P paragraph = new P(parent);
    TextRun text = new TextRun(paragraph, content);
    paragraph.getInlines().add(text);
    return paragraph;
}
Also used : P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)

Example 14 with TextRun

use of uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun 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

TextRun (uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)14 P (uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P)10 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)6 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 AssessmentItemFactory.appendDefaultItemBody (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody)2 AssessmentItemFactory.appendHottextInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHottextInteraction)2 AssessmentItemFactory.createHottextCorrectResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)2 AssessmentItemFactory.createResponseProcessing (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createResponseProcessing)2 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