Search in sources :

Example 11 with HotspotChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice in project openolat by klemens.

the class QTI21StatisticsManagerImpl method getHotspotInteractionStatistics.

@Override
public List<HotspotChoiceStatistics> getHotspotInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, HotspotInteraction hotspotInteraction, QTI21StatisticSearchParams searchParams) {
    List<RawData> results = getRawDatas(itemRefIdent, hotspotInteraction.getResponseIdentifier().toString(), searchParams);
    List<HotspotChoice> hotspotChoices = hotspotInteraction.getHotspotChoices();
    long[] counts = new long[hotspotChoices.size()];
    for (int i = counts.length; i-- > 0; ) {
        counts[i] = 0l;
    }
    for (RawData result : results) {
        Long numOfAnswers = result.getCount();
        ;
        if (numOfAnswers != null && numOfAnswers.longValue() > 0) {
            String stringuifiedResponse = result.getStringuifiedResponse();
            for (int i = hotspotChoices.size(); i-- > 0; ) {
                String identifier = hotspotChoices.get(i).getIdentifier().toString();
                if (stringuifiedResponse.contains(identifier)) {
                    counts[i] += numOfAnswers.longValue();
                }
            }
        }
    }
    List<HotspotChoiceStatistics> choicesStatistics = new ArrayList<>();
    for (int i = 0; i < hotspotChoices.size(); i++) {
        choicesStatistics.add(new HotspotChoiceStatistics(hotspotChoices.get(i), counts[i]));
    }
    return choicesStatistics;
}
Also used : HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) ArrayList(java.util.ArrayList) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)

Example 12 with HotspotChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice in project openolat by klemens.

the class GraphicOrderInteractionArchive method writeHeader2.

@Override
public int writeHeader2(AssessmentItem item, Interaction interaction, int itemNumber, int interactionNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
    GraphicOrderInteraction orderInteraction = (GraphicOrderInteraction) interaction;
    List<HotspotChoice> choices = orderInteraction.getHotspotChoices();
    if (choices.size() > 0) {
        for (int i = 0; i < choices.size(); i++) {
            String header = (itemNumber + 1) + "_GO" + i;
            dataRow.addCell(col++, header, workbook.getStyles().getHeaderStyle());
        }
    } else {
        col++;
    }
    return col;
}
Also used : GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)

Example 13 with HotspotChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice in project openolat by klemens.

the class GraphicOrderInteractionArchive method writeInteractionData.

@Override
public int writeInteractionData(AssessmentItem item, AssessmentResponse response, Interaction interaction, int itemNumber, Row dataRow, int col, OpenXMLWorkbook workbook) {
    GraphicOrderInteraction orderInteraction = (GraphicOrderInteraction) interaction;
    List<HotspotChoice> choices = orderInteraction.getHotspotChoices();
    if (choices.size() > 0) {
        String stringuifiedResponse = response == null ? null : response.getStringuifiedResponse();
        List<String> responses = CorrectResponsesUtil.parseResponses(stringuifiedResponse);
        List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectOrderedIdentifierResponses(item, interaction);
        for (int i = 0; i < choices.size(); i++) {
            String currentResponse = null;
            if (responses.size() > i) {
                currentResponse = responses.get(i);
            }
            String correctAnswer = null;
            if (correctAnswers.size() > i) {
                correctAnswer = correctAnswers.get(i).toString();
            }
            if (correctAnswer != null && correctAnswer.equals(currentResponse)) {
                dataRow.addCell(col++, currentResponse, workbook.getStyles().getCorrectStyle());
            } else {
                dataRow.addCell(col++, currentResponse, null);
            }
        }
    } else {
        col++;
    }
    return col;
}
Also used : GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)

Example 14 with HotspotChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice in project openolat by klemens.

the class HotspotChoiceScoreController method sync.

@Override
public void sync(UserRequest ureq, AssessmentItemBuilder assessmentItemBuilder) {
    if (itemBuilder == assessmentItemBuilder) {
        Set<Identifier> choiceIdentifiers = new HashSet<>();
        for (HotspotChoice choice : itemBuilder.getHotspotChoices()) {
            HotspotChoiceWrapper wrapper = getHotspotChoiceWrapper(choice);
            if (wrapper == null) {
                wrappers.add(createHotspotChoiceWrapper(choice));
            }
            choiceIdentifiers.add(choice.getIdentifier());
        }
        for (Iterator<HotspotChoiceWrapper> wrapperIt = wrappers.iterator(); wrapperIt.hasNext(); ) {
            HotspotChoiceWrapper wrapper = wrapperIt.next();
            if (!choiceIdentifiers.contains(wrapper.getChoice().getIdentifier())) {
                wrapperIt.remove();
            }
        }
        updateBackground();
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) HashSet(java.util.HashSet)

Example 15 with HotspotChoice

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice in project openolat by klemens.

the class HotspotEditorController method updateHotspotsPosition.

/**
 * If the image is too small, translate the hotspots to match
 * approximatively the new image.
 *
 * @param backgroundSize
 */
private void updateHotspotsPosition(Size backgroundSize) {
    if (backgroundSize == null || choiceWrappers.isEmpty())
        return;
    int width = backgroundSize.getWidth();
    int height = backgroundSize.getHeight();
    if (width <= 0 || height <= 0)
        return;
    for (HotspotWrapper wrapper : choiceWrappers) {
        HotspotChoice choice = wrapper.getChoice();
        if (choice != null) {
            if (Shape.CIRCLE.equals(choice.getShape())) {
                translateCircle(choice.getCoords(), width, height);
            } else if (Shape.RECT.equals(choice.getShape())) {
                translateRect(choice.getCoords(), width, height);
            }
        }
    }
}
Also used : HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)

Aggregations

HotspotChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)36 ArrayList (java.util.ArrayList)14 HotspotChoiceStatistics (org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)8 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)8 GraphicOrderInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction)6 BarSeries (org.olat.core.gui.components.chart.BarSeries)4 ResponseInfos (org.olat.ims.qti.statistics.ui.ResponseInfos)4 Series (org.olat.ims.qti.statistics.ui.Series)4 File (java.io.File)2 Path (java.nio.file.Path)2 HashSet (java.util.HashSet)2 Size (org.olat.core.commons.services.image.Size)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 ScoreBuilder (org.olat.ims.qti21.model.xml.ScoreBuilder)2 Object (uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object)2 HotspotInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction)2