use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.AreaMapEntry in project OpenOLAT by OpenOLAT.
the class SelectPointInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
List<AreaMapEntry> areaMapEntries = getAreaMapEntries(item, interaction);
if (areaMapEntries.size() == 0) {
col++;
} else {
String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
List<String> responses = CorrectResponsesUtil.parseResponses(stringuifiedResponse);
List<PointValue> responsePoints = CorrectResponsesUtil.parseResponses(responses);
List<Integer> freeSlots = new ArrayList<>();
for (AreaMapEntry areaMapEntry : areaMapEntries) {
int[] coords = CorrectResponsesUtil.convertCoordinates(areaMapEntry.getCoordinates());
PointValue foundPoints = null;
for (PointValue responsePoint : responsePoints) {
if (areaMapEntry.getShape().isInside(coords, responsePoint)) {
foundPoints = responsePoint;
responsePoints.remove(responsePoint);
break;
}
}
if (foundPoints != null) {
dataRow.addCell(col++, foundPoints.toQtiString(), workbook.getStyles().getCorrectStyle());
} else {
freeSlots.add(new Integer(col));
dataRow.addCell(col++, "", null);
}
}
// fill the rest
for (PointValue responsePoint : responsePoints) {
if (freeSlots.size() > 0) {
Integer slot = freeSlots.get(0);
dataRow.addCell(slot, responsePoint.toQtiString(), null);
}
}
}
return col++;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.AreaMapEntry in project openolat by klemens.
the class SelectPointInteractionArchive method writeInteractionData.
@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
List<AreaMapEntry> areaMapEntries = getAreaMapEntries(item, interaction);
if (areaMapEntries.size() == 0) {
col++;
} else {
String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
List<String> responses = CorrectResponsesUtil.parseResponses(stringuifiedResponse);
List<PointValue> responsePoints = CorrectResponsesUtil.parseResponses(responses);
List<Integer> freeSlots = new ArrayList<>();
for (AreaMapEntry areaMapEntry : areaMapEntries) {
int[] coords = CorrectResponsesUtil.convertCoordinates(areaMapEntry.getCoordinates());
PointValue foundPoints = null;
for (PointValue responsePoint : responsePoints) {
if (areaMapEntry.getShape().isInside(coords, responsePoint)) {
foundPoints = responsePoint;
responsePoints.remove(responsePoint);
break;
}
}
if (foundPoints != null) {
dataRow.addCell(col++, foundPoints.toQtiString(), workbook.getStyles().getCorrectStyle());
} else {
freeSlots.add(new Integer(col));
dataRow.addCell(col++, "", null);
}
}
// fill the rest
for (PointValue responsePoint : responsePoints) {
if (freeSlots.size() > 0) {
Integer slot = freeSlots.get(0);
dataRow.addCell(slot, responsePoint.toQtiString(), null);
}
}
}
return col++;
}
Aggregations