use of uk.ac.ed.ph.jqtiplus.value.PointValue in project openolat by klemens.
the class CorrectResponsesUtil method parseResponses.
/**
* The method ignore the wrong formatted coordinates
* @param responses
* @return
*/
public static final List<PointValue> parseResponses(List<String> responses) {
List<PointValue> points = new ArrayList<>();
for (String response : responses) {
if (StringHelper.containsNonWhitespace(response)) {
try {
PointValue pointValue = PointValue.parseString(response);
points.add(pointValue);
} catch (Exception e) {
log.error("", e);
}
}
}
return points;
}
use of uk.ac.ed.ph.jqtiplus.value.PointValue in project OpenOLAT by OpenOLAT.
the class CorrectResponsesUtil method parseResponses.
/**
* The method ignore the wrong formatted coordinates
* @param responses
* @return
*/
public static final List<PointValue> parseResponses(List<String> responses) {
List<PointValue> points = new ArrayList<>();
for (String response : responses) {
if (StringHelper.containsNonWhitespace(response)) {
try {
PointValue pointValue = PointValue.parseString(response);
points.add(pointValue);
} catch (Exception e) {
log.error("", e);
}
}
}
return points;
}
use of uk.ac.ed.ph.jqtiplus.value.PointValue 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.value.PointValue 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