Search in sources :

Example 1 with GapChoice

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

the class GapMatchInteractionArchive method writeInteractionData.

@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
    List<Gap> gaps = getGaps(interaction);
    if (gaps.size() > 0) {
        GapMatchInteraction gapMatchInteraction = (GapMatchInteraction) interaction;
        Set<String> correctAnswers = CorrectResponsesUtil.getCorrectDirectPairResponses(item, interaction, false);
        String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
        List<String> responses = CorrectResponsesUtil.parseResponses(stringuifiedResponse);
        for (Gap gap : gaps) {
            String gapIdentifier = gap.getIdentifier().toString();
            String gapResponse = null;
            for (String r : responses) {
                if (r.endsWith(gapIdentifier)) {
                    gapResponse = r;
                }
            }
            if (gapResponse != null) {
                String[] gapResponsePair = gapResponse.split(" ");
                if (gapResponsePair.length > 1) {
                    String gapResponseAssociation = gapResponsePair[0];
                    Identifier gapResponseIdentifier = Identifier.assumedLegal(gapResponseAssociation);
                    GapChoice choice = gapMatchInteraction.getGapChoice(gapResponseIdentifier);
                    String value = null;
                    if (choice != null) {
                        value = getTextContent(choice);
                    }
                    boolean correct = correctAnswers.contains(gapResponse);
                    if (correct) {
                        dataRow.addCell(col++, value, workbook.getStyles().getCorrectStyle());
                    } else {
                        dataRow.addCell(col++, value);
                    }
                } else {
                    col++;
                }
            } else {
                col++;
            }
        }
    } else {
        col++;
    }
    return col;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice)

Example 2 with GapChoice

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

the class GapMatchInteractionArchive method writeInteractionData.

@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
    List<Gap> gaps = getGaps(interaction);
    if (gaps.size() > 0) {
        GapMatchInteraction gapMatchInteraction = (GapMatchInteraction) interaction;
        Set<String> correctAnswers = CorrectResponsesUtil.getCorrectDirectPairResponses(item, interaction, false);
        String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
        List<String> responses = CorrectResponsesUtil.parseResponses(stringuifiedResponse);
        for (Gap gap : gaps) {
            String gapIdentifier = gap.getIdentifier().toString();
            String gapResponse = null;
            for (String r : responses) {
                if (r.endsWith(gapIdentifier)) {
                    gapResponse = r;
                }
            }
            if (gapResponse != null) {
                String[] gapResponsePair = gapResponse.split(" ");
                if (gapResponsePair.length > 1) {
                    String gapResponseAssociation = gapResponsePair[0];
                    Identifier gapResponseIdentifier = Identifier.assumedLegal(gapResponseAssociation);
                    GapChoice choice = gapMatchInteraction.getGapChoice(gapResponseIdentifier);
                    String value = null;
                    if (choice != null) {
                        value = getTextContent(choice);
                    }
                    boolean correct = correctAnswers.contains(gapResponse);
                    if (correct) {
                        dataRow.addCell(col++, value, workbook.getStyles().getCorrectStyle());
                    } else {
                        dataRow.addCell(col++, value);
                    }
                } else {
                    col++;
                }
            } else {
                col++;
            }
        }
    } else {
        col++;
    }
    return col;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice)

Example 3 with GapChoice

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

the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.

public List<GapChoice> getVisibleOrderedChoices(GapMatchInteraction interaction) {
    List<GapChoice> choices;
    if (interaction.getShuffle()) {
        // <xsl:variable name="shuffledChoiceOrders" select="$itemSessionState/qw:shuffledInteractionChoiceOrder"
        // as="element(qw:shuffledInteractionChoiceOrder)*"/>
        // <xsl:variable name="choiceSequence" as="xs:string?"
        // select="$shuffledChoiceOrders[@responseIdentifier=$interaction/@responseIdentifier]/@choiceSequence"/>
        List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
        choices = new ArrayList<>();
        for (Identifier choiceOrder : choiceOrders) {
            choices.add(interaction.getGapChoice(choiceOrder));
        }
    } else {
        choices = new ArrayList<>(interaction.getGapChoices());
    }
    return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
Also used : URLBuilder(org.olat.core.gui.render.URLBuilder) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) Map(java.util.Map) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) OLog(org.olat.core.logging.OLog) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Translator(org.olat.core.gui.translator.Translator) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) StringInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.StringInteraction) Value(uk.ac.ed.ph.jqtiplus.value.Value) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssociableHotspot(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.AssociableHotspot) Collectors(java.util.stream.Collectors) GapImg(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapImg) List(java.util.List) BlockStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.BlockStatic) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) AssessmentRenderFunctions.renderValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Settings(org.olat.core.helpers.Settings) Orientation(uk.ac.ed.ph.jqtiplus.value.Orientation) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) HashMap(java.util.HashMap) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) Prompt(uk.ac.ed.ph.jqtiplus.node.item.interaction.Prompt) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) ArrayList(java.util.ArrayList) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) Iterator(java.util.Iterator) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) IOException(java.io.IOException) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Shape(uk.ac.ed.ph.jqtiplus.node.expression.operator.Shape) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Tracing(org.olat.core.logging.Tracing) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) BodyElement(uk.ac.ed.ph.jqtiplus.node.content.BodyElement) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice)

Example 4 with GapChoice

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

the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.

public List<GapChoice> getVisibleOrderedChoices(GapMatchInteraction interaction) {
    List<GapChoice> choices;
    if (interaction.getShuffle()) {
        // <xsl:variable name="shuffledChoiceOrders" select="$itemSessionState/qw:shuffledInteractionChoiceOrder"
        // as="element(qw:shuffledInteractionChoiceOrder)*"/>
        // <xsl:variable name="choiceSequence" as="xs:string?"
        // select="$shuffledChoiceOrders[@responseIdentifier=$interaction/@responseIdentifier]/@choiceSequence"/>
        List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
        choices = new ArrayList<>();
        for (Identifier choiceOrder : choiceOrders) {
            choices.add(interaction.getGapChoice(choiceOrder));
        }
    } else {
        choices = new ArrayList<>(interaction.getGapChoices());
    }
    return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
Also used : URLBuilder(org.olat.core.gui.render.URLBuilder) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) Map(java.util.Map) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) OLog(org.olat.core.logging.OLog) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Translator(org.olat.core.gui.translator.Translator) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) StringInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.StringInteraction) Value(uk.ac.ed.ph.jqtiplus.value.Value) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssociableHotspot(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.AssociableHotspot) Collectors(java.util.stream.Collectors) GapImg(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapImg) List(java.util.List) BlockStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.BlockStatic) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) AssessmentRenderFunctions.renderValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Settings(org.olat.core.helpers.Settings) Orientation(uk.ac.ed.ph.jqtiplus.value.Orientation) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) HashMap(java.util.HashMap) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) Prompt(uk.ac.ed.ph.jqtiplus.node.item.interaction.Prompt) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) ArrayList(java.util.ArrayList) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) Iterator(java.util.Iterator) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) IOException(java.io.IOException) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Shape(uk.ac.ed.ph.jqtiplus.node.expression.operator.Shape) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Tracing(org.olat.core.logging.Tracing) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) BodyElement(uk.ac.ed.ph.jqtiplus.node.content.BodyElement) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice)

Aggregations

GapMatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction)4 GapChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice)4 Gap (uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap)4 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 FormJSHelper (org.olat.core.gui.components.form.flexible.impl.FormJSHelper)2 StringOutput (org.olat.core.gui.render.StringOutput)2 URLBuilder (org.olat.core.gui.render.URLBuilder)2 VelocityRenderDecorator (org.olat.core.gui.render.velocity.VelocityRenderDecorator)2 Translator (org.olat.core.gui.translator.Translator)2 Settings (org.olat.core.helpers.Settings)2 OLog (org.olat.core.logging.OLog)2 Tracing (org.olat.core.logging.Tracing)2 StringHelper (org.olat.core.util.StringHelper)2