use of uk.ac.ed.ph.jqtiplus.value.IdentifierValue in project openolat by klemens.
the class AssessmentRenderFunctionsTest method valueContains_orderedValues.
@Test
public void valueContains_orderedValues() {
Value identifierValues = OrderedValue.createOrderedValue(new IdentifierValue(Identifier.parseString("reference-id")), new IdentifierValue(Identifier.parseString("reference-id")));
Assert.assertTrue(AssessmentRenderFunctions.valueContains(identifierValues, Identifier.parseString("reference-id")));
Assert.assertFalse(AssessmentRenderFunctions.valueContains(identifierValues, Identifier.parseString("noid")));
}
use of uk.ac.ed.ph.jqtiplus.value.IdentifierValue in project openolat by klemens.
the class CorrectResponsesUtil method getCorrectIntegerResponses.
public static final List<Integer> getCorrectIntegerResponses(AssessmentItem assessmentItem, Interaction interaction) {
List<Integer> correctAnswers = new ArrayList<>(5);
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(interaction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
if (correctResponse.getCardinality().isOneOf(Cardinality.SINGLE)) {
List<FieldValue> values = correctResponse.getFieldValues();
Value value = FieldValue.computeValue(Cardinality.SINGLE, values);
if (value instanceof IntegerValue) {
IntegerValue identifierValue = (IntegerValue) value;
correctAnswers.add(identifierValue.intValue());
}
} else if (correctResponse.getCardinality().isOneOf(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 IntegerValue) {
IntegerValue identifierValue = (IntegerValue) value;
correctAnswers.add(identifierValue.intValue());
}
}
}
}
}
return correctAnswers;
}
use of uk.ac.ed.ph.jqtiplus.value.IdentifierValue in project OpenOLAT by OpenOLAT.
the class CorrectResponsesUtil method getCorrectIntegerResponses.
public static final List<Integer> getCorrectIntegerResponses(AssessmentItem assessmentItem, Interaction interaction) {
List<Integer> correctAnswers = new ArrayList<>(5);
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(interaction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
if (correctResponse.getCardinality().isOneOf(Cardinality.SINGLE)) {
List<FieldValue> values = correctResponse.getFieldValues();
Value value = FieldValue.computeValue(Cardinality.SINGLE, values);
if (value instanceof IntegerValue) {
IntegerValue identifierValue = (IntegerValue) value;
correctAnswers.add(identifierValue.intValue());
}
} else if (correctResponse.getCardinality().isOneOf(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 IntegerValue) {
IntegerValue identifierValue = (IntegerValue) value;
correctAnswers.add(identifierValue.intValue());
}
}
}
}
}
return correctAnswers;
}
use of uk.ac.ed.ph.jqtiplus.value.IdentifierValue in project OpenOLAT by OpenOLAT.
the class AssessmentObjectComponentRenderer method renderTestItemModalFeedback_feedbackModal.
/**
* Render the feedback modal generated by OpenOLAT editor.
*
* @param renderer
* @param sb
* @param modalFeedback
* @param component
* @param resolvedAssessmentItem
* @param itemSessionState
* @param ubu
* @param translator
*/
private void renderTestItemModalFeedback_feedbackModal(AssessmentRenderer renderer, StringOutput sb, ModalFeedback modalFeedback, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, URLBuilder ubu, Translator translator) {
sb.append("<div class='modalFeedback o_info clearfix");
Value feedbackBasic = itemSessionState.getOutcomeValue(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
if (feedbackBasic != null && feedbackBasic.hasBaseType(BaseType.IDENTIFIER) && feedbackBasic instanceof IdentifierValue) {
IdentifierValue identifierValue = (IdentifierValue) feedbackBasic;
if (AssessmentItemFactory.matchAdditionalFeedback(resolvedAssessmentItem.getRootNodeLookup().extractAssumingSuccessful(), modalFeedback)) {
sb.append(" o_additional_modal_feedback");
} else if (QTI21Constants.CORRECT_IDENTIFIER_VALUE.equals(identifierValue)) {
sb.append(" o_correct_modal_feedback");
} else if (QTI21Constants.INCORRECT_IDENTIFIER_VALUE.equals(identifierValue)) {
sb.append(" o_incorrect_modal_feedback");
} else if (QTI21Constants.EMPTY_IDENTIFIER_VALUE.equals(identifierValue)) {
sb.append(" o_empty_modal_feedback");
}
}
sb.append("'>");
Attribute<?> title = modalFeedback.getAttributes().get("title");
if (title != null && title.getValue() != null) {
String feedbackTitle = title.getValue().toString();
if (StringHelper.containsNonWhitespace(feedbackTitle)) {
sb.append("<h4>");
if (modalFeedback.getIdentifier() != null && QTI21Constants.HINT_IDENTIFIER.equals(modalFeedback.getIdentifier())) {
sb.append("<i class='o_icon o_icon_help'> </i> ");
}
sb.append(StringHelper.escapeHtml(feedbackTitle)).append("</h4>");
}
}
modalFeedback.getFlowStatics().forEach((flow) -> renderFlow(renderer, sb, component, resolvedAssessmentItem, itemSessionState, flow, ubu, translator));
sb.append("</div>");
}
use of uk.ac.ed.ph.jqtiplus.value.IdentifierValue in project OpenOLAT by OpenOLAT.
the class HotspotAssessmentItemBuilder method extractScoreEvaluationMode.
private void extractScoreEvaluationMode() {
boolean hasMapping = false;
if (hotspotInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hotspotInteraction.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;
}
Aggregations