Search in sources :

Example 1 with Gap

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

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

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

the class AssessmentObjectComponentRenderer method renderGap.

/*
	  <xsl:template match="qti:gap">
	    <xsl:variable name="gmi" select="ancestor::qti:gapMatchInteraction" as="element(qti:gapMatchInteraction)"/>
	    <xsl:variable name="gaps" select="$gmi//qti:gap" as="element(qti:gap)+"/>
	    <xsl:variable name="thisGap" select="." as="element(qti:gap)"/>
	    <span class="gap" id="qtiworks_id_{$gmi/@responseIdentifier}_{@identifier}">
	      <!-- (Print index of this gap wrt all gaps in the interaction) -->
	      GAP <xsl:value-of select="for $i in 1 to count($gaps) return
	        if ($gaps[$i]/@identifier = $thisGap/@identifier) then $i else ()"/>
	    </span>
	  </xsl:template>
	 */
private void renderGap(StringOutput sb, Gap gap, ItemSessionState itemSessionState, AssessmentObjectComponent component) {
    GapMatchInteraction interaction = null;
    for (QtiNode parentNode = gap.getParent(); parentNode.getParent() != null; parentNode = parentNode.getParent()) {
        if (parentNode instanceof GapMatchInteraction) {
            interaction = (GapMatchInteraction) parentNode;
            break;
        }
    }
    if (interaction != null) {
        List<Gap> gaps = QueryUtils.search(Gap.class, interaction.getBlockStatics());
        String responseUniqueId = component.getResponseUniqueIdentifier(itemSessionState, interaction);
        sb.append("<span class='gap' id=\"qtiworks_id_").append(responseUniqueId).append("_").append(gap.getIdentifier().toString()).append("\">");
        sb.append("GAP ").append(gaps.indexOf(gap));
        sb.append("</span>");
    }
}
Also used : GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Example 4 with Gap

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

the class AssessmentObjectComponentRenderer method renderGap.

/*
	  <xsl:template match="qti:gap">
	    <xsl:variable name="gmi" select="ancestor::qti:gapMatchInteraction" as="element(qti:gapMatchInteraction)"/>
	    <xsl:variable name="gaps" select="$gmi//qti:gap" as="element(qti:gap)+"/>
	    <xsl:variable name="thisGap" select="." as="element(qti:gap)"/>
	    <span class="gap" id="qtiworks_id_{$gmi/@responseIdentifier}_{@identifier}">
	      <!-- (Print index of this gap wrt all gaps in the interaction) -->
	      GAP <xsl:value-of select="for $i in 1 to count($gaps) return
	        if ($gaps[$i]/@identifier = $thisGap/@identifier) then $i else ()"/>
	    </span>
	  </xsl:template>
	 */
private void renderGap(StringOutput sb, Gap gap, ItemSessionState itemSessionState, AssessmentObjectComponent component) {
    GapMatchInteraction interaction = null;
    for (QtiNode parentNode = gap.getParent(); parentNode.getParent() != null; parentNode = parentNode.getParent()) {
        if (parentNode instanceof GapMatchInteraction) {
            interaction = (GapMatchInteraction) parentNode;
            break;
        }
    }
    if (interaction != null) {
        List<Gap> gaps = QueryUtils.search(Gap.class, interaction.getBlockStatics());
        String responseUniqueId = component.getResponseUniqueIdentifier(itemSessionState, interaction);
        sb.append("<span class='gap' id=\"qtiworks_id_").append(responseUniqueId).append("_").append(gap.getIdentifier().toString()).append("\">");
        sb.append("GAP ").append(gaps.indexOf(gap));
        sb.append("</span>");
    }
}
Also used : GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Aggregations

GapMatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction)4 Gap (uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap)4 AssessmentRenderFunctions.contentAsString (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)2 QtiNode (uk.ac.ed.ph.jqtiplus.node.QtiNode)2 GraphicGapMatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction)2 GapChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice)2 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)2