use of org.olat.modules.forms.ui.model.SliderWrapper 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.SliderWrapper in project OpenOLAT by OpenOLAT.
the class EvaluationFormController method forgeContinuousSlider.
private SliderWrapper forgeContinuousSlider(Slider slider, Rubric element, EvaluationFormResponse response) {
SliderElement sliderEl = uifactory.addSliderElement("slider_" + (count++), null, flc);
sliderEl.setDomReplacementWrapperRequired(false);
sliderEl.addActionListener(FormEvent.ONCHANGE);
sliderEl.setEnabled(!readOnly);
if (response != null && response.getNumericalResponse() != null) {
double val = response.getNumericalResponse().doubleValue();
sliderEl.setInitialValue(val);
}
sliderEl.setMinValue(element.getStart());
sliderEl.setMaxValue(element.getEnd());
SliderWrapper sliderWrapper = new SliderWrapper(slider, sliderEl);
sliderEl.setUserObject(sliderWrapper);
return sliderWrapper;
}
use of org.olat.modules.forms.ui.model.SliderWrapper 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.SliderWrapper in project OpenOLAT by OpenOLAT.
the class RubricController method forgeDiscreteRadioButtons.
private SliderWrapper forgeDiscreteRadioButtons(Slider slider, Rubric element) {
int start = element.getStart();
int end = element.getEnd();
int steps = element.getSteps();
double[] theSteps = new double[steps];
String[] theKeys = new String[steps];
String[] theValues = new String[steps];
double step = (end - start + 1) / (double) steps;
for (int i = 0; i < steps; i++) {
theSteps[i] = start + (i * step);
theKeys[i] = Double.toString(theSteps[i]);
theValues[i] = "";
}
SingleSelection radioEl = uifactory.addRadiosVertical("slider_" + (count++), null, flc, theKeys, theValues);
radioEl.setDomReplacementWrapperRequired(false);
radioEl.addActionListener(FormEvent.ONCHANGE);
int widthInPercent = EvaluationFormElementWrapper.getWidthInPercent(element);
radioEl.setWidthInPercent(widthInPercent, true);
SliderWrapper sliderWrapper = new SliderWrapper(slider, radioEl);
radioEl.setUserObject(sliderWrapper);
return sliderWrapper;
}
use of org.olat.modules.forms.ui.model.SliderWrapper 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);
}
Aggregations