Search in sources :

Example 1 with ListValue

use of uk.ac.ed.ph.jqtiplus.value.ListValue in project OpenOLAT by OpenOLAT.

the class AssessmentObjectVelocityRenderDecorator method getRespondedVisibleChoices.

/*
		<xsl:variable name="respondedChoiceIdentifiers" select="qw:extract-iterable-elements(qw:get-response-value(/, @responseIdentifier))" as="xs:string*"/>
        <xsl:variable name="unselectedVisibleChoices" select="$visibleOrderedChoices[not(@identifier = $respondedChoiceIdentifiers)]" as="element(qti:simpleChoice)*"/>
        
        <xsl:variable name="respondedVisibleChoices" as="element(qti:simpleChoice)*">
          <xsl:for-each select="$respondedChoiceIdentifiers">
            <xsl:sequence select="$thisInteraction/qti:simpleChoice[@identifier=current() and qw:is-visible(.)]"/>
          </xsl:for-each>
        </xsl:variable>
	 */
public OrderChoices getRespondedVisibleChoices(OrderInteraction interaction) {
    List<SimpleChoice> visibleChoices = getVisibleOrderedSimpleChoices(interaction);
    Value responseValue = getResponseValue(interaction.getResponseIdentifier());
    List<String> responseIdentifiers = new ArrayList<>();
    if (responseValue instanceof ListValue) {
        for (SingleValue singleValue : (ListValue) responseValue) {
            responseIdentifiers.add(singleValue.toQtiString());
        }
    }
    List<SimpleChoice> unselectedVisibleChoices = new ArrayList<>(visibleChoices);
    for (Iterator<SimpleChoice> it = unselectedVisibleChoices.iterator(); it.hasNext(); ) {
        SimpleChoice choice = it.next();
        if (responseIdentifiers.contains(choice.getIdentifier().toString())) {
            it.remove();
        }
    }
    List<SimpleChoice> respondedVisibleChoices = new ArrayList<>();
    for (String responseIdentifier : responseIdentifiers) {
        for (SimpleChoice visibleChoice : visibleChoices) {
            if (responseIdentifier.equals(visibleChoice.getIdentifier().toString())) {
                respondedVisibleChoices.add(visibleChoice);
            }
        }
    }
    return new OrderChoices(respondedVisibleChoices, unselectedVisibleChoices);
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) AssessmentRenderFunctions.renderValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) ArrayList(java.util.ArrayList)

Example 2 with ListValue

use of uk.ac.ed.ph.jqtiplus.value.ListValue in project openolat by klemens.

the class AssessmentObjectVelocityRenderDecorator method getRespondedVisibleChoices.

/*
		<xsl:variable name="respondedChoiceIdentifiers" select="qw:extract-iterable-elements(qw:get-response-value(/, @responseIdentifier))" as="xs:string*"/>
        <xsl:variable name="unselectedVisibleChoices" select="$visibleOrderedChoices[not(@identifier = $respondedChoiceIdentifiers)]" as="element(qti:simpleChoice)*"/>
        
        <xsl:variable name="respondedVisibleChoices" as="element(qti:simpleChoice)*">
          <xsl:for-each select="$respondedChoiceIdentifiers">
            <xsl:sequence select="$thisInteraction/qti:simpleChoice[@identifier=current() and qw:is-visible(.)]"/>
          </xsl:for-each>
        </xsl:variable>
	 */
public OrderChoices getRespondedVisibleChoices(OrderInteraction interaction) {
    List<SimpleChoice> visibleChoices = getVisibleOrderedSimpleChoices(interaction);
    Value responseValue = getResponseValue(interaction.getResponseIdentifier());
    List<String> responseIdentifiers = new ArrayList<>();
    if (responseValue instanceof ListValue) {
        for (SingleValue singleValue : (ListValue) responseValue) {
            responseIdentifiers.add(singleValue.toQtiString());
        }
    }
    List<SimpleChoice> unselectedVisibleChoices = new ArrayList<>(visibleChoices);
    for (Iterator<SimpleChoice> it = unselectedVisibleChoices.iterator(); it.hasNext(); ) {
        SimpleChoice choice = it.next();
        if (responseIdentifiers.contains(choice.getIdentifier().toString())) {
            it.remove();
        }
    }
    List<SimpleChoice> respondedVisibleChoices = new ArrayList<>();
    for (String responseIdentifier : responseIdentifiers) {
        for (SimpleChoice visibleChoice : visibleChoices) {
            if (responseIdentifier.equals(visibleChoice.getIdentifier().toString())) {
                respondedVisibleChoices.add(visibleChoice);
            }
        }
    }
    return new OrderChoices(respondedVisibleChoices, unselectedVisibleChoices);
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) AssessmentRenderFunctions.renderValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 AssessmentRenderFunctions.renderValue (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue)2 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)2 FileValue (uk.ac.ed.ph.jqtiplus.value.FileValue)2 ListValue (uk.ac.ed.ph.jqtiplus.value.ListValue)2 NullValue (uk.ac.ed.ph.jqtiplus.value.NullValue)2 RecordValue (uk.ac.ed.ph.jqtiplus.value.RecordValue)2 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)2 Value (uk.ac.ed.ph.jqtiplus.value.Value)2