Skip to content
Snippets Groups Projects
Commit 39ce4155 authored by uhensler's avatar uhensler
Browse files

OO-3303: Evaluation form report overview with histogram and more figures

parent 0f89e649
No related branches found
No related tags found
No related merge requests found
Showing
with 198 additions and 225 deletions
......@@ -47,7 +47,7 @@ public class DefaultReportProvider implements EvaluationFormReportProvider {
handlers.put(Title.TYPE, new TitleHandler());
handlers.put(Spacer.TYPE, new SpacerHandler());
handlers.put(HTMLRaw.TYPE, new HTMLRawHandler());
handlers.put(Rubric.TYPE, new RubricBarChartsHandler());
handlers.put(Rubric.TYPE, new RubricBarChartsHandler(false));
handlers.put(TextInput.TYPE, new TextInputLegendTextHandler());
handlers.put(FileUpload.TYPE, new FileUploadListingHandler());
handlers.put(SingleChoice.TYPE, new SingleChoiceBarChartHandler());
......
......@@ -28,7 +28,8 @@ import org.olat.core.gui.control.WindowControl;
import org.olat.modules.forms.EvaluationFormSessionRef;
import org.olat.modules.forms.model.xml.Rubric;
import org.olat.modules.forms.ui.ReportHelper;
import org.olat.modules.forms.ui.RubricBarChartsController;
import org.olat.modules.forms.ui.RubricSlidersBarChartsController;
import org.olat.modules.forms.ui.RubricTotalBarChartsController;
import org.olat.modules.portfolio.ui.editor.PageElement;
/**
......@@ -39,6 +40,13 @@ import org.olat.modules.portfolio.ui.editor.PageElement;
*/
public class RubricBarChartsHandler implements EvaluationFormReportHandler {
private boolean totals;
public RubricBarChartsHandler(boolean totals) {
super();
this.totals = totals;
}
@Override
public String getType() {
return "rubricbarcharts";
......@@ -49,7 +57,12 @@ public class RubricBarChartsHandler implements EvaluationFormReportHandler {
List<? extends EvaluationFormSessionRef> sessions, ReportHelper reportHelper) {
if (element instanceof Rubric) {
Rubric rubric = (Rubric) element;
Controller ctrl = new RubricBarChartsController(ureq, windowControl, rubric, sessions);
Controller ctrl;
if (totals) {
ctrl = new RubricTotalBarChartsController(ureq, windowControl, rubric, sessions);
} else {
ctrl = new RubricSlidersBarChartsController(ureq, windowControl, rubric, sessions);
}
return ctrl.getInitialComponent();
}
return null;
......
......@@ -33,10 +33,14 @@ import org.olat.core.gui.control.controller.BasicController;
import org.olat.modules.forms.EvaluationFormManager;
import org.olat.modules.forms.EvaluationFormSessionRef;
import org.olat.modules.forms.EvaluationFormStatistic;
import org.olat.modules.forms.handler.EvaluationFormReportHandler;
import org.olat.modules.forms.handler.EvaluationFormReportProvider;
import org.olat.modules.forms.handler.RubricBarChartsHandler;
import org.olat.modules.forms.model.xml.AbstractElement;
import org.olat.modules.forms.model.xml.Form;
import org.olat.modules.forms.model.xml.Rubric;
import org.olat.modules.forms.ui.component.ResponsiveBarChartComponent;
import org.olat.modules.portfolio.ui.editor.PageElement;
import org.springframework.beans.factory.annotation.Autowired;
/**
......@@ -47,6 +51,8 @@ import org.springframework.beans.factory.annotation.Autowired;
*
*/
public class EvaluationFormOverviewController extends BasicController {
private static final OverviewProvider PROVIDER = new OverviewProvider();
private VelocityContainer mainVC;
......@@ -67,7 +73,7 @@ public class EvaluationFormOverviewController extends BasicController {
mainVC.contextPut("averageDuration", EvaluationFormFormatter.duration(statistic.getAverageDuration()));
if (hasRubrics(form)) {
Controller reportCtrl = new RubricsTotalController(ureq, getWindowControl(), form, sessions);
Controller reportCtrl = new EvaluationFormReportController(ureq, wControl, form, sessions, PROVIDER, null);
mainVC.put("report", reportCtrl.getInitialComponent());
}
......@@ -167,4 +173,18 @@ public class EvaluationFormOverviewController extends BasicController {
}
}
private static final class OverviewProvider implements EvaluationFormReportProvider {
RubricBarChartsHandler rubricBarChartsHandler = new RubricBarChartsHandler(true);
@Override
public EvaluationFormReportHandler getReportHandler(PageElement element) {
if (Rubric.TYPE.equals(element.getType())) {
return rubricBarChartsHandler;
}
return null;
}
}
}
......@@ -42,52 +42,46 @@ import org.olat.modules.forms.EvaluationFormSessionRef;
import org.olat.modules.forms.model.xml.Rubric;
import org.olat.modules.forms.model.xml.Rubric.SliderType;
import org.olat.modules.forms.model.xml.Slider;
import org.olat.modules.forms.model.xml.StepLabel;
import org.olat.modules.forms.ui.component.ResponsiveBarChartComponent;
import org.olat.modules.forms.ui.model.RubricStatistic;
import org.olat.modules.forms.ui.model.SliderStatistic;
/**
*
* Initial date: 25.05.2018<br>
* Initial date: 19.06.2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public class RubricBarChartsController extends FormBasicController {
public abstract class RubricBarChartsController extends FormBasicController {
private final Rubric rubric;
private final List<? extends EvaluationFormSessionRef> sessions;
public RubricBarChartsController(UserRequest ureq, WindowControl wControl, Rubric rubric,
List<? extends EvaluationFormSessionRef> sessions) {
super(ureq, wControl, "rubric_bar_charts");
this.rubric = rubric;
this.sessions = sessions;
initForm(ureq);
}
protected abstract RubricWrapper createRubricWrapper();
public Rubric getRubric() {
return rubric;
}
public List<? extends EvaluationFormSessionRef> getSessions() {
return sessions;
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
flc.contextPut("rubricWrapper", createRubricWrapper());
}
private RubricWrapper createRubricWrapper() {
RubricStatistic rubricStatistic = new RubricStatistic(rubric, sessions);
List<SliderWrapper> sliderWrappers = new ArrayList<>();
for (Slider slider: rubric.getSliders()) {
SliderStatistic sliderStatistic = rubricStatistic.getSliderStatistic(slider);
SliderWrapper sliderWrapper = createSliderWrapper(slider, sliderStatistic);
sliderWrappers.add(sliderWrapper);
}
RubricWrapper rubricWrapper = new RubricWrapper(rubric);
rubricWrapper.setSliders(sliderWrappers);
return rubricWrapper;
}
private SliderWrapper createSliderWrapper(Slider slider, SliderStatistic sliderStatistic) {
protected SliderWrapper createSliderWrapper(String startLabel, String endLabel, SliderStatistic sliderStatistic) {
String barChartName = createChartAndGetName(sliderStatistic);
String tableName = createTableAndGetName(sliderStatistic);
return new SliderWrapper(slider, barChartName, tableName);
return new SliderWrapper(startLabel, endLabel, barChartName, tableName);
}
private String createChartAndGetName(SliderStatistic sliderStatistic) {
......@@ -117,6 +111,7 @@ public class RubricBarChartsController extends FormBasicController {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(StatisticCols.term));
DefaultFlexiColumnModel valueColumn = new DefaultFlexiColumnModel(StatisticCols.value);
valueColumn.setAlignment(FlexiColumnModel.ALIGNMENT_RIGHT);
valueColumn.setHeaderAlignment(FlexiColumnModel.ALIGNMENT_RIGHT);
valueColumn.setFooterCellRenderer(new RubricAvgRenderer(rubric));
columnsModel.addFlexiColumnModel(valueColumn);
......@@ -153,80 +148,21 @@ public class RubricBarChartsController extends FormBasicController {
}
public final static class RubricWrapper {
private final Rubric rubric;
private List<SliderWrapper> sliders;
public RubricWrapper(Rubric rubric) {
this.rubric = rubric;
}
public static int getWidthInPercent(Rubric theRubric) {
if(theRubric.getSliderType() != SliderType.continuous) {
int steps = theRubric.getSteps();
int stepInPercent = Math.round(100.0f / steps) - 1;
return stepInPercent;
}
return 0;
}
private Rubric rubric;
private List<SliderWrapper> sliders;
public int getStepInPercent() {
return getWidthInPercent(rubric);
public RubricWrapper() {
}
public boolean isStepLabels() {
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;
}
public boolean isLeftLabels() {
List<Slider> rubricSliders = rubric.getSliders();
if(rubricSliders != null && rubricSliders.size() > 0) {
for(Slider slider:rubricSliders) {
if(slider != null && StringHelper.containsNonWhitespace(slider.getStartLabel())) {
return true;
}
}
}
return false;
}
public boolean isRightLabels() {
List<Slider> rubricSliders = rubric.getSliders();
if(rubricSliders != null && rubricSliders.size() > 0) {
for(Slider slider:rubricSliders) {
if(slider != null && StringHelper.containsNonWhitespace(slider.getEndLabel())) {
return true;
}
}
}
return false;
public RubricWrapper(Rubric rubric) {
this.rubric = rubric;
}
public List<String> getStepLabels() {
if(rubric.getStepLabels() != null && rubric.getStepLabels().size() > 0) {
List<String> stepLabels = new ArrayList<>(rubric.getStepLabels().size());
for(StepLabel stepLabel:rubric.getStepLabels()) {
stepLabels.add(stepLabel.getLabel());
}
return stepLabels;
}
return new ArrayList<>(1);
}
public List<SliderWrapper> getSliders() {
return sliders;
}
public void setSliders(List<SliderWrapper> sliders) {
this.sliders = sliders;
}
......@@ -244,42 +180,41 @@ public class RubricBarChartsController extends FormBasicController {
return false;
}
}
public static final class SliderWrapper {
private final Slider slider;
private final String startLabel;
private final String endLabel;
private final String chartName;
private final String tableName;
SliderWrapper(Slider slider, String chartName, String tableName) {
SliderWrapper(String startLabel, String endLabel, String chartName, String tableName) {
super();
this.slider = slider;
this.startLabel = startLabel;
this.endLabel = endLabel;
this.chartName = chartName;
this.tableName = tableName;
}
public String getStartLabel() {
String start = slider.getStartLabel();
return start == null ? "" : start;
return startLabel == null ? "" : startLabel;
}
public String getEndLabel() {
String end = slider.getEndLabel();
return end == null ? "" : end;
return endLabel == null ? "" : endLabel;
}
public String getChartName() {
return chartName;
}
public String getTableName() {
return tableName;
}
}
private final static class StatisticRow {
protected final static class StatisticRow {
private final String term;
private final String value;
......@@ -297,8 +232,8 @@ public class RubricBarChartsController extends FormBasicController {
return value;
}
}
private final static class StatisticDataModel extends DefaultFlexiTableDataModel<StatisticRow>
protected final static class StatisticDataModel extends DefaultFlexiTableDataModel<StatisticRow>
implements FlexiTableFooterModel {
private final String footerHeader;
......@@ -339,8 +274,8 @@ public class RubricBarChartsController extends FormBasicController {
return col == 1? average: null;
}
}
private enum StatisticCols implements FlexiColumnDef {
protected enum StatisticCols implements FlexiColumnDef {
term("rubric.report.figure.title"),
value("rubric.report.value.title");
......@@ -356,4 +291,4 @@ public class RubricBarChartsController extends FormBasicController {
}
}
}
}
\ No newline at end of file
......@@ -19,53 +19,43 @@
*/
package org.olat.modules.forms.ui;
import org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiTableDataModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnDef;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel;
import java.util.ArrayList;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.WindowControl;
import org.olat.modules.forms.EvaluationFormSessionRef;
import org.olat.modules.forms.model.xml.Rubric;
import org.olat.modules.forms.model.xml.Slider;
import org.olat.modules.forms.ui.model.RubricStatistic;
import org.olat.modules.forms.ui.model.SliderStatistic;
/**
*
* Initial date: 23.05.2018<br>
* Initial date: 25.05.2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public class RubricsTotalDataModel extends DefaultFlexiTableDataModel<RubricsTotalRow> {
public class RubricSlidersBarChartsController extends RubricBarChartsController {
public RubricsTotalDataModel(FlexiTableColumnModel columnModel) {
super(columnModel);
public RubricSlidersBarChartsController(UserRequest ureq, WindowControl wControl, Rubric rubric,
List<? extends EvaluationFormSessionRef> sessions) {
super(ureq, wControl, rubric, sessions);
initForm(ureq);
}
@Override
public Object getValueAt(int row, int col) {
RubricsTotalRow rubricsTotalRow = getObject(row);
switch (RubricsTotalCols.values()[col]) {
case name: return rubricsTotalRow.getName();
case avg: return EvaluationFormFormatter.formatDouble(rubricsTotalRow.getAverage());
case scale: return rubricsTotalRow.getScale();
default: return null;
}
}
@Override
public DefaultFlexiTableDataModel<RubricsTotalRow> createCopyWithEmptyList() {
return new RubricsTotalDataModel(getTableColumnModel());
}
public enum RubricsTotalCols implements FlexiColumnDef {
name("rubric.report.name.title"),
avg("rubric.report.avg.title"),
scale("rubric.report.scale.title");
private final String i18nKey;
private RubricsTotalCols(String i18nKey) {
this.i18nKey = i18nKey;
}
@Override
public String i18nHeaderKey() {
return i18nKey;
protected RubricWrapper createRubricWrapper() {
RubricStatistic rubricStatistic = new RubricStatistic(getRubric(), getSessions());
List<SliderWrapper> sliderWrappers = new ArrayList<>();
for (Slider slider: getRubric().getSliders()) {
SliderStatistic sliderStatistic = rubricStatistic.getSliderStatistic(slider);
SliderWrapper sliderWrapper = createSliderWrapper(slider.getStartLabel(), slider.getEndLabel(), sliderStatistic);
sliderWrappers.add(sliderWrapper);
}
RubricWrapper rubricWrapper = new RubricWrapper(getRubric());
rubricWrapper.setSliders(sliderWrappers);
return rubricWrapper;
}
}
......@@ -19,36 +19,41 @@
*/
package org.olat.modules.forms.ui;
import java.util.ArrayList;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.WindowControl;
import org.olat.modules.forms.EvaluationFormSessionRef;
import org.olat.modules.forms.model.xml.Rubric;
import org.olat.modules.forms.ui.model.RubricStatistic;
import org.olat.modules.forms.ui.model.SliderStatistic;
/**
*
* Initial date: 23.05.2018<br>
* Initial date: 19.06.2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public class RubricsTotalRow {
private final String name;
private final Double average;
private final String scale;
RubricsTotalRow(String name, Double average, String scale) {
super();
this.name = name;
this.average = average;
this.scale = scale;
}
String getName() {
return name;
public class RubricTotalBarChartsController extends RubricBarChartsController {
public RubricTotalBarChartsController(UserRequest ureq, WindowControl wControl, Rubric rubric,
List<? extends EvaluationFormSessionRef> sessions) {
super(ureq, wControl, rubric, sessions);
initForm(ureq);
}
Double getAverage() {
return average;
}
String getScale() {
return scale;
@Override
protected RubricWrapper createRubricWrapper() {
String name = translate("rubric.report.total", new String[] {getRubric().getName()});
RubricStatistic rubricStatistic = new RubricStatistic(getRubric(), getSessions());
SliderStatistic totalStatistic = rubricStatistic.getTotalStatistic();
List<SliderWrapper> sliderWrappers = new ArrayList<>();
SliderWrapper sliderWrapper = createSliderWrapper(name, null, totalStatistic);
sliderWrappers.add(sliderWrapper);
RubricWrapper rubricWrapper = new RubricWrapper(getRubric());
rubricWrapper.setSliders(sliderWrappers);
return rubricWrapper;
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.forms.ui;
import java.util.ArrayList;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.FlexiTableElement;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel;
import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.modules.forms.EvaluationFormSessionRef;
import org.olat.modules.forms.model.xml.AbstractElement;
import org.olat.modules.forms.model.xml.Form;
import org.olat.modules.forms.model.xml.Rubric;
import org.olat.modules.forms.model.xml.ScaleType;
import org.olat.modules.forms.ui.RubricsTotalDataModel.RubricsTotalCols;
import org.olat.modules.forms.ui.model.RubricStatistic;
/**
*
* Initial date: 23.05.2018<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public class RubricsTotalController extends FormBasicController {
private final Form form;
private final List<? extends EvaluationFormSessionRef> sessions;
private RubricsTotalDataModel dataModel;
private FlexiTableElement tableEl;
public RubricsTotalController(UserRequest ureq, WindowControl wControl, Form form,
List<? extends EvaluationFormSessionRef> sessions) {
super(ureq, wControl, LAYOUT_HORIZONTAL);
this.form = form;
this.sessions = sessions;
initForm(ureq);
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RubricsTotalCols.name));
DefaultFlexiColumnModel avgColumn = new DefaultFlexiColumnModel(RubricsTotalCols.avg);
avgColumn.setAlignment(FlexiColumnModel.ALIGNMENT_RIGHT);
columnsModel.addFlexiColumnModel(avgColumn);
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RubricsTotalCols.scale));
dataModel = new RubricsTotalDataModel(columnsModel);
tableEl = uifactory.addTableElement(getWindowControl(), "total", dataModel, getTranslator(), formLayout);
tableEl.setCustomizeColumns(false);
tableEl.setNumOfRowsEnabled(false);
loadModel();
}
private void loadModel() {
List<RubricsTotalRow> rubricTotalRows = new ArrayList<>();
for (AbstractElement element: form.getElements()) {
if (element instanceof Rubric) {
Rubric rubric = (Rubric) element;
RubricStatistic rubricStatistic = new RubricStatistic(rubric, sessions);
String name = translate("rubric.report.total", new String[] {rubric.getName()});
Double avg = rubricStatistic.getTotalStatistic().getAvg();
ScaleType scaleType = rubric.getScaleType();
double minStep = scaleType.getStepValue(rubric.getSteps(), rubric.getStart());
double maxStep = scaleType.getStepValue(rubric.getSteps(), rubric.getEnd());
String scale = translate("rubric.report.scale", new String[] { String.valueOf(minStep), String.valueOf(maxStep)});
RubricsTotalRow row = new RubricsTotalRow(name, avg, scale);
rubricTotalRows.add(row);
}
}
dataModel.setObjects(rubricTotalRows);
tableEl.reset();
}
@Override
protected void formOK(UserRequest ureq) {
//
}
@Override
protected void doDispose() {
//
}
}
......@@ -100,8 +100,6 @@ rubric.report.median.title=Median
rubric.report.name.title=
rubric.report.number.no.responses.title="$\:no.response"
rubric.report.number.responses.title=Antworten
rubric.report.scale={0} bis {1}
rubric.report.scale.title=Skala
rubric.report.sdtdev.title=Standardabweichung
rubric.report.start.label.title=
rubric.report.total=Gesamttotal {0}
......
......@@ -105,8 +105,6 @@ rubric.report.median.title=Median
rubric.report.name.title=
rubric.report.number.no.responses.title="$\:no.response"
rubric.report.number.responses.title=Answers
rubric.report.scale={0} to {1}
rubric.report.scale.title=Scale
rubric.report.sdtdev.title=Standard deviation
rubric.report.start.label.title=
rubric.report.total=Total {0}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment