use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.
the class MatchScoreController method sync.
private List<MatchWrapper> sync(SimpleMatchSet matchSet, List<MatchWrapper> wrappers) {
Map<Identifier, MatchWrapper> currentMapping = wrappers.stream().collect(Collectors.toMap(w -> w.getChoiceIdentifier(), w -> w));
List<MatchWrapper> newWrappers = new ArrayList<>();
List<SimpleAssociableChoice> choices = matchSet.getSimpleAssociableChoices();
for (SimpleAssociableChoice choice : choices) {
if (currentMapping.containsKey(choice.getIdentifier())) {
newWrappers.add(currentMapping.get(choice.getIdentifier()));
} else {
newWrappers.add(createMatchWrapper(choice));
}
}
return newWrappers;
}
use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.
the class SingleChoiceEditorController method updateCorrectAnswer.
private void updateCorrectAnswer(UserRequest ureq) {
String correctAnswer = ureq.getParameter("correct");
if (StringHelper.containsNonWhitespace(correctAnswer)) {
Identifier correctAnswerIdentifier = Identifier.parseString(correctAnswer);
itemBuilder.setCorrectAnswer(correctAnswerIdentifier);
}
}
use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.
the class AssessmentItemComponentRenderer method renderPrintedVariable.
@Override
protected void renderPrintedVariable(AssessmentRenderer renderer, StringOutput sb, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, PrintedVariable printedVar) {
Identifier identifier = printedVar.getIdentifier();
Value templateValue = itemSessionState.getTemplateValues().get(identifier);
Value outcomeValue = itemSessionState.getOutcomeValues().get(identifier);
sb.append("<span class='printedVariable'>");
if (outcomeValue != null) {
OutcomeDeclaration outcomeDeclaration = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful().getOutcomeDeclaration(identifier);
renderPrintedVariable(renderer, sb, printedVar, outcomeDeclaration, outcomeValue);
} else if (templateValue != null) {
TemplateDeclaration templateDeclaration = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful().getTemplateDeclaration(identifier);
renderPrintedVariable(renderer, sb, printedVar, templateDeclaration, templateValue);
} else {
sb.append("(variable ").append(identifier.toString()).append(" was not found)");
}
sb.append("</span>");
}
use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.
the class AssessmentObjectComponent method isFeedback.
public boolean isFeedback(ModalFeedback feedbackElement, ItemSessionState itemSessionState) {
Identifier outcomeIdentifier = feedbackElement.getOutcomeIdentifier();
Identifier identifier = feedbackElement.getIdentifier();
Value outcomeValue = itemSessionState.getOutcomeValues().get(outcomeIdentifier);
boolean identifierMatch = valueContains(outcomeValue, identifier);
return (identifierMatch && feedbackElement.getVisibilityMode() == VisibilityMode.SHOW_IF_MATCH) || (!identifierMatch && feedbackElement.getVisibilityMode() == VisibilityMode.HIDE_IF_MATCH);
}
use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.
the class HotspotAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.hotspot, title);
// define the response
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
Identifier correctResponseId = IdentifierGenerator.newNumberAsIdentifier("hc");
ResponseDeclaration responseDeclaration = createHotspotEntryResponseDeclarationSingle(assessmentItem, responseDeclarationId, correctResponseId);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
appendHotspotInteraction(itemBody, responseDeclarationId, correctResponseId);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
Aggregations