Search in sources :

Example 26 with EvaluationFormElementWrapper

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

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 27 with EvaluationFormElementWrapper

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

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 28 with EvaluationFormElementWrapper

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

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)

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