Search in sources :

Example 1 with RadarChartElement

use of org.olat.core.gui.components.chart.RadarChartElement in project OpenOLAT by OpenOLAT.

the class CompareEvaluationsFormController method forgeRadarRubric.

private EvaluationFormElementWrapper forgeRadarRubric(Rubric element) {
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setRadarOverview(true);
    List<String> axisList = new ArrayList<>();
    List<Slider> sliders = element.getSliders();
    Map<EvaluationFormSession, RadarSeries> series = new HashMap<>();
    for (Slider slider : sliders) {
        String axis;
        if (StringHelper.containsNonWhitespace(slider.getEndLabel())) {
            axis = slider.getEndLabel();
        } else if (StringHelper.containsNonWhitespace(slider.getStartLabel())) {
            axis = slider.getStartLabel();
        } else {
            axis = "";
        }
        axisList.add(axis);
        String responseIdentifier = slider.getId();
        List<EvaluationFormResponse> responses = identifierToResponses.get(responseIdentifier);
        if (responses != null && responses.size() > 0) {
            for (EvaluationFormResponse response : responses) {
                EvaluationFormSession responseSession = response.getSession();
                if (!series.containsKey(responseSession)) {
                    Identity identity = responseSession.getIdentity();
                    String legend = getLegend(identity);
                    String color = evaluatorToColors.get(identity);
                    series.put(responseSession, new RadarSeries(legend, color));
                }
                if (response.getNumericalResponse() != null) {
                    double value = response.getNumericalResponse().doubleValue();
                    series.get(responseSession).addPoint(axis, value);
                }
            }
        }
    }
    String id = "radar_" + (count++);
    RadarChartElement radarEl = new RadarChartElement(id);
    radarEl.setSeries(new ArrayList<>(series.values()));
    radarEl.setShowLegend(true);
    radarEl.setAxis(axisList);
    if (element.getSliderType() == SliderType.discrete || element.getSliderType() == SliderType.discrete_slider) {
        radarEl.setLevels(element.getSteps());
        radarEl.setMaxValue(element.getSteps());
        radarEl.setFormat(Format.integer);
    } else if (element.getSliderType() == SliderType.continuous) {
        radarEl.setLevels(10);
        radarEl.setMaxValue(100);
        radarEl.setFormat(Format.integer);
    }
    wrapper.setRadarEl(radarEl);
    flc.add(id, radarEl);
    return wrapper;
}
Also used : Slider(org.olat.modules.forms.model.xml.Slider) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RadarSeries(org.olat.core.gui.components.chart.RadarSeries) EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession) RadarChartElement(org.olat.core.gui.components.chart.RadarChartElement) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) Identity(org.olat.core.id.Identity)

Example 2 with RadarChartElement

use of org.olat.core.gui.components.chart.RadarChartElement in project openolat by klemens.

the class CompareEvaluationsFormController method forgeRadarRubric.

private EvaluationFormElementWrapper forgeRadarRubric(Rubric element) {
    EvaluationFormElementWrapper wrapper = new EvaluationFormElementWrapper(element);
    wrapper.setRadarOverview(true);
    List<String> axisList = new ArrayList<>();
    List<Slider> sliders = element.getSliders();
    Map<EvaluationFormSession, RadarSeries> series = new HashMap<>();
    for (Slider slider : sliders) {
        String axis;
        if (StringHelper.containsNonWhitespace(slider.getEndLabel())) {
            axis = slider.getEndLabel();
        } else if (StringHelper.containsNonWhitespace(slider.getStartLabel())) {
            axis = slider.getStartLabel();
        } else {
            axis = "";
        }
        axisList.add(axis);
        String responseIdentifier = slider.getId();
        List<EvaluationFormResponse> responses = identifierToResponses.get(responseIdentifier);
        if (responses != null && responses.size() > 0) {
            for (EvaluationFormResponse response : responses) {
                EvaluationFormSession responseSession = response.getSession();
                if (!series.containsKey(responseSession)) {
                    Identity identity = responseSession.getIdentity();
                    String legend = getLegend(identity);
                    String color = evaluatorToColors.get(identity);
                    series.put(responseSession, new RadarSeries(legend, color));
                }
                if (response.getNumericalResponse() != null) {
                    double value = response.getNumericalResponse().doubleValue();
                    series.get(responseSession).addPoint(axis, value);
                }
            }
        }
    }
    String id = "radar_" + (count++);
    RadarChartElement radarEl = new RadarChartElement(id);
    radarEl.setSeries(new ArrayList<>(series.values()));
    radarEl.setShowLegend(true);
    radarEl.setAxis(axisList);
    if (element.getSliderType() == SliderType.discrete || element.getSliderType() == SliderType.discrete_slider) {
        radarEl.setLevels(element.getSteps());
        radarEl.setMaxValue(element.getSteps());
        radarEl.setFormat(Format.integer);
    } else if (element.getSliderType() == SliderType.continuous) {
        radarEl.setLevels(10);
        radarEl.setMaxValue(100);
        radarEl.setFormat(Format.integer);
    }
    wrapper.setRadarEl(radarEl);
    flc.add(id, radarEl);
    return wrapper;
}
Also used : Slider(org.olat.modules.forms.model.xml.Slider) EvaluationFormElementWrapper(org.olat.modules.forms.ui.model.EvaluationFormElementWrapper) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RadarSeries(org.olat.core.gui.components.chart.RadarSeries) EvaluationFormSession(org.olat.modules.forms.EvaluationFormSession) RadarChartElement(org.olat.core.gui.components.chart.RadarChartElement) EvaluationFormResponse(org.olat.modules.forms.EvaluationFormResponse) Identity(org.olat.core.id.Identity)

Aggregations

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 RadarChartElement (org.olat.core.gui.components.chart.RadarChartElement)2 RadarSeries (org.olat.core.gui.components.chart.RadarSeries)2 Identity (org.olat.core.id.Identity)2 EvaluationFormResponse (org.olat.modules.forms.EvaluationFormResponse)2 EvaluationFormSession (org.olat.modules.forms.EvaluationFormSession)2 Slider (org.olat.modules.forms.model.xml.Slider)2 EvaluationFormElementWrapper (org.olat.modules.forms.ui.model.EvaluationFormElementWrapper)2