Search in sources :

Example 6 with P

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

the class AssessmentItemFactory method appendSimpleChoice.

public static SimpleChoice appendSimpleChoice(ChoiceInteraction choiceInteraction, String text, Identifier identifier) {
    SimpleChoice newChoice = new SimpleChoice(choiceInteraction);
    newChoice.setIdentifier(identifier);
    P firstChoiceText = AssessmentItemFactory.getParagraph(newChoice, text);
    newChoice.getFlowStatics().add(firstChoiceText);
    choiceInteraction.getNodeGroups().getSimpleChoiceGroup().getSimpleChoices().add(newChoice);
    return newChoice;
}
Also used : P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)

Example 7 with P

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

Example 8 with P

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

the class QTI12To21Converter method convertKPrim.

private AssessmentItemBuilder convertKPrim(Item item) {
    KPrimAssessmentItemBuilder itemBuilder = new KPrimAssessmentItemBuilder("Kprim", "New answer", qtiSerializer);
    convertItemBasics(item, itemBuilder);
    Question question = item.getQuestion();
    itemBuilder.setShuffle(question.isShuffle());
    List<Response> responses = question.getResponses();
    List<SimpleAssociableChoice> choices = itemBuilder.getKprimChoices();
    for (int i = 0; i < 4; i++) {
        Response response = responses.get(i);
        SimpleAssociableChoice choice = choices.get(i);
        String answer = response.getContent().renderAsHtmlForEditor();
        answer = blockedHtml(answer);
        if (StringHelper.isHtml(answer)) {
            htmlBuilder.appendHtml(choice, answer);
        } else {
            P firstChoiceText = AssessmentItemFactory.getParagraph(choice, answer);
            choice.getFlowStatics().clear();
            choice.getFlowStatics().add(firstChoiceText);
        }
        if (response.isCorrect()) {
            itemBuilder.setAssociation(choice.getIdentifier(), QTI21Constants.CORRECT_IDENTIFIER);
        } else {
            itemBuilder.setAssociation(choice.getIdentifier(), QTI21Constants.WRONG_IDENTIFIER);
        }
    }
    double score = question.getMaxValue();
    itemBuilder.setMinScore(0.0d);
    itemBuilder.setMaxScore(score);
    return itemBuilder;
}
Also used : FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) ChoiceResponse(org.olat.ims.qti.editor.beecom.objects.ChoiceResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question)

Example 9 with P

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

the class AssessmentItemFactory method createSimpleChoice.

public static SimpleChoice createSimpleChoice(ChoiceInteraction choiceInteraction, String text, String prefix) {
    SimpleChoice newChoice = new SimpleChoice(choiceInteraction);
    newChoice.setIdentifier(IdentifierGenerator.newAsIdentifier(prefix));
    P firstChoiceText = AssessmentItemFactory.getParagraph(newChoice, text);
    newChoice.getFlowStatics().add(firstChoiceText);
    return newChoice;
}
Also used : P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)

Example 10 with P

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

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