Search in sources :

Example 31 with HotspotChoice

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

the class HotspotChoiceScoreController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    super.initForm(formLayout, listener, ureq);
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_score");
    ScoreBuilder minScore = itemBuilder.getMinScoreBuilder();
    String minValue = minScore == null ? "" : (minScore.getScore() == null ? "" : minScore.getScore().toString());
    minScoreEl = uifactory.addTextElement("min.score", "min.score", 8, minValue, formLayout);
    minScoreEl.setElementCssClass("o_sel_assessment_item_min_score");
    minScoreEl.setEnabled(!restrictedEdit && !readOnly);
    ScoreBuilder maxScore = itemBuilder.getMaxScoreBuilder();
    String maxValue = maxScore == null ? "" : (maxScore.getScore() == null ? "" : maxScore.getScore().toString());
    maxScoreEl = uifactory.addTextElement("max.score", "max.score", 8, maxValue, formLayout);
    maxScoreEl.setElementCssClass("o_sel_assessment_item_max_score");
    maxScoreEl.setEnabled(!restrictedEdit && !readOnly);
    String[] modeValues = new String[] { translate("form.score.assessment.all.correct"), translate("form.score.assessment.per.answer") };
    assessmentModeEl = uifactory.addRadiosHorizontal("assessment.mode", "form.score.assessment.mode", formLayout, modeKeys, modeValues);
    assessmentModeEl.addActionListener(FormEvent.ONCHANGE);
    assessmentModeEl.setEnabled(!restrictedEdit && !readOnly);
    if (itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) {
        assessmentModeEl.select(ScoreEvaluation.perAnswer.name(), true);
    } else {
        assessmentModeEl.select(ScoreEvaluation.allCorrectAnswers.name(), true);
    }
    String scorePage = velocity_root + "/hotspot_choices_score.html";
    scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
    formLayout.add(scoreCont);
    scoreCont.setLabel(null, null);
    for (HotspotChoice choice : itemBuilder.getHotspotChoices()) {
        HotspotChoiceWrapper wrapper = createHotspotChoiceWrapper(choice);
        wrappers.add(wrapper);
    }
    scoreCont.contextPut("choices", wrappers);
    scoreCont.contextPut("mapperUri", backgroundMapperUri);
    scoreCont.setVisible(assessmentModeEl.isSelected(1));
    updateBackground();
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : ScoreBuilder(org.olat.ims.qti21.model.xml.ScoreBuilder) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 32 with HotspotChoice

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

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)

Example 33 with HotspotChoice

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

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

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

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

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

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)

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