Search in sources :

Example 1 with Interaction

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

the class AssessmentTestHelper method needManualCorrection.

public static boolean needManualCorrection(AssessmentItemRef itemRef, ResolvedAssessmentTest resolvedAssessmentTest) {
    ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
    if (resolvedAssessmentItem != null && resolvedAssessmentItem.getItemLookup() != null && resolvedAssessmentItem.getItemLookup().getRootNodeHolder() != null) {
        AssessmentItem assessmentItem = resolvedAssessmentItem.getItemLookup().getRootNodeHolder().getRootNode();
        List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
        for (Interaction interaction : interactions) {
            if (interaction instanceof UploadInteraction || interaction instanceof DrawingInteraction || interaction instanceof ExtendedTextInteraction) {
                return true;
            }
        }
    }
    return false;
}
Also used : UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction)

Example 2 with Interaction

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

the class QTI21ArchiveFormat method writeHeaders_2.

private void writeHeaders_2(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    CellStyle headerStyle = workbook.getStyles().getHeaderStyle();
    // second header
    // reset column counter
    int col = 0;
    Row header2Row = exportSheet.newRow();
    String sequentialNumber = translator.translate("column.header.seqnum");
    header2Row.addCell(col++, sequentialNumber, headerStyle);
    if (anonymizerCallback != null) {
        col++;
    } else {
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            if (userPropertyHandler == null) {
                continue;
            }
            String header = translator.translate(userPropertyHandler.i18nFormElementLabelKey());
            header2Row.addCell(col++, header, headerStyle);
        }
        // add other user and session information
        header2Row.addCell(col++, translator.translate("column.header.homepage"), headerStyle);
    }
    // course node points and passed
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasScoreConfigured()) {
            header2Row.addCell(col++, translator.translate("archive.table.header.node.points"), headerStyle);
        }
        if (assessableCourseNode.hasPassedConfigured()) {
            header2Row.addCell(col++, translator.translate("archive.table.header.node.passed"), headerStyle);
        }
    }
    header2Row.addCell(col++, translator.translate("archive.table.header.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("archive.table.header.manual.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("archive.table.header.final.points"), headerStyle);
    header2Row.addCell(col++, translator.translate("column.header.passed"), headerStyle);
    if (anonymizerCallback == null) {
        header2Row.addCell(col++, translator.translate("column.header.date"), headerStyle);
    }
    header2Row.addCell(col++, translator.translate("column.header.duration"), headerStyle);
    List<AbstractInfos> infos = getItemInfos();
    for (int i = 0; i < infos.size(); i++) {
        AbstractInfos info = infos.get(i);
        if (info instanceof ItemInfos) {
            ItemInfos item = (ItemInfos) info;
            if (exportConfig.isResponseCols()) {
                List<Interaction> interactions = item.getInteractions();
                for (int j = 0; j < interactions.size(); j++) {
                    Interaction interaction = interactions.get(j);
                    col = interactionArchiveMap.get(interaction.getQtiClassName()).writeHeader2(item.getAssessmentItem(), interaction, i, j, header2Row, col, workbook);
                }
            }
            if (exportConfig.isPointCol()) {
                header2Row.addCell(col++, translator.translate("item.score"), headerStyle);
            }
            if (exportConfig.isCommentCol()) {
                header2Row.addCell(col++, translator.translate("item.comment"), headerStyle);
            }
            if (exportConfig.isTimeCols()) {
                if (anonymizerCallback == null) {
                    header2Row.addCell(col++, translator.translate("item.start"), headerStyle);
                }
                header2Row.addCell(col++, translator.translate("item.duration"), headerStyle);
            }
        } else if (numOfSections > 1 && info instanceof SectionInfos) {
            SectionInfos section = (SectionInfos) info;
            if (!section.getItemInfos().isEmpty()) {
                header2Row.addCell(col++, translator.translate("archive.table.header.points"), headerStyle);
            }
        }
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) CustomInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) SelectPointInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SelectPointInteraction) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) PositionObjectInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.PositionObjectInteraction) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) MediaInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MediaInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) CellStyle(org.olat.core.util.openxml.workbookstyle.CellStyle) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 3 with Interaction

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

the class AssessmentHtmlBuilderTest method filter_alt.

@Test
public void filter_alt() {
    String content = "<p>Test <textEntryInteraction responseIdentifier=\"RESPONSE_1\"/> </p>";
    AssessmentItem item = new AssessmentItem();
    ItemBody helper = new ItemBody(item);
    new AssessmentHtmlBuilder().appendHtml(helper, content);
    List<Interaction> interactions = helper.findInteractions();
    Assert.assertNotNull(interactions);
    Assert.assertEquals(1, interactions.size());
    Interaction interaction = interactions.get(0);
    Assert.assertTrue(interaction instanceof TextEntryInteraction);
    Assert.assertNotNull(interaction.getResponseIdentifier());
    Assert.assertEquals("RESPONSE_1", interaction.getResponseIdentifier().toString());
}
Also used : ItemBody(uk.ac.ed.ph.jqtiplus.node.content.ItemBody) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) Test(org.junit.Test)

Example 4 with Interaction

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

the class HottextAssessmentItemBuilderTest method readHottextAssessmentItem.

@Test
public void readHottextAssessmentItem() throws URISyntaxException {
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    URL itemUrl = AssessmentItemBuilderTest.class.getResource("resources/openolat/hottext-per-answer-11-4-0.xml");
    AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
    HottextAssessmentItemBuilder itemBuilder = new HottextAssessmentItemBuilder(assessmentItem, qtiSerializer);
    // basic check ChoiceInteraction
    AssessmentItem loadedItem = itemBuilder.getAssessmentItem();
    List<Interaction> interactions = loadedItem.getItemBody().findInteractions();
    Assert.assertNotNull(interactions);
    Assert.assertEquals(1, interactions.size());
    Assert.assertTrue(interactions.get(0) instanceof HottextInteraction);
    // hot texts
    Choice correct1 = itemBuilder.getChoice(Identifier.assumedLegal("htf9250a96f24bc8873c9cc54dfbaaaa"));
    Assert.assertTrue(itemBuilder.isCorrect(correct1));
    Choice correct2 = itemBuilder.getChoice(Identifier.assumedLegal("RESPONSE_3"));
    Assert.assertTrue(itemBuilder.isCorrect(correct2));
    Choice wrong1 = itemBuilder.getChoice(Identifier.assumedLegal("RESPONSE_2"));
    Assert.assertFalse(itemBuilder.isCorrect(wrong1));
    Choice wrong2 = itemBuilder.getChoice(Identifier.assumedLegal("RESPONSE_4"));
    Assert.assertFalse(itemBuilder.isCorrect(wrong2));
    // score
    Double maxScore = itemBuilder.getMaxScoreBuilder().getScore();
    Assert.assertEquals(3.0, maxScore.doubleValue(), 0.0001);
    Double minScore = itemBuilder.getMinScoreBuilder().getScore();
    Assert.assertEquals(0.0, minScore.doubleValue(), 0.0001);
    // per answer
    Assert.assertEquals(ScoreEvaluation.perAnswer, itemBuilder.getScoreEvaluationMode());
}
Also used : HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) JqtiExtensionManager(uk.ac.ed.ph.jqtiplus.JqtiExtensionManager) QtiSerializer(uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) URL(java.net.URL) Test(org.junit.Test)

Example 5 with Interaction

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

the class HottextAssessmentItemBuilderTest method readHottextAssessmentItem_allCorrectAnswers.

@Test
public void readHottextAssessmentItem_allCorrectAnswers() throws URISyntaxException {
    QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
    URL itemUrl = AssessmentItemBuilderTest.class.getResource("resources/openolat/hottext-score-all-11-4-0.xml");
    AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
    HottextAssessmentItemBuilder itemBuilder = new HottextAssessmentItemBuilder(assessmentItem, qtiSerializer);
    // basic check ChoiceInteraction
    AssessmentItem loadedItem = itemBuilder.getAssessmentItem();
    List<Interaction> interactions = loadedItem.getItemBody().findInteractions();
    Assert.assertNotNull(interactions);
    Assert.assertEquals(2, interactions.size());
    Assert.assertTrue(interactions.get(0) instanceof HottextInteraction);
    Assert.assertTrue(interactions.get(1) instanceof EndAttemptInteraction);
    // hot texts
    Choice correct1 = itemBuilder.getChoice(Identifier.assumedLegal("htebdb40344641dba115e3c8c6ce3926"));
    Assert.assertTrue(itemBuilder.isCorrect(correct1));
    Choice correct2 = itemBuilder.getChoice(Identifier.assumedLegal("ht103ce53892dea97613005a5ce76be31e"));
    Assert.assertTrue(itemBuilder.isCorrect(correct2));
    Choice wrong1 = itemBuilder.getChoice(Identifier.assumedLegal("hte11a51c3e3d86a5f7293da19a1a8700e"));
    Assert.assertFalse(itemBuilder.isCorrect(wrong1));
    // score
    Double maxScore = itemBuilder.getMaxScoreBuilder().getScore();
    Assert.assertEquals(2.0, maxScore.doubleValue(), 0.0001);
    Double minScore = itemBuilder.getMinScoreBuilder().getScore();
    Assert.assertEquals(0.0, minScore.doubleValue(), 0.0001);
    // per answer
    Assert.assertEquals(ScoreEvaluation.allCorrectAnswers, itemBuilder.getScoreEvaluationMode());
    // correct feedback
    ModalFeedbackBuilder correctFeedback = itemBuilder.getCorrectFeedback();
    Assert.assertNotNull(correctFeedback);
    Assert.assertNotNull(correctFeedback.getText());
    Assert.assertTrue(correctFeedback.getText().contains("You check the right answers"));
    // incorrect
    ModalFeedbackBuilder incorrectFeedback = itemBuilder.getIncorrectFeedback();
    Assert.assertNotNull(incorrectFeedback);
    Assert.assertNotNull(incorrectFeedback.getText());
    Assert.assertTrue(incorrectFeedback.getText().contains("Some of your anwsers are not the correct one."));
    // correct solution feedback
    ModalFeedbackBuilder correctSolutionFeedback = itemBuilder.getCorrectSolutionFeedback();
    Assert.assertNotNull(correctSolutionFeedback);
    Assert.assertNotNull(correctSolutionFeedback.getText());
    Assert.assertTrue(correctSolutionFeedback.getText().contains("A little hint towards the correct solution"));
    // hint
    ModalFeedbackBuilder hint = itemBuilder.getHint();
    Assert.assertNotNull(hint);
    Assert.assertNotNull(hint.getText());
    Assert.assertTrue(hint.getText().contains("This is an endAttemptInteraction"));
}
Also used : HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) JqtiExtensionManager(uk.ac.ed.ph.jqtiplus.JqtiExtensionManager) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) QtiSerializer(uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) URL(java.net.URL) Test(org.junit.Test)

Aggregations

Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)72 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)42 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)42 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)38 ExtendedTextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction)32 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)32 Test (org.junit.Test)28 HotspotInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction)28 TextEntryInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction)28 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)26 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)26 EndAttemptInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction)22 ArrayList (java.util.ArrayList)20 HottextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction)20 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)18 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)16 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)14 AssociateInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction)14 GapMatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction)14 GraphicAssociateInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction)14