Search in sources :

Example 31 with FloatValue

use of uk.ac.ed.ph.jqtiplus.value.FloatValue in project openolat by klemens.

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)

Example 32 with FloatValue

use of uk.ac.ed.ph.jqtiplus.value.FloatValue in project openolat by klemens.

the class AssessmentItemFactory method appendFloatValue.

private static void appendFloatValue(CorrectResponse correctResponse, double response) {
    FieldValue fieldValue = new FieldValue(correctResponse);
    FloatValue identifierValue = new FloatValue(response);
    fieldValue.setSingleValue(identifierValue);
    correctResponse.getFieldValues().add(fieldValue);
}
Also used : FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue)

Example 33 with FloatValue

use of uk.ac.ed.ph.jqtiplus.value.FloatValue in project openolat by klemens.

the class AssessmentTestBuilder method buildCutValue.

/*	Passed
	<outcomeCondition>
		<outcomeIf>
			<gte>
				<sum>
					<testVariables variableIdentifier="SCORE" />
				</sum>
				<baseValue baseType="float">
					1
				</baseValue>
			</gte>
			<setOutcomeValue identifier="PASS">
				<baseValue baseType="boolean">
					true
				</baseValue>
			</setOutcomeValue>
		</outcomeIf>
		<outcomeElse>
			<setOutcomeValue identifier="PASS">
				<baseValue baseType="boolean">
					false
				</baseValue>
			</setOutcomeValue>
		</outcomeElse>
	</outcomeCondition>
	*/
private void buildCutValue() {
    if (cutValue != null) {
        OutcomeDeclaration passDeclaration = assessmentTest.getOutcomeDeclaration(QTI21Constants.PASS_IDENTIFIER);
        if (passDeclaration == null) {
            passDeclaration = AssessmentTestFactory.createOutcomeDeclaration(assessmentTest, QTI21Constants.PASS_IDENTIFIER, false);
            assessmentTest.getOutcomeDeclarations().add(passDeclaration);
        }
        boolean updated = false;
        if (cutValueRule != null && cutValueRule.getOutcomeIf().getExpressions().size() > 0) {
            Expression gte = cutValueRule.getOutcomeIf().getExpressions().get(0);
            if (gte.getExpressions().size() > 1) {
                Expression baseValue = gte.getExpressions().get(1);
                if (baseValue instanceof BaseValue) {
                    BaseValue value = (BaseValue) baseValue;
                    value.setSingleValue(new FloatValue(cutValue.doubleValue()));
                    updated = true;
                }
            }
        }
        if (!updated) {
            assessmentTest.getOutcomeProcessing().getOutcomeRules().remove(cutValueRule);
            cutValueRule = AssessmentTestFactory.createCutValueRule(assessmentTest, cutValue);
            assessmentTest.getOutcomeProcessing().getOutcomeRules().add(cutValueRule);
        }
    } else if (cutValueRule != null) {
        assessmentTest.getOutcomeProcessing().getOutcomeRules().remove(cutValueRule);
    }
}
Also used : Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 34 with FloatValue

use of uk.ac.ed.ph.jqtiplus.value.FloatValue in project openolat by klemens.

the class AssessmentTestFactory method createOutcomeDeclaration.

public static OutcomeDeclaration createOutcomeDeclaration(AssessmentTest assessmentTest, Identifier identifier, Double defaultValue) {
    OutcomeDeclaration outcomeDeclaration = new OutcomeDeclaration(assessmentTest);
    outcomeDeclaration.setIdentifier(identifier);
    outcomeDeclaration.setCardinality(Cardinality.SINGLE);
    outcomeDeclaration.setBaseType(BaseType.FLOAT);
    DefaultValue defaultVal = new DefaultValue(outcomeDeclaration);
    outcomeDeclaration.setDefaultValue(defaultVal);
    FieldValue fieldValue = new FieldValue(defaultVal);
    FloatValue identifierValue = new FloatValue(defaultValue);
    fieldValue.setSingleValue(identifierValue);
    defaultVal.getFieldValues().add(fieldValue);
    return outcomeDeclaration;
}
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 35 with FloatValue

use of uk.ac.ed.ph.jqtiplus.value.FloatValue in project openolat by klemens.

the class AssessmentTestFactory method createCutValueRule.

/*	Passed
	<outcomeCondition>
		<outcomeIf>
			<gte>
				<sum>
					<testVariables variableIdentifier="SCORE" />
				</sum>
				<baseValue baseType="float">
					1
				</baseValue>
			</gte>
			<setOutcomeValue identifier="PASS">
				<baseValue baseType="boolean">
					true
				</baseValue>
			</setOutcomeValue>
		</outcomeIf>
		<outcomeElse>
			<setOutcomeValue identifier="PASS">
				<baseValue baseType="boolean">
					false
				</baseValue>
			</setOutcomeValue>
		</outcomeElse>
	</outcomeCondition>
	*/
public static OutcomeCondition createCutValueRule(AssessmentTest assessmentTest, Double cutValue) {
    OutcomeCondition outcomeCondition = new OutcomeCondition(assessmentTest);
    // if
    {
        OutcomeIf outcomeIf = new OutcomeIf(outcomeCondition);
        outcomeCondition.setOutcomeIf(outcomeIf);
        Gte gte = new Gte(outcomeIf);
        outcomeIf.setExpression(gte);
        {
            appendSumOfTestVariables(gte);
            BaseValue passed = new BaseValue(gte);
            passed.setBaseTypeAttrValue(BaseType.FLOAT);
            passed.setSingleValue(new FloatValue(cutValue.floatValue()));
            gte.getExpressions().add(passed);
        }
        SetOutcomeValue passedOutcomeValue = new SetOutcomeValue(outcomeIf);
        passedOutcomeValue.setIdentifier(QTI21Constants.PASS_IDENTIFIER);
        outcomeIf.getOutcomeRules().add(passedOutcomeValue);
        BaseValue passed = new BaseValue(passedOutcomeValue);
        passed.setBaseTypeAttrValue(BaseType.BOOLEAN);
        passed.setSingleValue(BooleanValue.TRUE);
        passedOutcomeValue.setExpression(passed);
    }
    {
        // else
        OutcomeElse outcomeElse = new OutcomeElse(outcomeCondition);
        outcomeCondition.setOutcomeElse(outcomeElse);
        SetOutcomeValue notPassedOutcomeValue = new SetOutcomeValue(outcomeElse);
        notPassedOutcomeValue.setIdentifier(QTI21Constants.PASS_IDENTIFIER);
        outcomeElse.getOutcomeRules().add(notPassedOutcomeValue);
        BaseValue notPassed = new BaseValue(notPassedOutcomeValue);
        notPassed.setBaseTypeAttrValue(BaseType.BOOLEAN);
        notPassed.setSingleValue(BooleanValue.FALSE);
        notPassedOutcomeValue.setExpression(notPassed);
    }
    return outcomeCondition;
}
Also used : SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) OutcomeElse(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeElse) OutcomeIf(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeIf) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) OutcomeCondition(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition) Gte(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue)

Aggregations

FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)36 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)16 OutcomeDeclaration (uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)14 Value (uk.ac.ed.ph.jqtiplus.value.Value)14 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)12 DefaultValue (uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue)12 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)10 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)10 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)8 File (java.io.File)6 FileOutputStream (java.io.FileOutputStream)6 IOException (java.io.IOException)6 URISyntaxException (java.net.URISyntaxException)6 Test (org.junit.Test)6 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)6 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)6 Equal (uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal)6