Search in sources :

Example 6 with GapMatchInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction 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)6 Gap (uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap)6 QtiNode (uk.ac.ed.ph.jqtiplus.node.QtiNode)4 GraphicGapMatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction)4 GapChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice)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