Search in sources :

Example 11 with SliderWrapper

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

the class RubricController method forgeContinuousSlider.

private SliderWrapper forgeContinuousSlider(Slider slider, Rubric element) {
    SliderElement sliderEl = uifactory.addSliderElement("slider_" + (count++), null, flc);
    sliderEl.setDomReplacementWrapperRequired(false);
    sliderEl.addActionListener(FormEvent.ONCHANGE);
    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 12 with SliderWrapper

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

the class EvaluationFormController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (saveAsDoneButton == source) {
        doConfirmDone(ureq);
    } else if (source instanceof SingleSelection) {
        SingleSelection radioEl = (SingleSelection) source;
        Object uobject = radioEl.getUserObject();
        if (uobject instanceof SliderWrapper) {
            String selectedKey = radioEl.getSelectedKey();
            SliderWrapper sliderWrapper = (SliderWrapper) uobject;
            saveNumericalResponse(new BigDecimal(selectedKey), selectedKey, sliderWrapper.getId());
        }
    } else if (source instanceof SliderElement) {
        SliderElement slider = (SliderElement) source;
        Object uobject = slider.getUserObject();
        if (uobject instanceof SliderWrapper) {
            double value = slider.getValue();
            SliderWrapper sliderWrapper = (SliderWrapper) uobject;
            saveNumericalResponse(BigDecimal.valueOf(value), Double.toString(value), sliderWrapper.getId());
        }
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        Object uobject = link.getUserObject();
        if (uobject instanceof TextInputWrapper) {
            TextInputWrapper wrapper = (TextInputWrapper) uobject;
            String value = wrapper.getTextEl().getValue();
            saveNumericalResponse(null, value, wrapper.getId());
        }
    } else if (source instanceof FileElement) {
        FileElement fileElement = (FileElement) source;
        Object uobject = fileElement.getUserObject();
        if (uobject instanceof FileUploadWrapper) {
            FileUploadWrapper wrapper = (FileUploadWrapper) uobject;
            if (event instanceof FileElementEvent) {
                if (FileElementEvent.DELETE.equals(event.getCommand())) {
                    saveFileResponse(null, null, wrapper.getId());
                    fileElement.setInitialFile(null);
                    if (fileElement.getUploadFile() != null) {
                        fileElement.reset();
                    }
                    flc.setDirty(true);
                }
            } else if (fileElement.isUploadSuccess()) {
                File file = fileElement.getUploadFile();
                String filename = fileElement.getUploadFileName();
                saveFileResponse(file, filename, wrapper.getId());
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : TextInputWrapper(org.olat.modules.forms.ui.model.TextInputWrapper) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) FileUploadWrapper(org.olat.modules.forms.ui.model.FileUploadWrapper) FileElementEvent(org.olat.core.gui.components.form.flexible.impl.elements.FileElementEvent) BigDecimal(java.math.BigDecimal) SliderWrapper(org.olat.modules.forms.ui.model.SliderWrapper) SliderElement(org.olat.core.gui.components.form.flexible.elements.SliderElement) FileElement(org.olat.core.gui.components.form.flexible.elements.FileElement) File(java.io.File)

Example 13 with SliderWrapper

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

the class EvaluationFormController method forgeDiscreteRadioButtons.

private SliderWrapper forgeDiscreteRadioButtons(Slider slider, Rubric element, EvaluationFormResponse response) {
    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);
    radioEl.setEnabled(!readOnly);
    radioEl.setAllowNoSelection(true);
    int widthInPercent = EvaluationFormElementWrapper.getWidthInPercent(element);
    radioEl.setWidthInPercent(widthInPercent, true);
    if (response != null && response.getNumericalResponse() != null) {
        double val = response.getNumericalResponse().doubleValue();
        double error = step / 10.0d;
        for (int i = 0; i < theSteps.length; i++) {
            double theStep = theSteps[i];
            double margin = Math.abs(theStep - val);
            if (margin < error) {
                radioEl.select(theKeys[i], 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 14 with SliderWrapper

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

the class EvaluationFormController method forgeDiscreteSlider.

private SliderWrapper forgeDiscreteSlider(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());
    sliderEl.setStep(1);
    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 15 with SliderWrapper

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

the class RubricController method forgeContinuousSlider.

private SliderWrapper forgeContinuousSlider(Slider slider, Rubric element) {
    SliderElement sliderEl = uifactory.addSliderElement("slider_" + (count++), null, flc);
    sliderEl.setDomReplacementWrapperRequired(false);
    sliderEl.addActionListener(FormEvent.ONCHANGE);
    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)

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