Search in sources :

Example 1 with HotspotChoice

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

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 2 with HotspotChoice

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

the class HotspotInteractionStatisticsController method getSingleChoice.

private Series getSingleChoice(List<HotspotChoiceStatistics> statisticResponses) {
    boolean survey = QTIType.survey.equals(resourceResult.getType());
    int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
    List<Identifier> correctAnswers = getCorrectResponses();
    int i = 0;
    long numOfResults = 0;
    BarSeries d1 = new BarSeries();
    List<ResponseInfos> responseInfos = new ArrayList<>();
    for (HotspotChoiceStatistics statisticResponse : statisticResponses) {
        HotspotChoice choice = statisticResponse.getChoice();
        String text = getAnswerText(choice);
        double ans_count = statisticResponse.getCount();
        numOfResults += statisticResponse.getCount();
        boolean correct = correctAnswers.contains(choice.getIdentifier());
        Float points;
        String cssColor;
        if (survey) {
            points = null;
            cssColor = "bar_default";
        } else {
            Double mappedValue = CorrectResponsesUtil.getMappedValue(assessmentItem, interaction, choice);
            if (mappedValue != null) {
                points = mappedValue.floatValue();
            } else {
                points = correct ? 1.0f : 0.0f;
            }
            cssColor = correct ? "bar_green" : "bar_red";
        }
        String label = Integer.toString(++i);
        d1.add(ans_count, label, cssColor);
        responseInfos.add(new ResponseInfos(label, text, points, correct, survey, false));
    }
    if (numOfResults != numOfParticipants) {
        long notAnswered = numOfParticipants - numOfResults;
        if (notAnswered > 0) {
            String label = Integer.toString(++i);
            String text = translate("user.not.answer");
            responseInfos.add(new ResponseInfos(label, text, null, false, survey, false));
            d1.add(notAnswered, label, "bar_grey");
        }
    }
    List<BarSeries> serieList = Collections.singletonList(d1);
    Series series = new Series(serieList, responseInfos, numOfParticipants, false);
    series.setChartType(SeriesFactory.BAR_CORRECT);
    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 3 with HotspotChoice

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

the class HotspotEditorController method scaleHotspot.

private void scaleHotspot(Size oldSize, Size newSize) {
    if (oldSize == null || newSize == null || choiceWrappers.isEmpty())
        return;
    int oldWidth = oldSize.getWidth();
    int newWidth = newSize.getWidth();
    int oldHeight = oldSize.getHeight();
    int newHeight = newSize.getHeight();
    if (oldWidth <= 0 || oldHeight <= 0 || newWidth <= 0 || newHeight <= 0)
        return;
    double widthFactor = ((double) oldWidth / newWidth);
    double heightFactor = ((double) oldHeight / newHeight);
    for (HotspotWrapper wrapper : choiceWrappers) {
        HotspotChoice choice = wrapper.getChoice();
        if (choice != null) {
            if (Shape.CIRCLE.equals(choice.getShape())) {
                scaleCircle(choice.getCoords(), widthFactor, heightFactor);
            } else if (Shape.RECT.equals(choice.getShape())) {
                scaleRect(choice.getCoords(), widthFactor, heightFactor);
            }
        }
    }
}
Also used : HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)

Example 4 with HotspotChoice

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

the class HotspotEditorController method doCorrectAnswers.

private void doCorrectAnswers(Collection<String> correctResponseIds) {
    List<HotspotChoice> choices = itemBuilder.getHotspotChoices();
    for (int i = 0; i < choices.size(); i++) {
        HotspotChoice choice = choices.get(i);
        boolean correct = correctResponseIds.contains(choice.getIdentifier().toString());
        itemBuilder.setCorrect(choice, correct);
    }
}
Also used : HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice)

Example 5 with HotspotChoice

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

the class HotspotChoiceScoreController method updateBackground.

protected void updateBackground() {
    File backgroundImage = null;
    if (StringHelper.containsNonWhitespace(itemBuilder.getBackground())) {
        File itemDirectory = itemFile.getParentFile();
        Path backgroundPath = itemDirectory.toPath().resolve(itemBuilder.getBackground());
        if (Files.exists(backgroundPath)) {
            backgroundImage = backgroundPath.toFile();
        }
    }
    if (backgroundImage != null) {
        String filename = backgroundImage.getName();
        Size size = imageService.getSize(new LocalFileImpl(backgroundImage), null);
        scoreCont.contextPut("filename", filename);
        if (size != null) {
            if (size.getHeight() > 0) {
                scoreCont.contextPut("height", Integer.toString(size.getHeight()));
            } else {
                scoreCont.contextRemove("height");
            }
            if (size.getWidth() > 0) {
                scoreCont.contextPut("width", Integer.toString(size.getWidth()));
            } else {
                scoreCont.contextRemove("width");
            }
        }
    } else {
        scoreCont.contextRemove("filename");
    }
    List<HotspotWrapper> choiceWrappers = new ArrayList<>();
    List<HotspotChoice> choices = itemBuilder.getHotspotChoices();
    for (int i = 0; i < choices.size(); i++) {
        HotspotChoice choice = choices.get(i);
        choiceWrappers.add(new HotspotWrapper(choice, itemBuilder));
    }
    scoreCont.contextPut("hotspots", choiceWrappers);
}
Also used : Path(java.nio.file.Path) Size(org.olat.core.commons.services.image.Size) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) ArrayList(java.util.ArrayList) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) File(java.io.File)

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