Search in sources :

Example 1 with StepLabel

use of org.olat.modules.forms.model.xml.StepLabel 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();
    }
}
Also used : StepLabel(org.olat.modules.forms.model.xml.StepLabel) ArrayList(java.util.ArrayList) SliderType(org.olat.modules.forms.model.xml.Rubric.SliderType)

Example 2 with StepLabel

use of org.olat.modules.forms.model.xml.StepLabel 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();
    }
}
Also used : StepLabel(org.olat.modules.forms.model.xml.StepLabel) ArrayList(java.util.ArrayList) SliderType(org.olat.modules.forms.model.xml.Rubric.SliderType)

Example 3 with StepLabel

use of org.olat.modules.forms.model.xml.StepLabel in project OpenOLAT by OpenOLAT.

the class EvaluationFormElementWrapper method isStepLabels.

public boolean isStepLabels() {
    if (element instanceof Rubric) {
        Rubric rubric = (Rubric) element;
        if (rubric.getStepLabels() == null || rubric.getStepLabels().isEmpty()) {
            return false;
        }
        List<StepLabel> stepLabels = rubric.getStepLabels();
        for (StepLabel stepLabel : stepLabels) {
            if (stepLabel != null && StringHelper.containsNonWhitespace(stepLabel.getLabel())) {
                return true;
            }
        }
    }
    return false;
}
Also used : Rubric(org.olat.modules.forms.model.xml.Rubric) StepLabel(org.olat.modules.forms.model.xml.StepLabel)

Example 4 with StepLabel

use of org.olat.modules.forms.model.xml.StepLabel in project openolat by klemens.

the class EvaluationFormElementWrapper method isStepLabels.

public boolean isStepLabels() {
    if (element instanceof Rubric) {
        Rubric rubric = (Rubric) element;
        if (rubric.getStepLabels() == null || rubric.getStepLabels().isEmpty()) {
            return false;
        }
        List<StepLabel> stepLabels = rubric.getStepLabels();
        for (StepLabel stepLabel : stepLabels) {
            if (stepLabel != null && StringHelper.containsNonWhitespace(stepLabel.getLabel())) {
                return true;
            }
        }
    }
    return false;
}
Also used : Rubric(org.olat.modules.forms.model.xml.Rubric) StepLabel(org.olat.modules.forms.model.xml.StepLabel)

Aggregations

StepLabel (org.olat.modules.forms.model.xml.StepLabel)4 ArrayList (java.util.ArrayList)2 Rubric (org.olat.modules.forms.model.xml.Rubric)2 SliderType (org.olat.modules.forms.model.xml.Rubric.SliderType)2