Search in sources :

Example 1 with AreaMapEntry

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++;
}
Also used : AreaMapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.AreaMapEntry) PointValue(uk.ac.ed.ph.jqtiplus.value.PointValue) ArrayList(java.util.ArrayList)

Example 2 with AreaMapEntry

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++;
}
Also used : AreaMapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.AreaMapEntry) PointValue(uk.ac.ed.ph.jqtiplus.value.PointValue) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 AreaMapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.AreaMapEntry)2 PointValue (uk.ac.ed.ph.jqtiplus.value.PointValue)2