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;
}
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;
}
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());
}
}
}
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;
}
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;
}
Aggregations