use of org.olat.core.gui.components.chart.BarSeries in project OpenOLAT by OpenOLAT.
the class HotspotInteractionStatisticsController method getMultipleChoice.
private Series getMultipleChoice(StatisticsItem itemStats, List<HotspotChoiceStatistics> statisticResponses) {
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"));
boolean survey = QTIType.survey.equals(resourceResult.getType());
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
int notAnswered = numOfParticipants - (itemStats == null ? 0 : itemStats.getNumOfResults());
List<Identifier> correctAnswers = getCorrectResponses();
int i = 0;
List<ResponseInfos> responseInfos = new ArrayList<>();
for (HotspotChoiceStatistics statisticResponse : statisticResponses) {
HotspotChoice choice = statisticResponse.getChoice();
String text = getAnswerText(choice);
boolean correct = correctAnswers.contains(choice.getIdentifier());
double answersPerAnswerOption = statisticResponse.getCount();
double rightA;
double wrongA;
if (survey) {
rightA = answersPerAnswerOption;
wrongA = 0d;
} else if (correct) {
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 : (correct ? 1.0f : 0.0f);
responseInfos.add(new ResponseInfos(label, text, pointsObj, correct, 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 ? SeriesFactory.BAR_ANSWERED : SeriesFactory.BAR_CORRECT_WRONG_NOT);
series.setItemCss("o_qti_scitem");
return series;
}
use of org.olat.core.gui.components.chart.BarSeries in project OpenOLAT by OpenOLAT.
the class KPrimStatisticsController method getKPrim.
public Series getKPrim() {
List<KPrimStatistics> statisticResponses = qtiStatisticsManager.getKPrimStatistics(itemRef.getIdentifier().toString(), assessmentItem, interaction, resourceResult.getSearchParams());
// TODO String mediaBaseURL = resourceResult.getMediaBaseURL();
boolean survey = QTIType.survey.equals(resourceResult.getType());
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
List<SimpleMatchSet> matchSets = interaction.getSimpleMatchSets();
SimpleMatchSet fourMatchSet = matchSets.get(0);
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 (KPrimStatistics statisticResponse : statisticResponses) {
Identifier choiceIdentifier = statisticResponse.getChoiceIdentifier();
boolean correctRight = statisticResponse.isCorrectRight();
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 = "";
for (SimpleAssociableChoice choice : fourMatchSet.getSimpleAssociableChoices()) {
if (choice.getIdentifier().equals(choiceIdentifier)) {
String textFlow = assessmentHtmlBuilder.flowStaticString(choice.getFlowStatics());
text = Formatter.formatLatexFormulas(textFlow);
}
}
responseInfos.add(new ResponseInfos(label, text, null, correctRight, 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 ? SeriesFactory.BAR_ANSWERED : SeriesFactory.BAR_CORRECT_WRONG_NOT);
series.setItemCss("o_mi_qtikprim");
return series;
}
use of org.olat.core.gui.components.chart.BarSeries in project OpenOLAT by OpenOLAT.
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);
}
use of org.olat.core.gui.components.chart.BarSeries in project OpenOLAT by OpenOLAT.
the class ChoiceInteractionStatisticsController method getSingleChoice.
private Series getSingleChoice() {
List<ChoiceStatistics> statisticResponses = getChoiceInteractionStatistics();
boolean survey = QTIType.survey.equals(resourceResult.getType());
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(assessmentItem, interaction);
int i = 0;
long numOfResults = 0;
BarSeries d1 = new BarSeries();
List<ResponseInfos> responseInfos = new ArrayList<>();
for (ChoiceStatistics statisticResponse : statisticResponses) {
Choice choice = statisticResponse.getChoice();
String text = getAnswerText(choice);
double ans_count = statisticResponse.getCount();
numOfResults += statisticResponse.getCount();
boolean correct = correctAnswers.contains(choice.getIdentifier());
Float points;
String cssColor;
if (survey) {
points = null;
cssColor = "bar_default";
} else {
Double mappedValue = CorrectResponsesUtil.getMappedValue(assessmentItem, interaction, choice);
if (mappedValue != null) {
points = mappedValue.floatValue();
} else {
// response.getPoints();
points = correct ? 1.0f : 0.0f;
}
cssColor = correct ? "bar_green" : "bar_red";
}
String label = Integer.toString(++i);
d1.add(ans_count, label, cssColor);
responseInfos.add(new ResponseInfos(label, text, points, correct, 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(SeriesFactory.BAR_CORRECT);
series.setItemCss("o_qti_scitem");
return series;
}
use of org.olat.core.gui.components.chart.BarSeries in project OpenOLAT by OpenOLAT.
the class ChoiceInteractionStatisticsController method getMultipleChoice.
private Series getMultipleChoice(StatisticsItem itemStats) {
List<ChoiceStatistics> statisticResponses = getChoiceInteractionStatistics();
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"));
boolean survey = QTIType.survey.equals(resourceResult.getType());
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
int notAnswered = numOfParticipants - (itemStats == null ? 0 : itemStats.getNumOfResults());
List<Identifier> correctAnswers = CorrectResponsesUtil.getCorrectIdentifierResponses(assessmentItem, interaction);
int i = 0;
List<ResponseInfos> responseInfos = new ArrayList<>();
for (ChoiceStatistics statisticResponse : statisticResponses) {
Choice choice = statisticResponse.getChoice();
String text = getAnswerText(choice);
boolean correct = correctAnswers.contains(choice.getIdentifier());
double answersPerAnswerOption = statisticResponse.getCount();
double rightA;
double wrongA;
if (survey) {
rightA = answersPerAnswerOption;
wrongA = 0d;
} else if (correct) {
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;
if (survey) {
pointsObj = null;
} else {
Double mappedValue = CorrectResponsesUtil.getMappedValue(assessmentItem, interaction, choice);
if (mappedValue != null) {
pointsObj = mappedValue.floatValue();
} else {
pointsObj = correct ? 1.0f : 0.0f;
}
}
responseInfos.add(new ResponseInfos(label, text, pointsObj, correct, 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 ? SeriesFactory.BAR_ANSWERED : SeriesFactory.BAR_CORRECT_WRONG_NOT);
series.setItemCss("o_qti_scitem");
return series;
}
Aggregations