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);
}
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);
}
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;
}
Aggregations