Search in sources :

Example 1 with InlineChoiceInteraction

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

the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.

/*
	  <xsl:function name="qw:get-visible-ordered-choices" as="element()*">
	    <xsl:param name="interaction" as="element()"/>
	    <xsl:param name="choices" as="element()*"/>
	    <xsl:variable name="orderedChoices" as="element()*">
	      <xsl:choose>
	        <xsl:when test="$interaction/@shuffle='true'">
	          <xsl:for-each select="qw:get-shuffled-choice-order($interaction)">
	            <xsl:sequence select="$choices[@identifier=current()]"/>
	          </xsl:for-each>
	        </xsl:when>
	        <xsl:otherwise>
	          <xsl:sequence select="$choices"/>
	        </xsl:otherwise>
	      </xsl:choose>
	    </xsl:variable>
	    <xsl:sequence select="qw:filter-visible($orderedChoices)"/>
	  </xsl:function>
	  */
public List<InlineChoice> getVisibleOrderedChoices(InlineChoiceInteraction interaction) {
    List<InlineChoice> 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.getInlineChoice(choiceOrder));
        }
    } else {
        choices = interaction.getInlineChoices();
    }
    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) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice)

Example 2 with InlineChoiceInteraction

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

the class InlineChoiceInteractionArchive method writeInteractionData.

@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
    InlineChoiceInteraction choiceInteraction = (InlineChoiceInteraction) interaction;
    List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(item, interaction);
    String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
    if (StringHelper.containsNonWhitespace(stringuifiedResponse)) {
        String inlineResponse = CorrectResponsesUtil.stripResponse(stringuifiedResponse);
        Identifier responseIdentifier = Identifier.assumedLegal(inlineResponse);
        boolean correct = false;
        for (Identifier correctAnswer : correctAnswers) {
            if (responseIdentifier.equals(correctAnswer)) {
                correct = true;
                break;
            }
        }
        InlineChoice selectedChoice = choiceInteraction.getInlineChoice(responseIdentifier);
        if (selectedChoice != null) {
            String value = getTextContent(selectedChoice);
            if (correct) {
                dataRow.addCell(col++, value, workbook.getStyles().getCorrectStyle());
            } else {
                dataRow.addCell(col++, value);
            }
        } else {
            col++;
        }
    } else {
        col++;
    }
    return col;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice)

Example 3 with InlineChoiceInteraction

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

the class InlineChoiceInteractionArchive method writeInteractionData.

@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
    InlineChoiceInteraction choiceInteraction = (InlineChoiceInteraction) interaction;
    List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(item, interaction);
    String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
    if (StringHelper.containsNonWhitespace(stringuifiedResponse)) {
        String inlineResponse = CorrectResponsesUtil.stripResponse(stringuifiedResponse);
        Identifier responseIdentifier = Identifier.assumedLegal(inlineResponse);
        boolean correct = false;
        for (Identifier correctAnswer : correctAnswers) {
            if (responseIdentifier.equals(correctAnswer)) {
                correct = true;
                break;
            }
        }
        InlineChoice selectedChoice = choiceInteraction.getInlineChoice(responseIdentifier);
        if (selectedChoice != null) {
            String value = getTextContent(selectedChoice);
            if (correct) {
                dataRow.addCell(col++, value, workbook.getStyles().getCorrectStyle());
            } else {
                dataRow.addCell(col++, value);
            }
        } else {
            col++;
        }
    } else {
        col++;
    }
    return col;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice)

Example 4 with InlineChoiceInteraction

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

the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.

/*
	  <xsl:function name="qw:get-visible-ordered-choices" as="element()*">
	    <xsl:param name="interaction" as="element()"/>
	    <xsl:param name="choices" as="element()*"/>
	    <xsl:variable name="orderedChoices" as="element()*">
	      <xsl:choose>
	        <xsl:when test="$interaction/@shuffle='true'">
	          <xsl:for-each select="qw:get-shuffled-choice-order($interaction)">
	            <xsl:sequence select="$choices[@identifier=current()]"/>
	          </xsl:for-each>
	        </xsl:when>
	        <xsl:otherwise>
	          <xsl:sequence select="$choices"/>
	        </xsl:otherwise>
	      </xsl:choose>
	    </xsl:variable>
	    <xsl:sequence select="qw:filter-visible($orderedChoices)"/>
	  </xsl:function>
	  */
public List<InlineChoice> getVisibleOrderedChoices(InlineChoiceInteraction interaction) {
    List<InlineChoice> 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.getInlineChoice(choiceOrder));
        }
    } else {
        choices = interaction.getInlineChoices();
    }
    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) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice)

Aggregations

InlineChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction)4 InlineChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice)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 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)2