Search in sources :

Example 6 with TextEntryInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction 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)

Example 7 with TextEntryInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction in project openolat by klemens.

the class QTI21StatisticsManagerImpl method getTextEntryInteractionsStatistic.

@Override
public List<AbstractTextEntryInteractionStatistics> getTextEntryInteractionsStatistic(String itemRefIdent, AssessmentItem item, List<TextEntryInteraction> interactions, QTI21StatisticSearchParams searchParams) {
    List<AbstractTextEntryInteractionStatistics> options = new ArrayList<>();
    Map<String, AbstractTextEntryInteractionStatistics> optionMap = new HashMap<>();
    for (TextEntryInteraction interaction : interactions) {
        Identifier responseIdentifier = interaction.getResponseIdentifier();
        ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
        if (responseDeclaration.hasBaseType(BaseType.STRING)) {
            TextEntryInteractionStatistics stats = getTextEntryInteractionSettings(responseIdentifier, responseDeclaration);
            optionMap.put(responseIdentifier.toString(), stats);
            options.add(stats);
        } else if (responseDeclaration.hasBaseType(BaseType.FLOAT)) {
            NumericalInputInteractionStatistics stats = getNumericalInputInteractionSettings(responseIdentifier, responseDeclaration, item);
            optionMap.put(responseIdentifier.toString(), stats);
            options.add(stats);
        }
    }
    for (TextEntryInteraction interaction : interactions) {
        String responseIdentifier = interaction.getResponseIdentifier().toString();
        List<RawData> datas = getRawDatas(itemRefIdent, responseIdentifier, searchParams);
        for (RawData data : datas) {
            Long count = data.getCount();
            if (count != null && count.longValue() > 0) {
                AbstractTextEntryInteractionStatistics stats = optionMap.get(responseIdentifier);
                String response = data.getStringuifiedResponse();
                if (response != null && response.length() >= 2 && response.startsWith("[") && response.endsWith("]")) {
                    response = response.substring(1, response.length() - 1);
                }
                if (stats.matchResponse(response)) {
                    stats.addCorrect(count.longValue());
                } else {
                    stats.addIncorrect(count.longValue());
                    stats.addWrongResponses(response);
                }
            }
        }
    }
    return options;
}
Also used : TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) NumericalInputInteractionStatistics(org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 8 with TextEntryInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction in project openolat by klemens.

the class TextEntryInteractionArchive method writeInteractionData.

@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
    String stringuifiedResponses = response == null ? null : response.getStringuifiedResponse();
    if (StringHelper.containsNonWhitespace(stringuifiedResponses)) {
        TextEntryInteraction textEntryInteraction = (TextEntryInteraction) interaction;
        AbstractEntry correctAnswers = CorrectResponsesUtil.getCorrectTextResponses(item, textEntryInteraction);
        stringuifiedResponses = CorrectResponsesUtil.stripResponse(stringuifiedResponses);
        boolean correct = correctAnswers.match(stringuifiedResponses);
        if (correct) {
            dataRow.addCell(col++, stringuifiedResponses, workbook.getStyles().getCorrectStyle());
        } else {
            dataRow.addCell(col++, stringuifiedResponses, null);
        }
    } else {
        col++;
    }
    return col;
}
Also used : AbstractEntry(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction)

Example 9 with TextEntryInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction in project openolat by klemens.

the class AssessmentItemBuilderTest method buildAssessmentItem_gap.

@Test
public void buildAssessmentItem_gap() throws IOException, URISyntaxException {
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    FIBAssessmentItemBuilder itemBuilder = new FIBAssessmentItemBuilder("Gap text", EntryType.text, qtiSerializer);
    if (build.booleanValue()) {
        itemBuilder.build();
    }
    AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
    ItemValidationResult itemResult = serializeAndReload(assessmentItem);
    AssessmentItem reloadedItem = itemResult.getResolvedAssessmentItem().getItemLookup().extractIfSuccessful();
    List<Interaction> interactions = reloadedItem.getItemBody().findInteractions();
    Assert.assertNotNull(interactions);
    Assert.assertEquals(1, interactions.size());
    Assert.assertTrue(interactions.get(0) instanceof TextEntryInteraction);
    TextEntryInteraction interaction = (TextEntryInteraction) interactions.get(0);
    Assert.assertNotNull(interaction.getResponseIdentifier());
    ResponseDeclaration responseDeclaration = reloadedItem.getResponseDeclaration(interaction.getResponseIdentifier());
    Assert.assertNotNull(responseDeclaration);
}
Also used : FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) JqtiExtensionManager(uk.ac.ed.ph.jqtiplus.JqtiExtensionManager) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) QtiSerializer(uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) ItemValidationResult(uk.ac.ed.ph.jqtiplus.validation.ItemValidationResult) Test(org.junit.Test)

Example 10 with TextEntryInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction in project OpenOLAT by OpenOLAT.

the class QTI21StatisticsManagerImpl method getTextEntryInteractionsStatistic.

@Override
public List<AbstractTextEntryInteractionStatistics> getTextEntryInteractionsStatistic(String itemRefIdent, AssessmentItem item, List<TextEntryInteraction> interactions, QTI21StatisticSearchParams searchParams) {
    List<AbstractTextEntryInteractionStatistics> options = new ArrayList<>();
    Map<String, AbstractTextEntryInteractionStatistics> optionMap = new HashMap<>();
    for (TextEntryInteraction interaction : interactions) {
        Identifier responseIdentifier = interaction.getResponseIdentifier();
        ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
        if (responseDeclaration.hasBaseType(BaseType.STRING)) {
            TextEntryInteractionStatistics stats = getTextEntryInteractionSettings(responseIdentifier, responseDeclaration);
            optionMap.put(responseIdentifier.toString(), stats);
            options.add(stats);
        } else if (responseDeclaration.hasBaseType(BaseType.FLOAT)) {
            NumericalInputInteractionStatistics stats = getNumericalInputInteractionSettings(responseIdentifier, responseDeclaration, item);
            optionMap.put(responseIdentifier.toString(), stats);
            options.add(stats);
        }
    }
    for (TextEntryInteraction interaction : interactions) {
        String responseIdentifier = interaction.getResponseIdentifier().toString();
        List<RawData> datas = getRawDatas(itemRefIdent, responseIdentifier, searchParams);
        for (RawData data : datas) {
            Long count = data.getCount();
            if (count != null && count.longValue() > 0) {
                AbstractTextEntryInteractionStatistics stats = optionMap.get(responseIdentifier);
                String response = data.getStringuifiedResponse();
                if (response != null && response.length() >= 2 && response.startsWith("[") && response.endsWith("]")) {
                    response = response.substring(1, response.length() - 1);
                }
                if (stats.matchResponse(response)) {
                    stats.addCorrect(count.longValue());
                } else {
                    stats.addIncorrect(count.longValue());
                    stats.addWrongResponses(response);
                }
            }
        }
    }
    return options;
}
Also used : TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) NumericalInputInteractionStatistics(org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Aggregations

TextEntryInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction)16 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)10 ArrayList (java.util.ArrayList)6 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)6 Test (org.junit.Test)4 AssessmentItemFactory.appendTextEntryInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendTextEntryInteraction)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)4 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)4 HotspotInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction)4 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)4 HashMap (java.util.HashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 DoubleAdder (java.util.concurrent.atomic.DoubleAdder)2 Component (org.olat.core.gui.components.Component)2 StatisticsComponent (org.olat.core.gui.components.chart.StatisticsComponent)2 Controller (org.olat.core.gui.control.Controller)2 BasicController (org.olat.core.gui.control.controller.BasicController)2 AbstractTextEntryInteractionStatistics (org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics)2 NumericalInputInteractionStatistics (org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics)2 TextEntryInteractionStatistics (org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics)2