use of org.olat.core.gui.components.chart.BarSeries in project openolat by klemens.
the class StatisticDisplayController method generateCharts.
private void generateCharts(Graph graph) {
statisticVc_.contextPut("hasChart", Boolean.FALSE);
statisticVc_.contextPut("hasChartError", Boolean.FALSE);
if (graph == null || graph.numElements == 0) {
Component ic = getInitialComponent();
if (ic != null) {
ic.setDirty(true);
}
return;
}
try {
statisticVc_.contextPut("chartAlt", getTranslator().translate("chart.alt"));
statisticVc_.contextPut("chartIntro", graph.chartIntroStr);
statisticVc_.contextPut("hasChart", Boolean.TRUE);
statisticVc_.contextPut("hasChartError", Boolean.FALSE);
BarChartComponent chartCmp = new BarChartComponent("stats");
List<String> labels = graph.getLabels();
List<Integer> values = graph.getValues();
BarSeries serie = new BarSeries();
for (int i = 0; i < labels.size(); i++) {
double value = values.get(i).doubleValue();
String category = labels.get(i);
serie.add(value, category);
}
chartCmp.addSeries(serie);
statisticVc_.put("chart", chartCmp);
} catch (RuntimeException re) {
log_.warn("generateCharts: RuntimeException during chart generation: " + re, re);
}
Component ic = getInitialComponent();
if (ic != null) {
ic.setDirty(true);
}
}
use of org.olat.core.gui.components.chart.BarSeries in project openolat by klemens.
the class SeriesFactory method getMultipleChoice.
public Series getMultipleChoice(Item item, StatisticsItem itemStats) {
List<StatisticChoiceOption> statisticResponses = qtiStatisticsManager.getNumOfRightAnsweredMultipleChoice(item, resourceResult.getSearchParams());
BarSeries d1 = new BarSeries("bar_green", "green", translate("answer.correct"));
BarSeries d2 = new BarSeries("bar_red", "red", translate("answer.false"));
BarSeries d3 = new BarSeries("bar_grey", "grey", translate("answer.noanswer"));
String mediaBaseURL = resourceResult.getMediaBaseURL();
boolean survey = QTIType.survey.equals(resourceResult.getType());
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
int notAnswered = numOfParticipants - (itemStats == null ? 0 : itemStats.getNumOfResults());
int i = 0;
List<ResponseInfos> responseInfos = new ArrayList<>();
for (StatisticChoiceOption statisticResponse : statisticResponses) {
Response response = statisticResponse.getResponse();
String text = response.getContent().renderAsHtml(mediaBaseURL);
float points = response.getPoints();
double answersPerAnswerOption = statisticResponse.getCount();
double rightA;
double wrongA;
if (survey) {
rightA = answersPerAnswerOption;
wrongA = 0d;
} else if (points > 0.00001f) {
rightA = answersPerAnswerOption;
wrongA = numOfParticipants - notAnswered - answersPerAnswerOption;
} else {
// minus negative points are not answered right?
rightA = numOfParticipants - notAnswered - answersPerAnswerOption;
wrongA = answersPerAnswerOption;
}
String label = Integer.toString(++i);
d1.add(rightA, label);
d2.add(wrongA, label);
d3.add(notAnswered, label);
Float pointsObj = survey ? null : points;
responseInfos.add(new ResponseInfos(label, text, pointsObj, (points > 0f), survey, false));
}
List<BarSeries> serieList = new ArrayList<>(3);
serieList.add(d1);
if (!survey) {
serieList.add(d2);
serieList.add(d3);
}
Series series = new Series(serieList, responseInfos, numOfParticipants, !survey);
series.setChartType(survey ? BAR_ANSWERED : BAR_CORRECT_WRONG_NOT);
series.setItemCss(getCssClass(item));
return series;
}
use of org.olat.core.gui.components.chart.BarSeries in project openolat by klemens.
the class SeriesFactory method getKPrim.
public Series getKPrim(Item item) {
List<StatisticKPrimOption> statisticResponses = qtiStatisticsManager.getNumbersInKPrim(item, resourceResult.getSearchParams());
String mediaBaseURL = resourceResult.getMediaBaseURL();
boolean survey = QTIType.survey.equals(resourceResult.getType());
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
int i = 0;
BarSeries d1 = new BarSeries("bar_green", "green", translate("answer.correct"));
BarSeries d2 = new BarSeries("bar_red", "red", translate("answer.false"));
BarSeries d3 = new BarSeries("bar_grey", "grey", translate("answer.noanswer"));
List<ResponseInfos> responseInfos = new ArrayList<>();
for (StatisticKPrimOption statisticResponse : statisticResponses) {
Response response = statisticResponse.getResponse();
boolean correct = response.isCorrect();
double right = statisticResponse.getNumOfCorrect();
double wrong = statisticResponse.getNumOfIncorrect();
double notanswered = numOfParticipants - right - wrong;
String label = Integer.toString(++i);
d1.add(right, label);
d2.add(wrong, label);
d3.add(notanswered, label);
String text = response.getContent().renderAsHtml(mediaBaseURL);
responseInfos.add(new ResponseInfos(label, text, null, correct, survey, true));
}
List<BarSeries> serieList = new ArrayList<>(3);
serieList.add(d1);
serieList.add(d2);
serieList.add(d3);
Series series = new Series(serieList, responseInfos, numOfParticipants, !survey);
series.setChartType(survey ? BAR_ANSWERED : BAR_CORRECT_WRONG_NOT);
series.setItemCss(getCssClass(item));
return series;
}
use of org.olat.core.gui.components.chart.BarSeries in project openolat by klemens.
the class QTI12AssessmentStatisticsController method initScoreStatisticPerItem.
private void initScoreStatisticPerItem(List<Item> items, double numOfParticipants) {
BarSeries d1 = new BarSeries();
BarSeries d2 = new BarSeries();
List<StatisticItem> statisticItems = qtiStatisticsManager.getStatisticPerItem(items, resourceResult.getSearchParams(), numOfParticipants);
int i = 0;
List<ItemInfos> itemInfos = new ArrayList<>(items.size());
for (StatisticItem statisticItem : statisticItems) {
Item item = statisticItem.getItem();
String label = Integer.toString(++i);
String text = item.getTitle();
d1.add(statisticItem.getAverageScore(), label);
double numOfRightAnswers = statisticItem.getNumOfCorrectAnswers();
double res = numOfRightAnswers;
d2.add(res, label);
itemInfos.add(new ItemInfos(label, text));
}
mainVC.contextPut("itemInfoList", itemInfos);
VelocityContainer averageScorePeritemVC = createVelocityContainer("hbar_average_score_per_item");
Stringuified data1 = BarSeries.getDatasAndColors(Collections.singletonList(d1), "bar_default");
averageScorePeritemVC.contextPut("datas", data1);
mainVC.put("averageScorePerItemChart", averageScorePeritemVC);
VelocityContainer percentRightAnswersPerItemVC = createVelocityContainer("hbar_right_answer_per_item");
Stringuified data2 = BarSeries.getDatasAndColors(Collections.singletonList(d2), "bar_green");
percentRightAnswersPerItemVC.contextPut("datas", data2);
percentRightAnswersPerItemVC.contextPut("numOfParticipants", Long.toString(Math.round(numOfParticipants)));
mainVC.put("percentRightAnswersPerItemChart", percentRightAnswersPerItemVC);
}
use of org.olat.core.gui.components.chart.BarSeries in project openolat by klemens.
the class QTI21AssessmentTestStatisticsController method initScoreStatisticPerItem.
/**
* The 2 graphs with the score per questions and right answers per questions.
*
* @param numOfParticipants The number of participants
*/
private void initScoreStatisticPerItem(double numOfParticipants) {
BarSeries d1 = new BarSeries();
BarSeries d2 = new BarSeries();
List<AssessmentItemStatistic> statisticItems = qtiStatisticsManager.getStatisticPerItem(resourceResult.getResolvedAssessmentTest(), resourceResult.getSearchParams(), numOfParticipants);
int i = 0;
List<ItemInfos> itemInfos = new ArrayList<>(statisticItems.size());
for (AssessmentItemStatistic statisticItem : statisticItems) {
AssessmentItem item = statisticItem.getAssessmentItem();
String label = Integer.toString(++i);
String text = item.getTitle();
d1.add(statisticItem.getAverageScore(), label);
d2.add(statisticItem.getNumOfCorrectAnswers(), label);
itemInfos.add(new ItemInfos(label, text));
}
mainVC.contextPut("itemInfoList", itemInfos);
VelocityContainer averageScorePeritemVC = createVelocityContainer("hbar_average_score_per_item");
Stringuified data1 = BarSeries.getDatasAndColors(Collections.singletonList(d1), "bar_default");
averageScorePeritemVC.contextPut("datas", data1);
mainVC.put("averageScorePerItemChart", averageScorePeritemVC);
VelocityContainer percentRightAnswersPerItemVC = createVelocityContainer("hbar_right_answer_per_item");
Stringuified data2 = BarSeries.getDatasAndColors(Collections.singletonList(d2), "bar_green");
percentRightAnswersPerItemVC.contextPut("datas", data2);
percentRightAnswersPerItemVC.contextPut("numOfParticipants", Long.toString(Math.round(numOfParticipants)));
mainVC.put("percentRightAnswersPerItemChart", percentRightAnswersPerItemVC);
}
Aggregations