Search in sources :

Example 16 with HotspotChoice

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

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

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

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

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

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

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

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

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

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)

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