Search in sources :

Example 1 with SliderWrapper

use of org.olat.modules.forms.ui.model.SliderWrapper 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 SliderWrapper

use of org.olat.modules.forms.ui.model.SliderWrapper in project OpenOLAT by OpenOLAT.

the class EvaluationFormController method forgeContinuousSlider.

private SliderWrapper forgeContinuousSlider(Slider slider, Rubric element, EvaluationFormResponse response) {
    SliderElement sliderEl = uifactory.addSliderElement("slider_" + (count++), null, flc);
    sliderEl.setDomReplacementWrapperRequired(false);
    sliderEl.addActionListener(FormEvent.ONCHANGE);
    sliderEl.setEnabled(!readOnly);
    if (response != null && response.getNumericalResponse() != null) {
        double val = response.getNumericalResponse().doubleValue();
        sliderEl.setInitialValue(val);
    }
    sliderEl.setMinValue(element.getStart());
    sliderEl.setMaxValue(element.getEnd());
    SliderWrapper sliderWrapper = new SliderWrapper(slider, sliderEl);
    sliderEl.setUserObject(sliderWrapper);
    return sliderWrapper;
}
Also used : SliderElement(org.olat.core.gui.components.form.flexible.elements.SliderElement) SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper)

Example 3 with SliderWrapper

use of org.olat.modules.forms.ui.model.SliderWrapper in project OpenOLAT by OpenOLAT.

the class EvaluationFormController method validate.

@Override
public boolean validate(UserRequest ureq, List<ValidationMessage> messages) {
    boolean allFiled = true;
    for (EvaluationFormElementWrapper elementWrapper : elementWrapperList) {
        if (elementWrapper.isTextInput()) {
            TextInputWrapper wrapper = elementWrapper.getTextInputWrapper();
            if (wrapper != null && !hasResponse(wrapper.getId())) {
                allFiled &= false;
            }
        } else if (elementWrapper.isFileUpload()) {
            FileUploadWrapper wrapper = elementWrapper.getFileUploadWrapper();
            if (wrapper != null && !hasResponse(wrapper.getId())) {
                allFiled &= false;
            }
        } else if (elementWrapper.getSliders() != null && elementWrapper.getSliders().size() > 0) {
            for (SliderWrapper slider : elementWrapper.getSliders()) {
                if (slider != null && !hasResponse(slider.getId())) {
                    allFiled &= false;
                }
            }
        }
    }
    if (!allFiled) {
        String msg = translate("warning.form.not.completed");
        messages.add(new ValidationMessage(Level.warning, msg));
    }
    return validateFormLogic(ureq);
}
Also used : SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper) ValidationMessage(org.olat.modules.portfolio.ui.editor.ValidationMessage) TextInputWrapper(org.olat.modules.forms.ui.model.TextInputWrapper) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) FileUploadWrapper(org.olat.modules.forms.ui.model.FileUploadWrapper)

Example 4 with SliderWrapper

use of org.olat.modules.forms.ui.model.SliderWrapper in project OpenOLAT by OpenOLAT.

the class RubricController method forgeDiscreteRadioButtons.

private SliderWrapper forgeDiscreteRadioButtons(Slider slider, Rubric element) {
    int start = element.getStart();
    int end = element.getEnd();
    int steps = element.getSteps();
    double[] theSteps = new double[steps];
    String[] theKeys = new String[steps];
    String[] theValues = new String[steps];
    double step = (end - start + 1) / (double) steps;
    for (int i = 0; i < steps; i++) {
        theSteps[i] = start + (i * step);
        theKeys[i] = Double.toString(theSteps[i]);
        theValues[i] = "";
    }
    SingleSelection radioEl = uifactory.addRadiosVertical("slider_" + (count++), null, flc, theKeys, theValues);
    radioEl.setDomReplacementWrapperRequired(false);
    radioEl.addActionListener(FormEvent.ONCHANGE);
    int widthInPercent = EvaluationFormElementWrapper.getWidthInPercent(element);
    radioEl.setWidthInPercent(widthInPercent, true);
    SliderWrapper sliderWrapper = new SliderWrapper(slider, radioEl);
    radioEl.setUserObject(sliderWrapper);
    return sliderWrapper;
}
Also used : SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection)

Example 5 with SliderWrapper

use of org.olat.modules.forms.ui.model.SliderWrapper 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)

Aggregations

SliderWrapper (org.olat.modules.forms.ui.model.SliderWrapper)24 SliderElement (org.olat.core.gui.components.form.flexible.elements.SliderElement)10 ArrayList (java.util.ArrayList)8 EvaluationFormElementWrapper (org.olat.modules.forms.ui.model.EvaluationFormElementWrapper)8 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)6 EvaluationFormResponse (org.olat.modules.forms.EvaluationFormResponse)6 Slider (org.olat.modules.forms.model.xml.Slider)6 SliderType (org.olat.modules.forms.model.xml.Rubric.SliderType)4 FileUploadWrapper (org.olat.modules.forms.ui.model.FileUploadWrapper)4 TextInputWrapper (org.olat.modules.forms.ui.model.TextInputWrapper)4 File (java.io.File)2 BigDecimal (java.math.BigDecimal)2 FileElement (org.olat.core.gui.components.form.flexible.elements.FileElement)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 FileElementEvent (org.olat.core.gui.components.form.flexible.impl.elements.FileElementEvent)2 Identity (org.olat.core.id.Identity)2 SliderOverviewElement (org.olat.modules.forms.ui.component.SliderOverviewElement)2 SliderPoint (org.olat.modules.forms.ui.component.SliderPoint)2 ValidationMessage (org.olat.modules.portfolio.ui.editor.ValidationMessage)2