Search in sources :

Example 51 with IdentifierValue

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

the class AssessmentItemFactory method appendMapping.

/*
	<mapping defaultValue="0">
		<mapEntry mapKey="idd072fa37-f4c3-4532-a2fb-4458fa23e919" mappedValue="2.0" />
		<mapEntry mapKey="ide18af420-393e-43dc-b194-7af94663b576" mappedValue="-0.5" />
		<mapEntry mapKey="id72eb2dda-4053-45ba-a9f8-cc101f3e3987" mappedValue="2.0" />
	</mapping>
	 */
public static Mapping appendMapping(ResponseDeclaration responseDeclaration, Map<Identifier, Double> map) {
    Mapping mapping = new Mapping(responseDeclaration);
    mapping.setDefaultValue(0d);
    responseDeclaration.setMapping(mapping);
    for (Map.Entry<Identifier, Double> entry : map.entrySet()) {
        MapEntry mapEntry = new MapEntry(mapping);
        mapEntry.setMapKey(new IdentifierValue(entry.getKey()));
        mapEntry.setMappedValue(entry.getValue());
        mapping.getMapEntries().add(mapEntry);
    }
    return mapping;
}
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) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) Map(java.util.Map)

Example 52 with IdentifierValue

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

the class AssessmentItemFactory method createCorrectSolutionModalFeedbackBasicRule.

/**
 * Generate the special case for "correct solution" feedback which is almost the same as
 * incorrect feedback.
 *
 * @param responseProcessing
 * @param feedbackIdentifier
 * @return
 */
public static ResponseCondition createCorrectSolutionModalFeedbackBasicRule(ResponseProcessing responseProcessing, Identifier correctSolutionFeedbackIdentifier, Identifier incorrectFeedbackIdentifier, boolean hint) {
    ResponseCondition rule = new ResponseCondition(responseProcessing);
    /*
		<responseIf>
			<and>
				<match>
					<baseValue baseType="identifier">incorrect</baseValue>
					<variable identifier="FEEDBACKBASIC" />
				</match>
			</and>
			<setOutcomeValue identifier="FEEDBACKMODAL">
				<multiple>
					<variable identifier="FEEDBACKMODAL" />
					<baseValue baseType="identifier">Feedback261171147</baseValue>
				</multiple>
			</setOutcomeValue>
			<setOutcomeValue identifier="SOLUTIONMODAL">
				<baseValue baseType="identifier">Feedback261171147</baseValue>
			</setOutcomeValue>
		</responseIf>
		*/
    ResponseIf responseIf = new ResponseIf(rule);
    rule.setResponseIf(responseIf);
    {
        // rule
        And and = new And(responseIf);
        responseIf.getExpressions().add(and);
        Match match = new Match(and);
        and.getExpressions().add(match);
        BaseValue feedbackVal = new BaseValue(match);
        feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        feedbackVal.setSingleValue(new IdentifierValue(QTI21Constants.INCORRECT));
        match.getExpressions().add(feedbackVal);
        Variable variable = new Variable(match);
        variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.FEEDBACKBASIC));
        match.getExpressions().add(variable);
        // not match the HINT
        if (hint) {
            IsNull isNull = new IsNull(and);
            and.getExpressions().add(isNull);
            Variable hintVar = new Variable(isNull);
            hintVar.setIdentifier(QTI21Constants.HINT_FEEDBACKMODAL_CLX_IDENTIFIER);
            isNull.getExpressions().add(hintVar);
        }
    }
    if (incorrectFeedbackIdentifier != null) {
        // outcome incorrect
        SetOutcomeValue feedbackVar = new SetOutcomeValue(responseIf);
        feedbackVar.setIdentifier(QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
        Multiple multiple = new Multiple(feedbackVar);
        feedbackVar.setExpression(multiple);
        Variable variable = new Variable(multiple);
        variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.FEEDBACKMODAL));
        multiple.getExpressions().add(variable);
        BaseValue feedbackVal = new BaseValue(feedbackVar);
        feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        feedbackVal.setSingleValue(new IdentifierValue(incorrectFeedbackIdentifier));
        multiple.getExpressions().add(feedbackVal);
        responseIf.getResponseRules().add(feedbackVar);
    }
    if (correctSolutionFeedbackIdentifier != null) {
        // outcome correct solution
        SetOutcomeValue feedbackVar = new SetOutcomeValue(responseIf);
        feedbackVar.setIdentifier(QTI21Constants.CORRECT_SOLUTION_IDENTIFIER);
        BaseValue feedbackVal = new BaseValue(feedbackVar);
        feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
        feedbackVal.setSingleValue(new IdentifierValue(correctSolutionFeedbackIdentifier));
        feedbackVar.getExpressions().add(feedbackVal);
        responseIf.getResponseRules().add(feedbackVar);
    }
    return rule;
}
Also used : Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) Multiple(uk.ac.ed.ph.jqtiplus.node.expression.operator.Multiple) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) And(uk.ac.ed.ph.jqtiplus.node.expression.operator.And) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) IsNull(uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Example 53 with IdentifierValue

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

the class QtiNodesExtractor method extractIdentifiersFromCorrectResponse.

public static void extractIdentifiersFromCorrectResponse(CorrectResponse correctResponse, List<Identifier> correctAnswers) {
    BaseTypeAndCardinality responseDeclaration = correctResponse.getParent();
    if (responseDeclaration.hasCardinality(Cardinality.MULTIPLE)) {
        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);
                }
            }
        }
    } else if (responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
        Value value = FieldValue.computeValue(Cardinality.SINGLE, correctResponse.getFieldValues());
        if (value instanceof IdentifierValue) {
            IdentifierValue identifierValue = (IdentifierValue) value;
            correctAnswers.add(identifierValue.identifierValue());
        }
    }
}
Also used : BaseTypeAndCardinality(uk.ac.ed.ph.jqtiplus.node.shared.BaseTypeAndCardinality) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) 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) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) 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) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue)

Example 54 with IdentifierValue

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

the class TestFeedbackBuilder method findFeedbackRuleInExpression.

private boolean findFeedbackRuleInExpression(Expression expression, Identifier feedbackIdentifier) {
    if (expression instanceof BaseValue) {
        BaseValue bValue = (BaseValue) expression;
        SingleValue sValue = bValue.getSingleValue();
        if (sValue instanceof IdentifierValue) {
            IdentifierValue iValue = (IdentifierValue) sValue;
            if (feedbackIdentifier.equals(iValue.identifierValue())) {
                return true;
            }
        }
    } else {
        List<Expression> childExpressions = expression.getExpressions();
        for (Expression childExpression : childExpressions) {
            if (findFeedbackRuleInExpression(childExpression, feedbackIdentifier)) {
                return true;
            }
        }
    }
    return false;
}
Also used : SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue)

Example 55 with IdentifierValue

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

the class AssessmentRenderFunctions method isVisible.

// <xsl:sequence select="boolean($element[$overrideTemplate
// or not(@templateIdentifier)
// or (qw:value-contains(qw:get-template-value(@templateIdentifier), @identifier) and not(@showHide='hide'))])"/>
public static boolean isVisible(Choice choice, ItemSessionState iSessionState) {
    if (choice.getTemplateIdentifier() == null)
        return true;
    Value templateValue = iSessionState.getTemplateValue(choice.getTemplateIdentifier());
    boolean visible = templateValue instanceof IdentifierValue && ((IdentifierValue) templateValue).identifierValue().equals(choice.getIdentifier()) && choice.getVisibilityMode() != VisibilityMode.HIDE_IF_MATCH;
    return visible;
}
Also used : DurationValue(uk.ac.ed.ph.jqtiplus.value.DurationValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) OrderedValue(uk.ac.ed.ph.jqtiplus.value.OrderedValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) StringValue(uk.ac.ed.ph.jqtiplus.value.StringValue) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue)

Aggregations

IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)56 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)26 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)24 Value (uk.ac.ed.ph.jqtiplus.value.Value)22 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)18 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)18 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)16 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)16 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)16 MultipleValue (uk.ac.ed.ph.jqtiplus.value.MultipleValue)16 IntegerValue (uk.ac.ed.ph.jqtiplus.value.IntegerValue)14 ResponseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf)12 OrderedValue (uk.ac.ed.ph.jqtiplus.value.OrderedValue)12 Match (uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)10 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)10 ResponseCondition (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)10 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 IsNull (uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull)8 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)8