use of uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction in project openolat by klemens.
the class AbstractQtiWorksController method processResponse.
protected void processResponse(UserRequest ureq, FormItem source) {
Map<Identifier, ResponseInput> stringResponseMap = extractStringResponseData();
Map<Identifier, ResponseInput> fileResponseMap;
if (mainForm.isMultipartEnabled()) {
fileResponseMap = extractFileResponseData();
} else {
fileResponseMap = Collections.emptyMap();
}
if (source instanceof FormLink) {
FormLink button = (FormLink) source;
String cmd = button.getCmd();
if (cmd != null && cmd.startsWith("qtiworks_response_")) {
String responseIdentifierString = cmd.substring("qtiworks_response_".length());
String presentedFlag = "qtiworks_presented_".concat(responseIdentifierString);
if (mainForm.getRequestParameterSet().contains(presentedFlag)) {
Identifier responseIdentifier;
try {
responseIdentifier = getResponseIdentifierFromUniqueId(responseIdentifierString);
// Identifier.parseString(responseIdentifierString);
} catch (final QtiParseException e) {
throw new RuntimeException("Bad response identifier encoded in parameter " + cmd, e);
}
String[] responseValues;
if (button.getUserObject() instanceof EndAttemptInteraction) {
responseValues = new String[] { ((EndAttemptInteraction) button.getUserObject()).getTitle() };
} else {
responseValues = new String[] { "submit" };
}
StringInput stringResponseData = new StringInput(responseValues);
stringResponseMap.put(responseIdentifier, stringResponseData);
}
}
}
String candidateComment = extractComment();
fireResponse(ureq, source, stringResponseMap, fileResponseMap, candidateComment);
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction in project openolat by klemens.
the class QTI21AssessmentItemStatisticsController method initInteractionControllers.
private List<String> initInteractionControllers(UserRequest ureq, StatisticsItem itemStats) {
List<Interaction> interactions = item.getItemBody().findInteractions();
List<String> interactionIds = new ArrayList<>(interactions.size());
int counter = 0;
List<TextEntryInteraction> textEntryInteractions = new ArrayList<>();
for (Interaction interaction : interactions) {
if (interaction instanceof TextEntryInteraction) {
textEntryInteractions.add((TextEntryInteraction) interaction);
} else if (interaction instanceof EndAttemptInteraction) {
continue;
} else {
Component cmp = interactionControllerFactory(ureq, interaction, itemStats);
String componentId = "interaction" + counter++;
mainVC.put(componentId, cmp);
interactionIds.add(componentId);
}
}
if (textEntryInteractions.size() > 0) {
Controller interactionCtrl = new TextEntryInteractionsStatisticsController(ureq, getWindowControl(), itemRef, item, textEntryInteractions, resourceResult);
listenTo(interactionCtrl);
String componentId = "interaction" + counter++;
mainVC.put(componentId, interactionCtrl.getInitialComponent());
interactionIds.add(componentId);
}
return interactionIds;
}
Aggregations