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