Search in sources :

Example 61 with Interaction

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

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 62 with Interaction

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

the class QTI21ArchiveFormat method writeDataRow.

private void writeDataRow(int num, SessionResponses responses, OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    int col = 0;
    Row dataRow = exportSheet.newRow();
    // sequence number
    dataRow.addCell(col++, num, null);
    AssessmentTestSession testSession = responses.getTestSession();
    AssessmentEntry entry = testSession.getAssessmentEntry();
    Identity assessedIdentity = entry.getIdentity();
    // user properties
    if (assessedIdentity == null) {
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            if (userPropertyHandler != null) {
                if (userPropertyHandlers.get(0) == userPropertyHandler) {
                    dataRow.addCell(col++, translator.translate("anonym.user"), null);
                } else {
                    col++;
                }
            }
        }
    } else if (anonymizerCallback != null) {
        String anonymizedName = anonymizerCallback.getAnonymizedUserName(assessedIdentity);
        dataRow.addCell(col++, anonymizedName, null);
    } else {
        User assessedUser = assessedIdentity.getUser();
        for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
            if (userPropertyHandler != null) {
                String property = userPropertyHandler.getUserProperty(assessedUser, translator.getLocale());
                dataRow.addCell(col++, property, null);
            }
        }
    }
    // homepage
    if (anonymizerCallback == null) {
        String homepage;
        if (entry.getIdentity() == null) {
            homepage = "";
        } else {
            ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(entry.getIdentity());
            homepage = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
        }
        dataRow.addCell(col++, homepage, null);
    }
    // course node points and passed
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasScoreConfigured()) {
            if (entry.getScore() != null) {
                dataRow.addCell(col++, entry.getScore(), null);
            } else {
                col++;
            }
        }
        if (assessableCourseNode.hasPassedConfigured()) {
            if (entry.getPassed() != null) {
                dataRow.addCell(col++, entry.getPassed().toString(), null);
            } else {
                col++;
            }
        }
    }
    // assesspoints, passed, ipaddress, date, duration
    if (testSession.getScore() != null) {
        dataRow.addCell(col++, testSession.getScore(), null);
    } else {
        col++;
    }
    if (testSession.getManualScore() != null) {
        dataRow.addCell(col++, testSession.getManualScore(), null);
    } else {
        col++;
    }
    if (testSession.getFinalScore() != null) {
        dataRow.addCell(col++, testSession.getFinalScore(), null);
    } else {
        col++;
    }
    if (testSession.getPassed() != null) {
        dataRow.addCell(col++, testSession.getPassed().toString(), null);
    } else {
        col++;
    }
    if (anonymizerCallback == null) {
        dataRow.addCell(col++, testSession.getCreationDate(), workbook.getStyles().getDateStyle());
    }
    dataRow.addCell(col++, toDurationInMilliseconds(testSession.getDuration()), null);
    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;
            AssessmentItemRef itemRef = item.getAssessmentItemRef();
            String itemRefIdentifier = itemRef.getIdentifier().toString();
            AssessmentItemSession itemSession = responses.getItemSession(itemRefIdentifier);
            if (exportConfig.isResponseCols()) {
                List<Interaction> interactions = item.getInteractions();
                for (int j = 0; j < interactions.size(); j++) {
                    Interaction interaction = interactions.get(j);
                    AssessmentResponse response = responses.getResponse(itemRefIdentifier, interaction.getResponseIdentifier());
                    col = interactionArchiveMap.get(interaction.getQtiClassName()).writeInteractionData(item.getAssessmentItem(), response, interaction, j, dataRow, col, workbook);
                }
            }
            // score, start, duration
            if (itemSession == null) {
                if (exportConfig.isPointCol()) {
                    col++;
                }
                if (exportConfig.isCommentCol()) {
                    col++;
                }
                if (exportConfig.isTimeCols()) {
                    col += anonymizerCallback != null ? 1 : 2;
                }
            } else {
                if (exportConfig.isPointCol()) {
                    if (itemSession.getManualScore() != null) {
                        dataRow.addCell(col++, itemSession.getManualScore(), null);
                    } else {
                        dataRow.addCell(col++, itemSession.getScore(), null);
                    }
                }
                if (exportConfig.isCommentCol()) {
                    dataRow.addCell(col++, itemSession.getCoachComment(), null);
                }
                if (exportConfig.isTimeCols()) {
                    if (anonymizerCallback == null) {
                        dataRow.addCell(col++, itemSession.getCreationDate(), workbook.getStyles().getTimeStyle());
                    }
                    dataRow.addCell(col++, toDurationInMilliseconds(itemSession.getDuration()), null);
                }
            }
        } else if (numOfSections > 1 && info instanceof SectionInfos) {
            SectionInfos section = (SectionInfos) info;
            if (!section.getItemInfos().isEmpty()) {
                BigDecimal score = calculateSectionScore(responses, section);
                if (score != null) {
                    dataRow.addCell(col++, score, workbook.getStyles().getLightGrayStyle());
                } else {
                    col++;
                }
            }
        }
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) User(org.olat.core.id.User) 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) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) ContextEntry(org.olat.core.id.context.ContextEntry) BigDecimal(java.math.BigDecimal) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 63 with Interaction

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

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 64 with Interaction

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

the class FIBAssessmentItemBuilder method buildItemBody.

@Override
protected void buildItemBody() {
    // remove current blocks
    List<Block> blocks = assessmentItem.getItemBody().getBlocks();
    blocks.clear();
    // add question
    getHtmlHelper().appendHtml(assessmentItem.getItemBody(), question);
    // transfer text entry to the interactions
    List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
    List<String> usedResponseIdentifiers = new ArrayList<>(interactions.size());
    for (Interaction interaction : interactions) {
        if (interaction instanceof TextEntryInteraction && interaction.getResponseIdentifier() != null) {
            TextEntryInteraction textEntryInteraction = (TextEntryInteraction) interaction;
            String responseIdentifier = interaction.getResponseIdentifier().toString();
            AbstractEntry entry = responseIdentifierToTextEntry.get(responseIdentifier);
            if (entry != null) {
                textEntryInteraction.setPlaceholderText(entry.getPlaceholder());
                textEntryInteraction.setExpectedLength(entry.getExpectedLength());
            }
            usedResponseIdentifiers.add(responseIdentifier);
        }
    }
    List<String> mappedResponseIdentifiers = new ArrayList<>(responseIdentifierToTextEntry.keySet());
    mappedResponseIdentifiers.removeAll(usedResponseIdentifiers);
    for (String mappedResponseIdentifier : mappedResponseIdentifiers) {
        responseIdentifierToTextEntry.remove(mappedResponseIdentifier);
    }
}
Also used : AssessmentItemFactory.appendTextEntryInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendTextEntryInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) AssessmentItemFactory.appendTextEntryInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendTextEntryInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ArrayList(java.util.ArrayList) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block)

Example 65 with Interaction

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

the class FIBAssessmentItemBuilder method getOrderedTextEntries.

public List<AbstractEntry> getOrderedTextEntries() {
    List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
    List<AbstractEntry> entries = getTextEntries();
    List<AbstractEntry> orderedEntries = new ArrayList<>();
    for (Interaction interaction : interactions) {
        AbstractEntry entry = getTextEntry(interaction.getResponseIdentifier().toString());
        if (entry != null) {
            orderedEntries.add(entry);
            entries.remove(entry);
        }
    }
    if (entries.size() > 0) {
        // security
        orderedEntries.addAll(entries);
    }
    return orderedEntries;
}
Also used : AssessmentItemFactory.appendTextEntryInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendTextEntryInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ArrayList(java.util.ArrayList)

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