use of org.olat.modules.forms.model.xml.Rubric.SliderType 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.model.xml.Rubric.SliderType 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.model.xml.Rubric.SliderType in project OpenOLAT by OpenOLAT.
the class RubricEditorController method commitStepLabels.
private void commitStepLabels() {
if (!typeEl.isOneSelected())
return;
SliderType selectedType = SliderType.valueOf(typeEl.getSelectedKey());
if (selectedType == SliderType.discrete || selectedType == SliderType.discrete_slider) {
if (rubric.getStepLabels() == null) {
rubric.setStepLabels(new ArrayList<>());
}
int steps = Integer.parseInt(stepsEl.getSelectedKey());
for (int i = 0; i < stepLabels.size() && i < steps; i++) {
StepLabelColumn stepLabel = stepLabels.get(i);
if (i < rubric.getStepLabels().size()) {
rubric.getStepLabels().get(i).setLabel(stepLabel.getStepLabelEl().getValue());
} else {
StepLabel label = new StepLabel();
label.setId(UUID.randomUUID().toString());
label.setLabel(stepLabel.getStepLabelEl().getValue());
rubric.getStepLabels().add(label);
}
}
if (rubric.getStepLabels().size() > steps) {
List<StepLabel> labels = new ArrayList<>(rubric.getStepLabels().subList(0, steps));
rubric.setStepLabels(labels);
}
} else {
rubric.getStepLabels().clear();
}
}
use of org.olat.modules.forms.model.xml.Rubric.SliderType 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.model.xml.Rubric.SliderType in project openolat by klemens.
the class RubricEditorController method commitStepLabels.
private void commitStepLabels() {
if (!typeEl.isOneSelected())
return;
SliderType selectedType = SliderType.valueOf(typeEl.getSelectedKey());
if (selectedType == SliderType.discrete || selectedType == SliderType.discrete_slider) {
if (rubric.getStepLabels() == null) {
rubric.setStepLabels(new ArrayList<>());
}
int steps = Integer.parseInt(stepsEl.getSelectedKey());
for (int i = 0; i < stepLabels.size() && i < steps; i++) {
StepLabelColumn stepLabel = stepLabels.get(i);
if (i < rubric.getStepLabels().size()) {
rubric.getStepLabels().get(i).setLabel(stepLabel.getStepLabelEl().getValue());
} else {
StepLabel label = new StepLabel();
label.setId(UUID.randomUUID().toString());
label.setLabel(stepLabel.getStepLabelEl().getValue());
rubric.getStepLabels().add(label);
}
}
if (rubric.getStepLabels().size() > steps) {
List<StepLabel> labels = new ArrayList<>(rubric.getStepLabels().subList(0, steps));
rubric.setStepLabels(labels);
}
} else {
rubric.getStepLabels().clear();
}
}
Aggregations