Search in sources :

Example 16 with FieldValue

use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project openolat by klemens.

the class AssessmentItemFactory method appendAssociationKPrimResponseDeclaration.

public static ResponseDeclaration appendAssociationKPrimResponseDeclaration(ResponseDeclaration responseDeclaration, Map<Identifier, Identifier> associations, double maxScore) {
    responseDeclaration.setCardinality(Cardinality.MULTIPLE);
    responseDeclaration.setBaseType(BaseType.DIRECTED_PAIR);
    // correct response
    CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
    responseDeclaration.setCorrectResponse(correctResponse);
    for (Map.Entry<Identifier, Identifier> association : associations.entrySet()) {
        Identifier choiceId = association.getKey();
        Identifier correctwrongId = association.getValue();
        DirectedPairValue dpValue = new DirectedPairValue(choiceId, correctwrongId);
        FieldValue fValue = new FieldValue(correctResponse, dpValue);
        correctResponse.getFieldValues().add(fValue);
    }
    double mappedValue = maxScore;
    if (associations.size() > 0) {
        mappedValue = maxScore / associations.size();
    }
    // mapping
    Mapping mapping = new Mapping(responseDeclaration);
    mapping.setDefaultValue(-mappedValue);
    responseDeclaration.setMapping(mapping);
    for (Map.Entry<Identifier, Identifier> association : associations.entrySet()) {
        Identifier choiceId = association.getKey();
        Identifier correctwrongId = association.getValue();
        MapEntry mapEntry = new MapEntry(mapping);
        mapEntry.setMapKey(new DirectedPairValue(choiceId, correctwrongId));
        mapEntry.setMappedValue(mappedValue);
        mapping.getMapEntries().add(mapEntry);
    }
    return responseDeclaration;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) Map(java.util.Map)

Example 17 with FieldValue

use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project openolat by klemens.

the class AssessmentItemFactory method createOutcomeDeclarationForFeedbackBasic.

public static OutcomeDeclaration createOutcomeDeclarationForFeedbackBasic(AssessmentItem assessmentItem) {
    OutcomeDeclaration feedbackOutcomeDeclaration = new OutcomeDeclaration(assessmentItem);
    feedbackOutcomeDeclaration.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
    feedbackOutcomeDeclaration.setCardinality(Cardinality.SINGLE);
    feedbackOutcomeDeclaration.setBaseType(BaseType.IDENTIFIER);
    DefaultValue feedbackDefaultVal = new DefaultValue(feedbackOutcomeDeclaration);
    feedbackOutcomeDeclaration.setDefaultValue(feedbackDefaultVal);
    FieldValue feedbackDefaultFieldVal = new FieldValue(feedbackDefaultVal, new IdentifierValue("none"));
    feedbackDefaultVal.getFieldValues().add(feedbackDefaultFieldVal);
    List<View> views = new ArrayList<>();
    views.add(View.TEST_CONSTRUCTOR);
    feedbackOutcomeDeclaration.setViews(views);
    return feedbackOutcomeDeclaration;
}
Also used : DefaultValue(uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue) ArrayList(java.util.ArrayList) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration) View(uk.ac.ed.ph.jqtiplus.node.test.View)

Example 18 with FieldValue

use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project openolat by klemens.

the class AssessmentItemFactory method createOutcomeDeclarationForMinScore.

public static OutcomeDeclaration createOutcomeDeclarationForMinScore(AssessmentItem assessmentItem, double minScore) {
    OutcomeDeclaration maxScoreOutcomeDeclaration = new OutcomeDeclaration(assessmentItem);
    maxScoreOutcomeDeclaration.setIdentifier(QTI21Constants.MINSCORE_IDENTIFIER);
    maxScoreOutcomeDeclaration.setCardinality(Cardinality.SINGLE);
    maxScoreOutcomeDeclaration.setBaseType(BaseType.FLOAT);
    List<View> views = new ArrayList<>();
    views.add(View.TEST_CONSTRUCTOR);
    maxScoreOutcomeDeclaration.setViews(views);
    DefaultValue maxScoreDefaultVal = new DefaultValue(maxScoreOutcomeDeclaration);
    maxScoreOutcomeDeclaration.setDefaultValue(maxScoreDefaultVal);
    FieldValue maxScoreDefaultFieldVal = new FieldValue(maxScoreDefaultVal, new FloatValue(minScore));
    maxScoreDefaultVal.getFieldValues().add(maxScoreDefaultFieldVal);
    return maxScoreOutcomeDeclaration;
}
Also used : DefaultValue(uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue) ArrayList(java.util.ArrayList) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration) View(uk.ac.ed.ph.jqtiplus.node.test.View)

Example 19 with FieldValue

use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project openolat by klemens.

the class AssessmentItemFactory method createOutcomeDeclarationForMaxScore.

public static OutcomeDeclaration createOutcomeDeclarationForMaxScore(AssessmentItem assessmentItem, double maxScore) {
    OutcomeDeclaration maxScoreOutcomeDeclaration = new OutcomeDeclaration(assessmentItem);
    maxScoreOutcomeDeclaration.setIdentifier(QTI21Constants.MAXSCORE_IDENTIFIER);
    maxScoreOutcomeDeclaration.setCardinality(Cardinality.SINGLE);
    maxScoreOutcomeDeclaration.setBaseType(BaseType.FLOAT);
    DefaultValue maxScoreDefaultVal = new DefaultValue(maxScoreOutcomeDeclaration);
    maxScoreOutcomeDeclaration.setDefaultValue(maxScoreDefaultVal);
    FieldValue maxScoreDefaultFieldVal = new FieldValue(maxScoreDefaultVal, new FloatValue(maxScore));
    maxScoreDefaultVal.getFieldValues().add(maxScoreDefaultFieldVal);
    return maxScoreOutcomeDeclaration;
}
Also used : DefaultValue(uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 20 with FieldValue

use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project openolat by klemens.

the class AssessmentItemFactory method createOutcomeDeclarationForScore.

/**
 * Create an outcome declaration with SCORE as identifier, single and float
 * and 0 as default value.
 *
 * @param assessmentItem
 * @return
 */
public static OutcomeDeclaration createOutcomeDeclarationForScore(AssessmentItem assessmentItem) {
    OutcomeDeclaration scoreOutcomeDeclaration = new OutcomeDeclaration(assessmentItem);
    scoreOutcomeDeclaration.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
    scoreOutcomeDeclaration.setCardinality(Cardinality.SINGLE);
    scoreOutcomeDeclaration.setBaseType(BaseType.FLOAT);
    DefaultValue scoreDefaultVal = new DefaultValue(scoreOutcomeDeclaration);
    scoreOutcomeDeclaration.setDefaultValue(scoreDefaultVal);
    FieldValue scoreDefaultFieldVal = new FieldValue(scoreDefaultVal, FloatValue.ZERO);
    scoreDefaultVal.getFieldValues().add(scoreDefaultFieldVal);
    return scoreOutcomeDeclaration;
}
Also used : DefaultValue(uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Aggregations

FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)48 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)24 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)20 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)20 ArrayList (java.util.ArrayList)16 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)16 DefaultValue (uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue)16 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)16 OutcomeDeclaration (uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)14 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)14 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)12 Value (uk.ac.ed.ph.jqtiplus.value.Value)12 IntegerValue (uk.ac.ed.ph.jqtiplus.value.IntegerValue)10 MultipleValue (uk.ac.ed.ph.jqtiplus.value.MultipleValue)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 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)8 Map (java.util.Map)4 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)4