use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.
the class AssessmentObjectComponent method isFeedback.
// <xsl:variable name="identifierMatch" select="boolean(qw:value-contains(qw:get-outcome-value(@outcomeIdentifier), @identifier))" as="xs:boolean"/>
// <xsl:if test="($identifierMatch and @showHide='show') or (not($identifierMatch) and @showHide='hide')">
// <xsl:apply-templates/>
// </xsl:if>
public boolean isFeedback(FeedbackElement 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 klemens.
the class AssessmentObjectFormItem method extractStringResponseData.
protected Map<Identifier, StringResponseData> extractStringResponseData() {
final Map<Identifier, StringResponseData> responseMap = new HashMap<Identifier, StringResponseData>();
final Set<String> parameterNames = getRootForm().getRequestParameterSet();
for (final String name : parameterNames) {
if (name.startsWith("qtiworks_presented_")) {
final String responseIdentifierString = name.substring("qtiworks_presented_".length());
final Identifier responseIdentifier;
try {
responseIdentifier = Identifier.parseString(responseIdentifierString);
} catch (final QtiParseException e) {
// throw new BadResponseWebPayloadException("Bad response identifier encoded in parameter " + name, e);
throw new RuntimeException("Bad response identifier encoded in parameter " + name, e);
}
final String[] responseValues = getRootForm().getRequestParameterValues("qtiworks_response_" + responseIdentifierString);
final StringResponseData stringResponseData = new StringResponseData(responseValues);
responseMap.put(responseIdentifier, stringResponseData);
}
}
return responseMap;
}
use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.
the class AssessmentObjectVelocityRenderDecorator method getResponseValueForField.
public String getResponseValueForField(Value value, String field) {
String responseValue;
// for math entry interaction
if (value instanceof RecordValue) {
Identifier fieldIdentifier = Identifier.assumedLegal(field);
RecordValue recordValue = (RecordValue) value;
SingleValue sValue = recordValue.get(fieldIdentifier);
responseValue = sValue == null ? null : sValue.toQtiString();
} else {
responseValue = null;
}
return responseValue;
}
use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.
the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.
public List<SimpleAssociableChoice> getVisibleOrderedChoices(MatchInteraction interaction, int pos) {
try {
List<SimpleAssociableChoice> choices;
if (interaction.getShuffle()) {
List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
Map<Identifier, SimpleAssociableChoice> idTochoice = new HashMap<>();
List<SimpleAssociableChoice> allChoices = interaction.getSimpleMatchSets().get(pos).getSimpleAssociableChoices();
for (SimpleAssociableChoice allChoice : allChoices) {
idTochoice.put(allChoice.getIdentifier(), allChoice);
}
choices = new ArrayList<>();
for (Identifier choiceOrder : choiceOrders) {
SimpleAssociableChoice choice = idTochoice.get(choiceOrder);
if (choice != null) {
choices.add(choice);
}
}
} else {
choices = interaction.getSimpleMatchSets().get(pos).getSimpleAssociableChoices();
}
return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
} catch (Exception e) {
log.error("", e);
return null;
}
}
use of uk.ac.ed.ph.jqtiplus.types.Identifier in project openolat by klemens.
the class AssessmentRenderFunctions method testFeedbackVisible.
public static final boolean testFeedbackVisible(TestFeedback testFeedback, TestSessionState testSessionState) {
// <xsl:variable name="identifierMatch" select="boolean(qw:value-contains(qw:get-test-outcome-value(@outcomeIdentifier), @identifier))" as="xs:boolean"/>
Identifier outcomeIdentifier = testFeedback.getOutcomeIdentifier();
Value outcomeValue = testSessionState.getOutcomeValue(outcomeIdentifier);
boolean identifierMatch = valueContains(outcomeValue, testFeedback.getOutcomeValue());
// <xsl:if test="($identifierMatch and @showHide='show') or (not($identifierMatch) and @showHide='hide')">
if ((identifierMatch && testFeedback.getVisibilityMode() == VisibilityMode.SHOW_IF_MATCH) || (!identifierMatch && testFeedback.getVisibilityMode() == VisibilityMode.HIDE_IF_MATCH)) {
return true;
}
return false;
}
Aggregations