Search in sources :

Example 31 with ResponseDeclaration

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.

the class AssessmentObjectVelocityRenderDecorator method getSliderOptions.

/*
	<xsl:variable name="is-discrete" select="qw:get-response-declaration(/, @responseIdentifier)/@baseType='integer'" as="xs:boolean"/>
    <xsl:variable name="min" select="if ($is-discrete) then string(floor(@lowerBound)) else string(@lowerBound)" as="xs:string"/>
    <xsl:variable name="max" select="if ($is-discrete) then string(ceiling(@upperBound)) else string(@upperBound)" as="xs:string"/>
    <xsl:variable name="step" select="if (@step) then @step else if ($is-discrete) then '1' else '0.01'" as="xs:string"/>
    <xsl:value-of select="if (@reverse) then @reverse else 'false'"/>
    */
public SliderOptions getSliderOptions(SliderInteraction interaction) {
    ResponseDeclaration responseDeclaration = getResponseDeclaration(interaction.getResponseIdentifier());
    boolean discrete = responseDeclaration.hasBaseType(BaseType.INTEGER);
    boolean reverse = interaction.getReverse() == null ? false : interaction.getReverse().booleanValue();
    String step;
    if (interaction.getStep() != null) {
        step = Integer.toString(interaction.getStep().intValue());
    } else {
        step = discrete ? "1" : "0.01";
    }
    String min;
    String max;
    if (discrete) {
        min = Long.toString(java.lang.Math.round(java.lang.Math.floor(interaction.getLowerBound())));
        max = Long.toString(java.lang.Math.round(java.lang.Math.ceil(interaction.getUpperBound())));
    } else {
        min = Long.toString(java.lang.Math.round(interaction.getLowerBound()));
        max = Long.toString(java.lang.Math.round(interaction.getUpperBound()));
    }
    return new SliderOptions(discrete, reverse, min, max, step);
}
Also used : ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 32 with ResponseDeclaration

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.

the class AssessmentObjectVelocityRenderDecorator method isSingleChoice.

/**
 * Check the maxChoices and the cardinality
 * @param interaction
 * @return
 */
public boolean isSingleChoice(Interaction interaction) {
    if (interaction instanceof ChoiceInteraction) {
        ChoiceInteraction choiceInteraction = (ChoiceInteraction) interaction;
        boolean sc = choiceInteraction.getMaxChoices() == 1;
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(choiceInteraction.getResponseIdentifier());
        if (responseDeclaration != null && responseDeclaration.hasCardinality(Cardinality.MULTIPLE)) {
            return false;
        }
        return sc;
    } else if (interaction instanceof HottextInteraction) {
        HottextInteraction hottextInteraction = (HottextInteraction) interaction;
        boolean sc = hottextInteraction.getMaxChoices() == 1;
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hottextInteraction.getResponseIdentifier());
        if (responseDeclaration != null && responseDeclaration.hasCardinality(Cardinality.MULTIPLE)) {
            return false;
        }
        return sc;
    } else if (interaction instanceof HotspotInteraction) {
        HotspotInteraction hotspotInteraction = (HotspotInteraction) interaction;
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hotspotInteraction.getResponseIdentifier());
        if (responseDeclaration != null && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
            return true;
        }
        return false;
    }
    return false;
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 33 with ResponseDeclaration

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.

the class HottextAssessmentItemBuilder method extractCorrectAnswers.

private void extractCorrectAnswers() {
    correctAnswers = new ArrayList<>(5);
    if (hottextInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hottextInteraction.getResponseIdentifier());
        if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
            CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
            extractIdentifiersFromCorrectResponse(correctResponse, correctAnswers);
        }
    }
}
Also used : QtiNodesExtractor.extractIdentifiersFromCorrectResponse(org.olat.ims.qti21.model.xml.QtiNodesExtractor.extractIdentifiersFromCorrectResponse) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createHottextCorrectResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)

Example 34 with ResponseDeclaration

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.

the class HottextAssessmentItemBuilder method extractScoreEvaluationMode.

private void extractScoreEvaluationMode() {
    boolean hasMapping = false;
    if (hottextInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hottextInteraction.getResponseIdentifier());
        if (responseDeclaration != null) {
            Mapping mapping = responseDeclaration.getMapping();
            hasMapping = (mapping != null && mapping.getMapEntries() != null && mapping.getMapEntries().size() > 0);
            if (hasMapping) {
                scoreMapping = new HashMap<>();
                for (MapEntry entry : mapping.getMapEntries()) {
                    SingleValue sValue = entry.getMapKey();
                    if (sValue instanceof IdentifierValue) {
                        Identifier identifier = ((IdentifierValue) sValue).identifierValue();
                        scoreMapping.put(identifier, entry.getMappedValue());
                    }
                }
            }
        }
    }
    scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createHottextCorrectResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)

Example 35 with ResponseDeclaration

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.

the class MultipleChoiceAssessmentItemBuilder method extract.

@Override
public void extract() {
    super.extract();
    correctAnswers = new ArrayList<>(5);
    if (choiceInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(choiceInteraction.getResponseIdentifier());
        if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
            CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
            Value value = FieldValue.computeValue(Cardinality.MULTIPLE, correctResponse.getFieldValues());
            if (value instanceof MultipleValue) {
                MultipleValue multiValue = (MultipleValue) value;
                for (SingleValue sValue : multiValue.getAll()) {
                    if (sValue instanceof IdentifierValue) {
                        IdentifierValue identifierValue = (IdentifierValue) sValue;
                        Identifier correctAnswer = identifierValue.identifierValue();
                        correctAnswers.add(correctAnswer);
                    }
                }
            }
        }
    }
}
Also used : SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createMultipleChoiceCorrectResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMultipleChoiceCorrectResponseDeclaration)

Aggregations

ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)132 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)54 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)40 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)36 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)28 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)28 ResponseProcessing (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing)24 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)24 ArrayList (java.util.ArrayList)22 ItemBody (uk.ac.ed.ph.jqtiplus.node.content.ItemBody)22 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)22 AssessmentItemFactory.appendDefaultItemBody (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody)20 AssessmentItemFactory.createResponseProcessing (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createResponseProcessing)20 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)18 Value (uk.ac.ed.ph.jqtiplus.value.Value)16 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)14 HashMap (java.util.HashMap)12 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)12 MultipleValue (uk.ac.ed.ph.jqtiplus.value.MultipleValue)12 IntegerValue (uk.ac.ed.ph.jqtiplus.value.IntegerValue)10