use of org.olat.ims.qti.statistics.model.StatisticChoiceOption in project OpenOLAT by OpenOLAT.
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.ims.qti.statistics.model.StatisticChoiceOption 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.ims.qti.statistics.model.StatisticChoiceOption in project openolat by klemens.
the class QTIStatisticsManagerImpl method getNumOfRightAnsweredMultipleChoice.
/**
* calculates the percentage of participants that answered a answer option
* correctly.<br>
* Number at index 0 = answer option 1, Number at index 1 = answer option 2,
* etc.
*
* @param item
* @param numberOfParticipants
* @param olatResource
* @param olatResourceDetail
* @return
*/
@Override
public List<StatisticChoiceOption> getNumOfRightAnsweredMultipleChoice(Item item, QTIStatisticSearchParams searchParams) {
List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
List<Response> responses = item.getQuestion().getResponses();
List<StatisticChoiceOption> percentageRightAnswered = new ArrayList<StatisticChoiceOption>();
for (Response response : responses) {
String answerIdent = response.getIdent();
long num = 0;
for (StatisticAnswerOption answerToNumber : answerToNumberList) {
String answer = answerToNumber.getAnswer();
if (answer.indexOf(answerIdent) >= 0) {
num += answerToNumber.getCount();
}
}
percentageRightAnswered.add(new StatisticChoiceOption(response, num));
}
return percentageRightAnswered;
}
use of org.olat.ims.qti.statistics.model.StatisticChoiceOption in project openolat by klemens.
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 QTIStatisticsManagerImpl method getNumOfRightAnsweredMultipleChoice.
/**
* calculates the percentage of participants that answered a answer option
* correctly.<br>
* Number at index 0 = answer option 1, Number at index 1 = answer option 2,
* etc.
*
* @param item
* @param numberOfParticipants
* @param olatResource
* @param olatResourceDetail
* @return
*/
@Override
public List<StatisticChoiceOption> getNumOfRightAnsweredMultipleChoice(Item item, QTIStatisticSearchParams searchParams) {
List<StatisticAnswerOption> answerToNumberList = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
List<Response> responses = item.getQuestion().getResponses();
List<StatisticChoiceOption> percentageRightAnswered = new ArrayList<StatisticChoiceOption>();
for (Response response : responses) {
String answerIdent = response.getIdent();
long num = 0;
for (StatisticAnswerOption answerToNumber : answerToNumberList) {
String answer = answerToNumber.getAnswer();
if (answer.indexOf(answerIdent) >= 0) {
num += answerToNumber.getCount();
}
}
percentageRightAnswered.add(new StatisticChoiceOption(response, num));
}
return percentageRightAnswered;
}
Aggregations