Search in sources :

Example 11 with CorrectResponse

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

the class FIBAssessmentItemBuilder method extractNumericalEntrySettings.

public static void extractNumericalEntrySettings(AssessmentItem item, NumericalEntry numericalEntry, ResponseDeclaration responseDeclaration, AtomicInteger countAlternatives, DoubleAdder mappedScore) {
    Double solution = null;
    CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
    if (correctResponse != null && correctResponse.getFieldValues().size() > 0) {
        List<FieldValue> fValues = correctResponse.getFieldValues();
        SingleValue sValue = fValues.get(0).getSingleValue();
        if (sValue instanceof FloatValue) {
            solution = ((FloatValue) sValue).doubleValue();
            numericalEntry.setSolution(solution);
        }
    }
    // search the equal
    List<ResponseRule> responseRules = item.getResponseProcessing().getResponseRules();
    a_a: for (ResponseRule responseRule : responseRules) {
        if (responseRule instanceof ResponseCondition) {
            ResponseCondition condition = (ResponseCondition) responseRule;
            ResponseIf responseIf = condition.getResponseIf();
            if (responseIf != null && responseIf.getExpressions().size() > 0) {
                // first is an and/equal/
                Expression potentialEqualOrAnd = responseIf.getExpressions().get(0);
                if (potentialEqualOrAnd instanceof And) {
                    And and = (And) potentialEqualOrAnd;
                    for (Expression potentialEqual : and.getExpressions()) {
                        if (potentialEqual instanceof Equal && potentialEqual.getExpressions().size() == 2 && extractNumericalEntrySettings(numericalEntry, (Equal) potentialEqual)) {
                            break a_a;
                        }
                    }
                } else if (potentialEqualOrAnd instanceof Equal) {
                    if (extractNumericalEntrySettings(numericalEntry, (Equal) potentialEqualOrAnd)) {
                        // find to score as outcome value
                        if (responseIf.getResponseRules() != null && responseIf.getResponseRules().size() == 1 && responseIf.getResponseRules().get(0) instanceof SetOutcomeValue) {
                            SetOutcomeValue outcomeValue = (SetOutcomeValue) responseIf.getResponseRules().get(0);
                            if (outcomeValue.getExpressions() != null && outcomeValue.getExpressions().size() == 1 && outcomeValue.getExpressions().get(0) instanceof BaseValue) {
                                BaseValue bValue = (BaseValue) outcomeValue.getExpressions().get(0);
                                SingleValue sValue = bValue.getSingleValue();
                                if (sValue instanceof FloatValue) {
                                    FloatValue fValue = (FloatValue) sValue;
                                    numericalEntry.setScore(fValue.doubleValue());
                                    mappedScore.add(fValue.doubleValue());
                                    countAlternatives.incrementAndGet();
                                }
                            }
                        }
                        break a_a;
                    }
                }
            }
        }
    }
    // toleranceMode cannot be empty
    if (numericalEntry.getToleranceMode() == null) {
        numericalEntry.setToleranceMode(ToleranceMode.EXACT);
    }
}
Also used : SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) ResponseRule(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseRule) Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) Equal(uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal) And(uk.ac.ed.ph.jqtiplus.node.expression.operator.And) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)

Example 12 with CorrectResponse

use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse 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 13 with CorrectResponse

use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse 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)

Example 14 with CorrectResponse

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

the class HotspotAssessmentItemBuilder method extractCorrectAnswers.

private void extractCorrectAnswers() {
    correctAnswers = new ArrayList<>(5);
    if (hotspotInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hotspotInteraction.getResponseIdentifier());
        if (responseDeclaration != null) {
            if (responseDeclaration.getCorrectResponse() != null) {
                CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
                extractIdentifiersFromCorrectResponse(correctResponse, correctAnswers);
            }
            cardinality = responseDeclaration.getCardinality();
        }
    }
}
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)

Example 15 with CorrectResponse

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

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)

Aggregations

CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)48 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)40 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)26 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)22 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)20 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)20 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)16 ArrayList (java.util.ArrayList)14 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)14 Value (uk.ac.ed.ph.jqtiplus.value.Value)14 MultipleValue (uk.ac.ed.ph.jqtiplus.value.MultipleValue)12 IntegerValue (uk.ac.ed.ph.jqtiplus.value.IntegerValue)10 OrderedValue (uk.ac.ed.ph.jqtiplus.value.OrderedValue)10 PairValue (uk.ac.ed.ph.jqtiplus.value.PairValue)10 PointValue (uk.ac.ed.ph.jqtiplus.value.PointValue)10 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)6 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)6 Mapping (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping)6 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)6 List (java.util.List)4