Search in sources :

Example 1 with P

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P 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 P

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P in project OpenOLAT by OpenOLAT.

the class MultipleChoiceEditorController method doAddSimpleChoice.

private void doAddSimpleChoice(UserRequest ureq) {
    ChoiceInteraction interaction = itemBuilder.getChoiceInteraction();
    SimpleChoice newChoice = new SimpleChoice(interaction);
    newChoice.setIdentifier(IdentifierGenerator.newAsIdentifier("mc"));
    P firstChoiceText = AssessmentItemFactory.getParagraph(newChoice, translate("new.answer"));
    newChoice.getFlowStatics().add(firstChoiceText);
    wrapAnswer(ureq, newChoice);
    flc.setDirty(true);
}
Also used : P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)

Example 3 with P

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P 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 4 with P

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method appendMatchInteraction.

public static MatchInteraction appendMatchInteraction(ItemBody itemBody, Identifier responseDeclarationId) {
    MatchInteraction matchInteraction = new MatchInteraction(itemBody);
    matchInteraction.setResponseIdentifier(responseDeclarationId);
    matchInteraction.setMaxAssociations(0);
    matchInteraction.setShuffle(false);
    itemBody.getBlocks().add(matchInteraction);
    PromptGroup prompts = new PromptGroup(matchInteraction);
    matchInteraction.getNodeGroups().add(prompts);
    SimpleMatchSet sourceMatchSet = new SimpleMatchSet(matchInteraction);
    matchInteraction.getSimpleMatchSets().add(sourceMatchSet);
    String[] sources = new String[] { "A", "B" };
    for (int i = 0; i < sources.length; i++) {
        SimpleAssociableChoice sourceChoice = new SimpleAssociableChoice(sourceMatchSet);
        sourceChoice.setMatchMax(0);
        sourceChoice.setMatchMin(0);
        sourceChoice.setIdentifier(IdentifierGenerator.newNumberAsIdentifier(sources[i]));
        P question = getParagraph(sourceChoice, sources[i]);
        sourceChoice.getFlowStatics().add(question);
        sourceMatchSet.getSimpleAssociableChoices().add(sourceChoice);
    }
    SimpleMatchSet targetMatchSet = new SimpleMatchSet(matchInteraction);
    matchInteraction.getSimpleMatchSets().add(targetMatchSet);
    String[] targets = new String[] { "M", "N" };
    for (int i = 0; i < targets.length; i++) {
        SimpleAssociableChoice targetChoice = new SimpleAssociableChoice(sourceMatchSet);
        targetChoice.setMatchMax(0);
        targetChoice.setMatchMin(0);
        targetChoice.setIdentifier(IdentifierGenerator.newNumberAsIdentifier(targets[i]));
        P question = getParagraph(targetChoice, targets[i]);
        targetChoice.getFlowStatics().add(question);
        targetMatchSet.getSimpleAssociableChoices().add(targetChoice);
    }
    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)

Example 5 with P

use of uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P 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)

Aggregations

P (uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P)28 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)12 TextRun (uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)10 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)8 PromptGroup (uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)4 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)4 SimpleMatchSet (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet)4 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)4 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)2 ChoiceResponse (org.olat.ims.qti.editor.beecom.objects.ChoiceResponse)2 EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)2 EssayResponse (org.olat.ims.qti.editor.beecom.objects.EssayResponse)2 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)2 Question (org.olat.ims.qti.editor.beecom.objects.Question)2 Response (org.olat.ims.qti.editor.beecom.objects.Response)2 AssessmentItemFactory.appendDefaultItemBody (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody)2