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