Search in sources :

Example 6 with SliderType

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

the class RubricEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    commitFields();
    commitStepLabels();
    String selectedType = typeEl.getSelectedKey();
    SliderType type = SliderType.valueOf(selectedType);
    rubric.setSliderType(type);
    if (type == SliderType.continuous) {
        rubric.setStart(1);
        rubric.setEnd(100);
        rubric.setSteps(100);
    } else {
        int steps = Integer.parseInt(stepsEl.getSelectedKey());
        rubric.setStart(1);
        rubric.setEnd(steps);
        rubric.setSteps(steps);
    }
    for (Iterator<Slider> sliderIt = rubric.getSliders().iterator(); sliderIt.hasNext(); ) {
        Slider slider = sliderIt.next();
        if (!StringHelper.containsNonWhitespace(slider.getStartLabel()) && !StringHelper.containsNonWhitespace(slider.getEndLabel())) {
            sliderIt.remove();
        }
    }
    rubricCtrl.updateForm();
    fireEvent(ureq, new ChangePartEvent(rubric));
    fireEvent(ureq, new ClosePartEvent(rubric));
}
Also used : ClosePartEvent(org.olat.modules.portfolio.ui.editor.event.ClosePartEvent) Slider(org.olat.modules.forms.model.xml.Slider) ChangePartEvent(org.olat.modules.portfolio.ui.editor.event.ChangePartEvent) SliderType(org.olat.modules.forms.model.xml.Rubric.SliderType)

Example 7 with SliderType

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

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 8 with SliderType

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

the class RubricEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    commitFields();
    commitStepLabels();
    String selectedType = typeEl.getSelectedKey();
    SliderType type = SliderType.valueOf(selectedType);
    rubric.setSliderType(type);
    if (type == SliderType.continuous) {
        rubric.setStart(1);
        rubric.setEnd(100);
        rubric.setSteps(100);
    } else {
        int steps = Integer.parseInt(stepsEl.getSelectedKey());
        rubric.setStart(1);
        rubric.setEnd(steps);
        rubric.setSteps(steps);
    }
    for (Iterator<Slider> sliderIt = rubric.getSliders().iterator(); sliderIt.hasNext(); ) {
        Slider slider = sliderIt.next();
        if (!StringHelper.containsNonWhitespace(slider.getStartLabel()) && !StringHelper.containsNonWhitespace(slider.getEndLabel())) {
            sliderIt.remove();
        }
    }
    rubricCtrl.updateForm();
    fireEvent(ureq, new ChangePartEvent(rubric));
    fireEvent(ureq, new ClosePartEvent(rubric));
}
Also used : ClosePartEvent(org.olat.modules.portfolio.ui.editor.event.ClosePartEvent) Slider(org.olat.modules.forms.model.xml.Slider) ChangePartEvent(org.olat.modules.portfolio.ui.editor.event.ChangePartEvent) 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