Search in sources :

Example 1 with SliderType

use of org.olat.modules.forms.model.xml.Rubric.SliderType in project OpenOLAT by OpenOLAT.

the class EvaluationFormController method forgeRubric.

private EvaluationFormElementWrapper forgeRubric(Rubric element) {
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    List<Slider> sliders = element.getSliders();
    List<SliderWrapper> sliderWrappers = new ArrayList<>(sliders.size());
    for (Slider slider : sliders) {
        String responseIdentifier = slider.getId();
        EvaluationFormResponse response = identifierToResponses.get(responseIdentifier);
        SliderType type = element.getSliderType();
        SliderWrapper sliderWrapper = null;
        if (type == SliderType.discrete) {
            sliderWrapper = forgeDiscreteRadioButtons(slider, element, response);
        } else if (type == SliderType.discrete_slider) {
            sliderWrapper = forgeDiscreteSlider(slider, element, response);
        } else if (type == SliderType.continuous) {
            sliderWrapper = forgeContinuousSlider(slider, element, response);
        }
        if (sliderWrapper != null) {
            sliderWrappers.add(sliderWrapper);
        }
    }
    wrapper.setSliders(sliderWrappers);
    return wrapper;
}
Also used : SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper) Slider(org.olat.modules.forms.model.xml.Slider) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList) SliderType(org.olat.modules.forms.model.xml.Rubric.SliderType) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse)

Example 2 with SliderType

use of org.olat.modules.forms.model.xml.Rubric.SliderType in project OpenOLAT by OpenOLAT.

the class RubricController method updateForm.

protected void updateForm() {
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(rubric);
    List<Slider> sliders = rubric.getSliders();
    List<SliderWrapper> sliderWrappers = new ArrayList<>(sliders.size());
    for (Slider slider : sliders) {
        SliderType type = rubric.getSliderType();
        SliderWrapper sliderWrapper = null;
        if (type == SliderType.discrete) {
            sliderWrapper = forgeDiscreteRadioButtons(slider, rubric);
        } else if (type == SliderType.discrete_slider) {
            sliderWrapper = forgeDiscreteSlider(slider, rubric);
        } else if (type == SliderType.continuous) {
            sliderWrapper = forgeContinuousSlider(slider, rubric);
        }
        if (sliderWrapper != null) {
            sliderWrappers.add(sliderWrapper);
        }
    }
    wrapper.setSliders(sliderWrappers);
    flc.contextPut("element", wrapper);
}
Also used : SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper) Slider(org.olat.modules.forms.model.xml.Slider) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList) SliderType(org.olat.modules.forms.model.xml.Rubric.SliderType)

Example 3 with SliderType

use of org.olat.modules.forms.model.xml.Rubric.SliderType in project OpenOLAT by OpenOLAT.

the class RubricEditorController method commitStepLabels.

private void commitStepLabels() {
    if (!typeEl.isOneSelected())
        return;
    SliderType selectedType = SliderType.valueOf(typeEl.getSelectedKey());
    if (selectedType == SliderType.discrete || selectedType == SliderType.discrete_slider) {
        if (rubric.getStepLabels() == null) {
            rubric.setStepLabels(new ArrayList<>());
        }
        int steps = Integer.parseInt(stepsEl.getSelectedKey());
        for (int i = 0; i < stepLabels.size() && i < steps; i++) {
            StepLabelColumn stepLabel = stepLabels.get(i);
            if (i < rubric.getStepLabels().size()) {
                rubric.getStepLabels().get(i).setLabel(stepLabel.getStepLabelEl().getValue());
            } else {
                StepLabel label = new StepLabel();
                label.setId(UUID.randomUUID().toString());
                label.setLabel(stepLabel.getStepLabelEl().getValue());
                rubric.getStepLabels().add(label);
            }
        }
        if (rubric.getStepLabels().size() > steps) {
            List<StepLabel> labels = new ArrayList<>(rubric.getStepLabels().subList(0, steps));
            rubric.setStepLabels(labels);
        }
    } else {
        rubric.getStepLabels().clear();
    }
}
Also used : StepLabel(org.olat.modules.forms.model.xml.StepLabel) ArrayList(java.util.ArrayList) SliderType(org.olat.modules.forms.model.xml.Rubric.SliderType)

Example 4 with SliderType

use of org.olat.modules.forms.model.xml.Rubric.SliderType in project openolat by klemens.

the class EvaluationFormController method forgeRubric.

private EvaluationFormElementWrapper forgeRubric(Rubric element) {
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    List<Slider> sliders = element.getSliders();
    List<SliderWrapper> sliderWrappers = new ArrayList<>(sliders.size());
    for (Slider slider : sliders) {
        String responseIdentifier = slider.getId();
        EvaluationFormResponse response = identifierToResponses.get(responseIdentifier);
        SliderType type = element.getSliderType();
        SliderWrapper sliderWrapper = null;
        if (type == SliderType.discrete) {
            sliderWrapper = forgeDiscreteRadioButtons(slider, element, response);
        } else if (type == SliderType.discrete_slider) {
            sliderWrapper = forgeDiscreteSlider(slider, element, response);
        } else if (type == SliderType.continuous) {
            sliderWrapper = forgeContinuousSlider(slider, element, response);
        }
        if (sliderWrapper != null) {
            sliderWrappers.add(sliderWrapper);
        }
    }
    wrapper.setSliders(sliderWrappers);
    return wrapper;
}
Also used : SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper) Slider(org.olat.modules.forms.model.xml.Slider) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList) SliderType(org.olat.modules.forms.model.xml.Rubric.SliderType) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse)

Example 5 with SliderType

use of org.olat.modules.forms.model.xml.Rubric.SliderType in project openolat by klemens.

the class RubricEditorController method commitStepLabels.

private void commitStepLabels() {
    if (!typeEl.isOneSelected())
        return;
    SliderType selectedType = SliderType.valueOf(typeEl.getSelectedKey());
    if (selectedType == SliderType.discrete || selectedType == SliderType.discrete_slider) {
        if (rubric.getStepLabels() == null) {
            rubric.setStepLabels(new ArrayList<>());
        }
        int steps = Integer.parseInt(stepsEl.getSelectedKey());
        for (int i = 0; i < stepLabels.size() && i < steps; i++) {
            StepLabelColumn stepLabel = stepLabels.get(i);
            if (i < rubric.getStepLabels().size()) {
                rubric.getStepLabels().get(i).setLabel(stepLabel.getStepLabelEl().getValue());
            } else {
                StepLabel label = new StepLabel();
                label.setId(UUID.randomUUID().toString());
                label.setLabel(stepLabel.getStepLabelEl().getValue());
                rubric.getStepLabels().add(label);
            }
        }
        if (rubric.getStepLabels().size() > steps) {
            List<StepLabel> labels = new ArrayList<>(rubric.getStepLabels().subList(0, steps));
            rubric.setStepLabels(labels);
        }
    } else {
        rubric.getStepLabels().clear();
    }
}
Also used : StepLabel(org.olat.modules.forms.model.xml.StepLabel) ArrayList(java.util.ArrayList) SliderType(org.olat.modules.forms.model.xml.Rubric.SliderType)

Aggregations

SliderType (org.olat.modules.forms.model.xml.Rubric.SliderType)8 ArrayList (java.util.ArrayList)6 Slider (org.olat.modules.forms.model.xml.Slider)6 EvaluationFormElementWrapper (org.olat.modules.forms.ui.model.EvaluationFormElementWrapper)4 SliderWrapper (org.olat.modules.forms.ui.model.SliderWrapper)4 EvaluationFormResponse (org.olat.modules.forms.EvaluationFormResponse)2 StepLabel (org.olat.modules.forms.model.xml.StepLabel)2 ChangePartEvent (org.olat.modules.portfolio.ui.editor.event.ChangePartEvent)2 ClosePartEvent (org.olat.modules.portfolio.ui.editor.event.ClosePartEvent)2