Search in sources :

Example 1 with EvaluationFormElementWrapper

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

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

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

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

the class CompareEvaluationsFormController method appendsElement.

private void appendsElement(UserRequest ureq, AbstractElement element, List<EvaluationFormElementWrapper> wrappers) {
    String type = element.getType();
    switch(type) {
        case "formhtitle":
        case "formhr":
        case "formhtmlraw":
            wrappers.add(new EvaluationFormElementWrapper(element));
            break;
        case "formrubric":
            Rubric rubric = (Rubric) element;
            EvaluationFormElementWrapper sliderWrapper;
            if (rubric.getSliders().size() > 2) {
                sliderWrapper = forgeRadarRubric((Rubric) element);
            } else {
                sliderWrapper = forgeRubric((Rubric) element);
            }
            if (sliderWrapper != null) {
                wrappers.add(sliderWrapper);
            }
            break;
        case "formtextinput":
            List<EvaluationFormElementWrapper> inputWrappers = forgeTextInput((TextInput) element);
            if (inputWrappers != null && !inputWrappers.isEmpty()) {
                wrappers.addAll(inputWrappers);
            }
            break;
        case "formfileupload":
            List<EvaluationFormElementWrapper> fileUploadWrappers = forgeFileUpload(ureq, (FileUpload) element);
            if (fileUploadWrappers != null && !fileUploadWrappers.isEmpty()) {
                wrappers.addAll(fileUploadWrappers);
            }
            break;
    }
}
Also used : Rubric(org.olat.modules.forms.model.xml.Rubric) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper)

Example 5 with EvaluationFormElementWrapper

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

the class CompareEvaluationsFormController method forgeTextInput.

private List<EvaluationFormElementWrapper> forgeTextInput(TextInput element) {
    List<EvaluationFormResponse> responses = identifierToResponses.get(element.getId());
    if (responses == null) {
        // in review - selbstreview ??
        return new ArrayList<>();
    }
    List<EvaluationFormElementWrapper> inputWrappers = new ArrayList<>(responses.size());
    for (EvaluationFormResponse response : responses) {
        if (StringHelper.containsNonWhitespace(response.getStringuifiedResponse())) {
            String initialValue = response.getStringuifiedResponse();
            if (initialValue != null) {
                initialValue = Formatter.stripTabsAndReturns(initialValue).toString();
            }
            Identity evaluator = response.getSession().getIdentity();
            String legend = getLegend(evaluator);
            String color = evaluatorToColors.get(evaluator);
            TextInputWrapper textInputWrapper = new TextInputWrapper(legend, color, initialValue, null);
            EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
            wrapper.setTextInputWrapper(textInputWrapper);
            inputWrappers.add(wrapper);
        }
    }
    return inputWrappers;
}
Also used : TextInputWrapper(org.olat.modules.forms.ui.model.TextInputWrapper) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) Identity(org.olat.core.id.Identity)

Aggregations

EvaluationFormElementWrapper (org.olat.modules.forms.ui.model.EvaluationFormElementWrapper)28 ArrayList (java.util.ArrayList)18 EvaluationFormResponse (org.olat.modules.forms.EvaluationFormResponse)14 Slider (org.olat.modules.forms.model.xml.Slider)8 SliderWrapper (org.olat.modules.forms.ui.model.SliderWrapper)8 TextInputWrapper (org.olat.modules.forms.ui.model.TextInputWrapper)8 Identity (org.olat.core.id.Identity)4 AbstractElement (org.olat.modules.forms.model.xml.AbstractElement)4 Rubric (org.olat.modules.forms.model.xml.Rubric)4 SliderType (org.olat.modules.forms.model.xml.Rubric.SliderType)4 FileUploadWrapper (org.olat.modules.forms.ui.model.FileUploadWrapper)4 ValidationMessage (org.olat.modules.portfolio.ui.editor.ValidationMessage)4 File (java.io.File)2 HashMap (java.util.HashMap)2 RadarChartElement (org.olat.core.gui.components.chart.RadarChartElement)2 RadarSeries (org.olat.core.gui.components.chart.RadarSeries)2 FileElement (org.olat.core.gui.components.form.flexible.elements.FileElement)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)2 EvaluationFormSession (org.olat.modules.forms.EvaluationFormSession)2