use of uk.ac.ed.ph.jqtiplus.value.SingleValue in project OpenOLAT by OpenOLAT.
the class KPrimAssessmentItemBuilder method extractCorrectResponse.
private void extractCorrectResponse() {
associations = new HashMap<>();
if (matchInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(matchInteraction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
List<FieldValue> values = correctResponse.getFieldValues();
for (FieldValue value : values) {
SingleValue sValue = value.getSingleValue();
if (sValue instanceof DirectedPairValue) {
DirectedPairValue dpValue = (DirectedPairValue) sValue;
Identifier sourceId = dpValue.sourceValue();
Identifier destinationId = dpValue.destValue();
associations.put(sourceId, destinationId);
}
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.value.SingleValue in project OpenOLAT by OpenOLAT.
the class SimpleChoiceAssessmentItemBuilder method extractScoreEvaluationMode.
private void extractScoreEvaluationMode() {
boolean hasMapping = false;
if (choiceInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(choiceInteraction.getResponseIdentifier());
if (responseDeclaration != null) {
Mapping mapping = responseDeclaration.getMapping();
hasMapping = (mapping != null && mapping.getMapEntries() != null && mapping.getMapEntries().size() > 0);
if (hasMapping) {
scoreMapping = new HashMap<>();
for (MapEntry entry : mapping.getMapEntries()) {
SingleValue sValue = entry.getMapKey();
if (sValue instanceof IdentifierValue) {
Identifier identifier = ((IdentifierValue) sValue).identifierValue();
scoreMapping.put(identifier, entry.getMappedValue());
}
}
}
}
}
scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
use of uk.ac.ed.ph.jqtiplus.value.SingleValue in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method findBaseValueInExpression.
public static boolean findBaseValueInExpression(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 (findBaseValueInExpression(childExpression, feedbackIdentifier)) {
return true;
}
}
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.value.SingleValue in project OpenOLAT by OpenOLAT.
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.SingleValue in project OpenOLAT by OpenOLAT.
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;
}
Aggregations