Search in sources :

Example 1 with TextRun

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

the class AssessmentHtmlBuilderTest method serializer.

@Test
public void serializer() {
    AssessmentItem item = new AssessmentItem();
    SimpleChoice helper = new SimpleChoice(item);
    P p = new P(helper);
    TextRun text = new TextRun(p, "Hello world");
    p.getInlines().add(text);
    helper.getFlowStatics().add(p);
    String content = new AssessmentHtmlBuilder().flowStaticString(helper.getFlowStatics());
    Assert.assertTrue(content.contains(">Hello world<"));
}
Also used : P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun) Test(org.junit.Test)

Example 2 with TextRun

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

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 3 with TextRun

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

the class AssessmentItemFactory method appendTextEntryInteraction.

public static TextEntryInteraction appendTextEntryInteraction(ItemBody itemBody, Identifier responseDeclarationId) {
    P paragraph = new P(itemBody);
    TextRun text = new TextRun(paragraph, "New text");
    paragraph.getInlines().add(text);
    TextEntryInteraction textInteraction = new TextEntryInteraction(paragraph);
    textInteraction.setResponseIdentifier(responseDeclarationId);
    paragraph.getInlines().add(textInteraction);
    itemBody.getBlocks().add(paragraph);
    return textInteraction;
}
Also used : P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)

Example 4 with TextRun

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

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 5 with TextRun

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

the class HottextAssessmentItemBuilder method createAssessmentItem.

private static AssessmentItem createAssessmentItem(String title, String text, String hottext) {
    AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.hottext, title);
    // define correct answer
    Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
    Identifier correctResponseId = IdentifierGenerator.newAsIdentifier("ht");
    List<Identifier> correctResponseIds = new ArrayList<>();
    correctResponseIds.add(correctResponseId);
    ResponseDeclaration responseDeclaration = createHottextCorrectResponseDeclaration(assessmentItem, responseDeclarationId, correctResponseIds);
    assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
    // outcomes
    appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
    // the single choice interaction
    ItemBody itemBody = appendDefaultItemBody(assessmentItem);
    HottextInteraction hottextInteraction = appendHottextInteraction(itemBody, responseDeclarationId, 0);
    P p = new P(itemBody);
    p.getInlines().add(new TextRun(p, text));
    appendHottext(p, correctResponseId, hottext);
    hottextInteraction.getBlockStatics().add(p);
    // response processing
    ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
    assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
    return assessmentItem;
}
Also used : P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) AssessmentItemFactory.appendDefaultItemBody(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody) ItemBody(uk.ac.ed.ph.jqtiplus.node.content.ItemBody) ArrayList(java.util.ArrayList) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) AssessmentItemFactory.appendHottextInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHottextInteraction) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun) AssessmentItemFactory.createResponseProcessing(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createResponseProcessing) ResponseProcessing(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createHottextCorrectResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)

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