Search in sources :

Example 6 with DefaultValue

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

the class AssessmentTestFactory method createOutcomeDeclaration.

public static OutcomeDeclaration createOutcomeDeclaration(AssessmentTest assessmentTest, Identifier identifier, boolean defaultValue) {
    OutcomeDeclaration outcomeDeclaration = new OutcomeDeclaration(assessmentTest);
    outcomeDeclaration.setIdentifier(identifier);
    outcomeDeclaration.setCardinality(Cardinality.SINGLE);
    outcomeDeclaration.setBaseType(BaseType.BOOLEAN);
    DefaultValue defaultVal = new DefaultValue(outcomeDeclaration);
    outcomeDeclaration.setDefaultValue(defaultVal);
    FieldValue fieldValue = new FieldValue(defaultVal);
    BooleanValue booleanValue = defaultValue ? BooleanValue.TRUE : BooleanValue.FALSE;
    fieldValue.setSingleValue(booleanValue);
    defaultVal.getFieldValues().add(fieldValue);
    return outcomeDeclaration;
}
Also used : DefaultValue(uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 7 with DefaultValue

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

the class AssessmentTestFactory method updateDefaultValue.

public static void updateDefaultValue(OutcomeDeclaration outcomeDeclaration, Double defaultValue) {
    outcomeDeclaration.setBaseType(BaseType.FLOAT);
    DefaultValue defaultVal = outcomeDeclaration.getDefaultValue();
    defaultVal.getFieldValues().clear();
    FieldValue fieldValue = new FieldValue(defaultVal);
    FloatValue identifierValue = new FloatValue(defaultValue);
    fieldValue.setSingleValue(identifierValue);
    defaultVal.getFieldValues().add(fieldValue);
}
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)

Example 8 with DefaultValue

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

the class AssessmentItemBuilder method extractMaxScore.

private void extractMaxScore() {
    OutcomeDeclaration outcomeDeclaration = assessmentItem.getOutcomeDeclaration(MAXSCORE_IDENTIFIER);
    if (outcomeDeclaration != null) {
        DefaultValue defaultValue = outcomeDeclaration.getDefaultValue();
        if (defaultValue != null) {
            Value maxScoreValue = defaultValue.evaluate();
            if (maxScoreValue instanceof FloatValue) {
                Double maxScore = new Double(((FloatValue) maxScoreValue).doubleValue());
                maxScoreBuilder = new ScoreBuilder(maxScore, outcomeDeclaration);
            }
        }
    }
}
Also used : DefaultValue(uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) DefaultValue(uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 9 with DefaultValue

use of uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue 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 10 with DefaultValue

use of uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue 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)

Aggregations

DefaultValue (uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue)20 OutcomeDeclaration (uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)18 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)16 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)12 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)6 ArrayList (java.util.ArrayList)4 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)4 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)4 View (uk.ac.ed.ph.jqtiplus.node.test.View)4 Value (uk.ac.ed.ph.jqtiplus.value.Value)4 BooleanValue (uk.ac.ed.ph.jqtiplus.value.BooleanValue)2