Search in sources :

Example 21 with HotspotChoice

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

the class HotspotInteractionStatisticsController method buildBubbleChart.

private HotspotBubbles buildBubbleChart(List<HotspotChoiceStatistics> statisticResponses) {
    List<HotspotBubble> bubbles = new ArrayList<>(statisticResponses.size());
    int count = 0;
    for (HotspotChoiceStatistics statisticResponse : statisticResponses) {
        HotspotChoice choice = statisticResponse.getChoice();
        bubbles.add(new HotspotBubble(Integer.toString(++count), choice.getShape(), choice.getCoords(), statisticResponse.getCount()));
    }
    return new HotspotBubbles(bubbles);
}
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 22 with HotspotChoice

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

the class HotspotInteractionStatisticsController method getMultipleChoice.

private Series getMultipleChoice(StatisticsItem itemStats, List<HotspotChoiceStatistics> statisticResponses) {
    BarSeries d1 = new BarSeries("bar_green", "green", translate("answer.correct"));
    BarSeries d2 = new BarSeries("bar_red", "red", translate("answer.false"));
    BarSeries d3 = new BarSeries("bar_grey", "grey", translate("answer.noanswer"));
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    int notAnswered = numOfParticipants - (itemStats == null ? 0 : itemStats.getNumOfResults());
    List<Identifier> correctAnswers = getCorrectResponses();
    int i = 0;
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (HotspotChoiceStatistics statisticResponse : statisticResponses) {
        HotspotChoice choice = statisticResponse.getChoice();
        String text = getAnswerText(choice);
        boolean correct = correctAnswers.contains(choice.getIdentifier());
        double answersPerAnswerOption = statisticResponse.getCount();
        double rightA;
        double wrongA;
        if (survey) {
            rightA = answersPerAnswerOption;
            wrongA = 0d;
        } else if (correct) {
            rightA = answersPerAnswerOption;
            wrongA = numOfParticipants - notAnswered - answersPerAnswerOption;
        } else {
            // minus negative points are not answered right?
            rightA = numOfParticipants - notAnswered - answersPerAnswerOption;
            wrongA = answersPerAnswerOption;
        }
        String label = Integer.toString(++i);
        d1.add(rightA, label);
        d2.add(wrongA, label);
        d3.add(notAnswered, label);
        Float pointsObj = survey ? null : (correct ? 1.0f : 0.0f);
        responseInfos.add(new ResponseInfos(label, text, pointsObj, correct, survey, false));
    }
    List<BarSeries> serieList = new ArrayList<>(3);
    serieList.add(d1);
    if (!survey) {
        serieList.add(d2);
        serieList.add(d3);
    }
    Series series = new Series(serieList, responseInfos, numOfParticipants, !survey);
    series.setChartType(survey ? SeriesFactory.BAR_ANSWERED : SeriesFactory.BAR_CORRECT_WRONG_NOT);
    series.setItemCss("o_qti_scitem");
    return series;
}
Also used : ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) Series(org.olat.ims.qti.statistics.ui.Series) BarSeries(org.olat.core.gui.components.chart.BarSeries) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseInfos(org.olat.ims.qti.statistics.ui.ResponseInfos) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)

Example 23 with HotspotChoice

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

the class HotspotEditorController method rebuildWrappersAndCorrectSelection.

private void rebuildWrappersAndCorrectSelection() {
    choiceWrappers.clear();
    List<HotspotChoice> choices = itemBuilder.getHotspotChoices();
    String[] keys = new String[choices.size()];
    String[] values = new String[choices.size()];
    for (int i = 0; i < choices.size(); i++) {
        HotspotChoice choice = choices.get(i);
        keys[i] = choice.getIdentifier().toString();
        values[i] = Integer.toString(i + 1) + ".";
        choiceWrappers.add(new HotspotWrapper(choice, itemBuilder));
    }
    correctHotspotsEl.setKeysAndValues(keys, values);
    for (int i = 0; i < choices.size(); i++) {
        if (itemBuilder.isCorrect(choices.get(i))) {
            correctHotspotsEl.select(keys[i], true);
        }
    }
    hotspotsCont.contextPut("hotspots", choiceWrappers);
}
Also used : HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)

Example 24 with HotspotChoice

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

the class HotspotEditorController method doDeleteHotspot.

private void doDeleteHotspot(UserRequest ureq) {
    if (restrictedEdit || readOnly)
        return;
    String hotspotId = ureq.getParameter("hotspot");
    HotspotChoice choiceToDelete = itemBuilder.getHotspotChoice(hotspotId);
    if (choiceToDelete != null) {
        itemBuilder.deleteHotspotChoice(choiceToDelete);
        rebuildWrappersAndCorrectSelection();
    }
}
Also used : HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)

Example 25 with HotspotChoice

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

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