Search in sources :

Example 1 with DefaultValue

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

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 2 with DefaultValue

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

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 3 with DefaultValue

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

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)

Example 4 with DefaultValue

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

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 5 with DefaultValue

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

the class AssessmentItemBuilder method extractMinScore.

private void extractMinScore() {
    OutcomeDeclaration outcomeDeclaration = assessmentItem.getOutcomeDeclaration(MINSCORE_IDENTIFIER);
    if (outcomeDeclaration != null) {
        DefaultValue defaultValue = outcomeDeclaration.getDefaultValue();
        if (defaultValue != null) {
            Value minScoreValue = defaultValue.evaluate();
            if (minScoreValue instanceof FloatValue) {
                Double minScore = new Double(((FloatValue) minScoreValue).doubleValue());
                minScoreBuilder = new ScoreBuilder(minScore, 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)

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