use of org.olat.core.gui.components.chart.BarSeries in project OpenOLAT by OpenOLAT.
the class TextEntryInteractionsStatisticsController method getFIB.
private Series getFIB() {
List<AbstractTextEntryInteractionStatistics> processedAnswers = qtiStatisticsManager.getTextEntryInteractionsStatistic(itemRef.getIdentifier().toString(), assessmentItem, interactions, resourceResult.getSearchParams());
boolean survey = QTIType.survey.equals(resourceResult.getType());
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
int i = 0;
String cssColor = survey ? "bar_default" : "bar_green";
String color = survey ? null : "green";
BarSeries d1 = new BarSeries(cssColor, color, null);
List<ResponseInfos> responseInfos = new ArrayList<>();
for (AbstractTextEntryInteractionStatistics entry : processedAnswers) {
String label = Integer.toString(++i);
String answerString = entry.getCorrectResponse();
d1.add(entry.getNumOfCorrect(), label, cssColor);
StringBuilder text = new StringBuilder();
text.append(answerString);
if (entry instanceof TextEntryInteractionStatistics) {
TextEntryInteractionStatistics textEntry = (TextEntryInteractionStatistics) entry;
if (textEntry.getAlternatives().size() > 1) {
text.append(" [");
for (int j = 1; j < textEntry.getAlternatives().size(); j++) {
if (j > 1)
text.append(", ");
text.append(textEntry.getAlternatives().get(j));
}
text.append("]");
}
}
Float score = entry.getPoints() == null ? null : entry.getPoints().floatValue();
responseInfos.add(new ResponseInfos(label, text.toString(), entry.getWrongAnswers(), score, true, survey, false));
}
List<BarSeries> serieList = Collections.singletonList(d1);
Series series = new Series(serieList, responseInfos, numOfParticipants, false);
series.setChartType(SeriesFactory.BAR_ANSWERED);
series.setItemCss("o_mi_qtifib");
return series;
}
use of org.olat.core.gui.components.chart.BarSeries in project openolat by klemens.
the class SeriesFactory method getFIB.
public Series getFIB(Item item) {
List<StatisticFIBOption> processedAnswers = qtiStatisticsManager.getStatisticAnswerOptionsFIB(item, resourceResult.getSearchParams());
boolean survey = QTIType.survey.equals(resourceResult.getType());
boolean singleCorrectScore = item.getQuestion().getSingleCorrectScore() > 0.0f;
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
int i = 0;
String cssColor = survey ? "bar_default" : "bar_green";
String color = survey ? null : "green";
BarSeries d1 = new BarSeries(cssColor, color, null);
List<ResponseInfos> responseInfos = new ArrayList<>();
for (StatisticFIBOption entry : processedAnswers) {
String label = Integer.toString(++i);
String answerString = entry.getCorrectBlank();
d1.add(entry.getNumOfCorrect(), label, cssColor);
StringBuilder text = new StringBuilder();
text.append(answerString);
if (entry.getAlternatives().size() > 1) {
text.append(" [");
for (int j = 1; j < entry.getAlternatives().size(); j++) {
if (j > 1)
text.append(", ");
text.append(entry.getAlternatives().get(j));
}
text.append("]");
}
Float score = singleCorrectScore ? null : entry.getPoints();
responseInfos.add(new ResponseInfos(label, text.toString(), entry.getWrongAnswers(), score, true, survey, false));
}
List<BarSeries> serieList = Collections.singletonList(d1);
Series series = new Series(serieList, responseInfos, numOfParticipants, false);
series.setChartType(BAR_ANSWERED);
series.setItemCss(getCssClass(item));
return series;
}
use of org.olat.core.gui.components.chart.BarSeries in project openolat by klemens.
the class SeriesFactory method getSingleChoice.
public Series getSingleChoice(Item item) {
List<StatisticChoiceOption> statisticResponses = qtiStatisticsManager.getNumOfAnswersPerSingleChoiceAnswerOption(item, resourceResult.getSearchParams());
String mediaBaseURL = resourceResult.getMediaBaseURL();
boolean survey = QTIType.survey.equals(resourceResult.getType());
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
int i = 0;
long numOfResults = 0;
BarSeries d1 = new BarSeries();
List<ResponseInfos> responseInfos = new ArrayList<>();
for (StatisticChoiceOption statisticResponse : statisticResponses) {
Response response = statisticResponse.getResponse();
double ans_count = statisticResponse.getCount();
numOfResults += statisticResponse.getCount();
Float points;
String cssColor;
if (survey) {
points = null;
cssColor = "bar_default";
} else {
points = response.getPoints();
cssColor = response.isCorrect() ? "bar_green" : "bar_red";
}
String label = Integer.toString(++i);
d1.add(ans_count, label, cssColor);
String text = response.getContent().renderAsHtml(mediaBaseURL);
responseInfos.add(new ResponseInfos(label, text, points, response.isCorrect(), survey, false));
}
if (numOfResults != numOfParticipants) {
long notAnswered = numOfParticipants - numOfResults;
if (notAnswered > 0) {
String label = Integer.toString(++i);
String text = translate("user.not.answer");
responseInfos.add(new ResponseInfos(label, text, null, false, survey, false));
d1.add(notAnswered, label, "bar_grey");
}
}
List<BarSeries> serieList = Collections.singletonList(d1);
Series series = new Series(serieList, responseInfos, numOfParticipants, false);
series.setChartType(BAR_CORRECT);
series.setItemCss(getCssClass(item));
return series;
}
use of org.olat.core.gui.components.chart.BarSeries in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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);
}
}
Aggregations