use of org.olat.ims.qti.statistics.model.StatisticChoiceOption in project OpenOLAT by OpenOLAT.
the class QTIStatisticsManagerImpl method getNumOfAnswersPerSingleChoiceAnswerOption.
/**
* calculates how many participants selected answer option 1 and/or option 2
* and/or option 3...
*
* @param aQuestion
* @param olatResource
* @param olatResourceDetail
* @return
*/
@Override
public List<StatisticChoiceOption> getNumOfAnswersPerSingleChoiceAnswerOption(Item item, QTIStatisticSearchParams searchParams) {
List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
List<Response> answerOptions = item.getQuestion().getResponses();
List<StatisticChoiceOption> numOfAnswersPerOption = new ArrayList<>();
for (int i = 0; i < answerOptions.size(); i++) {
Response response = answerOptions.get(i);
String responseIdent = response.getIdent();
long num = 0;
for (StatisticAnswerOption answerToNumber : answerToNumberList) {
String answer = answerToNumber.getAnswer();
if (answer.indexOf(responseIdent) >= 0) {
num += answerToNumber.getCount();
}
}
numOfAnswersPerOption.add(new StatisticChoiceOption(response, num));
}
return numOfAnswersPerOption;
}
use of org.olat.ims.qti.statistics.model.StatisticChoiceOption 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.ims.qti.statistics.model.StatisticChoiceOption 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;
}
Aggregations