use of uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction in project openolat by klemens.
the class AssessmentItemFactory method appendTextEntryInteraction.
public static TextEntryInteraction appendTextEntryInteraction(ItemBody itemBody, Identifier responseDeclarationId) {
P paragraph = new P(itemBody);
TextRun text = new TextRun(paragraph, "New text");
paragraph.getInlines().add(text);
TextEntryInteraction textInteraction = new TextEntryInteraction(paragraph);
textInteraction.setResponseIdentifier(responseDeclarationId);
paragraph.getInlines().add(textInteraction);
itemBody.getBlocks().add(paragraph);
return textInteraction;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction in project openolat by klemens.
the class QTI21StatisticsManagerImpl method getTextEntryInteractionsStatistic.
@Override
public List<AbstractTextEntryInteractionStatistics> getTextEntryInteractionsStatistic(String itemRefIdent, AssessmentItem item, List<TextEntryInteraction> interactions, QTI21StatisticSearchParams searchParams) {
List<AbstractTextEntryInteractionStatistics> options = new ArrayList<>();
Map<String, AbstractTextEntryInteractionStatistics> optionMap = new HashMap<>();
for (TextEntryInteraction interaction : interactions) {
Identifier responseIdentifier = interaction.getResponseIdentifier();
ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
if (responseDeclaration.hasBaseType(BaseType.STRING)) {
TextEntryInteractionStatistics stats = getTextEntryInteractionSettings(responseIdentifier, responseDeclaration);
optionMap.put(responseIdentifier.toString(), stats);
options.add(stats);
} else if (responseDeclaration.hasBaseType(BaseType.FLOAT)) {
NumericalInputInteractionStatistics stats = getNumericalInputInteractionSettings(responseIdentifier, responseDeclaration, item);
optionMap.put(responseIdentifier.toString(), stats);
options.add(stats);
}
}
for (TextEntryInteraction interaction : interactions) {
String responseIdentifier = interaction.getResponseIdentifier().toString();
List<RawData> datas = getRawDatas(itemRefIdent, responseIdentifier, searchParams);
for (RawData data : datas) {
Long count = data.getCount();
if (count != null && count.longValue() > 0) {
AbstractTextEntryInteractionStatistics stats = optionMap.get(responseIdentifier);
String response = data.getStringuifiedResponse();
if (response != null && response.length() >= 2 && response.startsWith("[") && response.endsWith("]")) {
response = response.substring(1, response.length() - 1);
}
if (stats.matchResponse(response)) {
stats.addCorrect(count.longValue());
} else {
stats.addIncorrect(count.longValue());
stats.addWrongResponses(response);
}
}
}
}
return options;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction in project openolat by klemens.
the class TextEntryInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
String stringuifiedResponses = response == null ? null : response.getStringuifiedResponse();
if (StringHelper.containsNonWhitespace(stringuifiedResponses)) {
TextEntryInteraction textEntryInteraction = (TextEntryInteraction) interaction;
AbstractEntry correctAnswers = CorrectResponsesUtil.getCorrectTextResponses(item, textEntryInteraction);
stringuifiedResponses = CorrectResponsesUtil.stripResponse(stringuifiedResponses);
boolean correct = correctAnswers.match(stringuifiedResponses);
if (correct) {
dataRow.addCell(col++, stringuifiedResponses, workbook.getStyles().getCorrectStyle());
} else {
dataRow.addCell(col++, stringuifiedResponses, null);
}
} else {
col++;
}
return col;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction in project openolat by klemens.
the class AssessmentItemBuilderTest method buildAssessmentItem_gap.
@Test
public void buildAssessmentItem_gap() throws IOException, URISyntaxException {
QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
FIBAssessmentItemBuilder itemBuilder = new FIBAssessmentItemBuilder("Gap text", EntryType.text, qtiSerializer);
if (build.booleanValue()) {
itemBuilder.build();
}
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
ItemValidationResult itemResult = serializeAndReload(assessmentItem);
AssessmentItem reloadedItem = itemResult.getResolvedAssessmentItem().getItemLookup().extractIfSuccessful();
List<Interaction> interactions = reloadedItem.getItemBody().findInteractions();
Assert.assertNotNull(interactions);
Assert.assertEquals(1, interactions.size());
Assert.assertTrue(interactions.get(0) instanceof TextEntryInteraction);
TextEntryInteraction interaction = (TextEntryInteraction) interactions.get(0);
Assert.assertNotNull(interaction.getResponseIdentifier());
ResponseDeclaration responseDeclaration = reloadedItem.getResponseDeclaration(interaction.getResponseIdentifier());
Assert.assertNotNull(responseDeclaration);
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction in project OpenOLAT by OpenOLAT.
the class QTI21StatisticsManagerImpl method getTextEntryInteractionsStatistic.
@Override
public List<AbstractTextEntryInteractionStatistics> getTextEntryInteractionsStatistic(String itemRefIdent, AssessmentItem item, List<TextEntryInteraction> interactions, QTI21StatisticSearchParams searchParams) {
List<AbstractTextEntryInteractionStatistics> options = new ArrayList<>();
Map<String, AbstractTextEntryInteractionStatistics> optionMap = new HashMap<>();
for (TextEntryInteraction interaction : interactions) {
Identifier responseIdentifier = interaction.getResponseIdentifier();
ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
if (responseDeclaration.hasBaseType(BaseType.STRING)) {
TextEntryInteractionStatistics stats = getTextEntryInteractionSettings(responseIdentifier, responseDeclaration);
optionMap.put(responseIdentifier.toString(), stats);
options.add(stats);
} else if (responseDeclaration.hasBaseType(BaseType.FLOAT)) {
NumericalInputInteractionStatistics stats = getNumericalInputInteractionSettings(responseIdentifier, responseDeclaration, item);
optionMap.put(responseIdentifier.toString(), stats);
options.add(stats);
}
}
for (TextEntryInteraction interaction : interactions) {
String responseIdentifier = interaction.getResponseIdentifier().toString();
List<RawData> datas = getRawDatas(itemRefIdent, responseIdentifier, searchParams);
for (RawData data : datas) {
Long count = data.getCount();
if (count != null && count.longValue() > 0) {
AbstractTextEntryInteractionStatistics stats = optionMap.get(responseIdentifier);
String response = data.getStringuifiedResponse();
if (response != null && response.length() >= 2 && response.startsWith("[") && response.endsWith("]")) {
response = response.substring(1, response.length() - 1);
}
if (stats.matchResponse(response)) {
stats.addCorrect(count.longValue());
} else {
stats.addIncorrect(count.longValue());
stats.addWrongResponses(response);
}
}
}
}
return options;
}
Aggregations