Search in sources :

Example 11 with EvaluationFormElementWrapper

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

the class EvaluationFormController method forgeTextInput.

private EvaluationFormElementWrapper forgeTextInput(TextInput element) {
    String initialValue = "";
    EvaluationFormResponse response = identifierToResponses.get(element.getId());
    if (response != null && StringHelper.containsNonWhitespace(response.getStringuifiedResponse())) {
        initialValue = response.getStringuifiedResponse();
    }
    int rows = 12;
    if (element.getRows() > 0) {
        rows = element.getRows();
    }
    TextElement textEl = uifactory.addTextAreaElement("textinput_" + (count++), null, Integer.MAX_VALUE, rows, 72, false, initialValue, flc);
    textEl.setEnabled(!readOnly);
    FormLink saveButton = uifactory.addFormLink("save_" + (count++), "save", null, flc, Link.BUTTON);
    saveButton.setVisible(!readOnly);
    TextInputWrapper textInputWrapper = new TextInputWrapper(element, textEl, saveButton);
    saveButton.setUserObject(textInputWrapper);
    textEl.setUserObject(textInputWrapper);
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setTextInputWrapper(textInputWrapper);
    return wrapper;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) TextInputWrapper(org.olat.modules.forms.ui.model.TextInputWrapper) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 12 with EvaluationFormElementWrapper

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

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

the class EvaluationFormController method updateElements.

private void updateElements(UserRequest ureq) {
    List<EvaluationFormElementWrapper> elementWrappers = new ArrayList<>();
    for (AbstractElement element : form.getElements()) {
        EvaluationFormElementWrapper wrapper = forgeElement(ureq, element);
        if (wrapper != null) {
            elementWrappers.add(wrapper);
        }
    }
    elementWrapperList = elementWrappers;
    flc.contextPut("elements", elementWrappers);
}
Also used : AbstractElement(org.olat.modules.forms.model.xml.AbstractElement) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) ArrayList(java.util.ArrayList)

Example 14 with EvaluationFormElementWrapper

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

the class EvaluationFormController method forgeFileUpload.

private EvaluationFormElementWrapper forgeFileUpload(UserRequest ureq, FileUpload element) {
    FileElement fileEl = uifactory.addFileElement(getWindowControl(), "file_upload_" + CodeHelper.getRAMUniqueID(), "", flc);
    fileEl.setPreview(ureq.getUserSession(), true);
    fileEl.addActionListener(FormEvent.ONCHANGE);
    fileEl.setDeleteEnabled(true);
    fileEl.setMaxUploadSizeKB(element.getMaxUploadSizeKB(), "file.upload.error.limit.exeeded", null);
    Set<String> mimeTypes = MimeTypeSetFactory.getMimeTypes(element.getMimeTypeSetKey());
    fileEl.limitToMimeType(mimeTypes, "file.upload.error.mime.type.wrong", null);
    EvaluationFormResponse response = identifierToResponses.get(element.getId());
    File responseFile = evaluationFormManager.loadResponseFile(response);
    if (responseFile != null) {
        fileEl.setInitialFile(responseFile);
    }
    fileEl.setEnabled(!readOnly);
    FileUploadWrapper fileUploadWrapper = new FileUploadWrapper(fileEl, element);
    fileEl.setUserObject(fileUploadWrapper);
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setFileUploadWrapper(fileUploadWrapper);
    return wrapper;
}
Also used : EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) FileElement(org.olat.core.gui.components.form.flexible.elements.FileElement) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) FileUploadWrapper(org.olat.modules.forms.ui.model.FileUploadWrapper) File(java.io.File)

Example 15 with EvaluationFormElementWrapper

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

the class EvaluationFormController method forgeTextInput.

private EvaluationFormElementWrapper forgeTextInput(TextInput element) {
    String initialValue = "";
    EvaluationFormResponse response = identifierToResponses.get(element.getId());
    if (response != null && StringHelper.containsNonWhitespace(response.getStringuifiedResponse())) {
        initialValue = response.getStringuifiedResponse();
    }
    int rows = 12;
    if (element.getRows() > 0) {
        rows = element.getRows();
    }
    TextElement textEl = uifactory.addTextAreaElement("textinput_" + (count++), null, Integer.MAX_VALUE, rows, 72, false, initialValue, flc);
    textEl.setEnabled(!readOnly);
    FormLink saveButton = uifactory.addFormLink("save_" + (count++), "save", null, flc, Link.BUTTON);
    saveButton.setVisible(!readOnly);
    TextInputWrapper textInputWrapper = new TextInputWrapper(element, textEl, saveButton);
    saveButton.setUserObject(textInputWrapper);
    textEl.setUserObject(textInputWrapper);
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setTextInputWrapper(textInputWrapper);
    return wrapper;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) TextInputWrapper(org.olat.modules.forms.ui.model.TextInputWrapper) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

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