use of org.olat.ims.qti.statistics.model.StatisticFIBOption in project OpenOLAT by OpenOLAT.
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.ims.qti.statistics.model.StatisticFIBOption 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.ims.qti.statistics.model.StatisticFIBOption in project OpenOLAT by OpenOLAT.
the class QTIStatisticsManagerImpl method getStatisticAnswerOptionsFIB.
@Override
public List<StatisticFIBOption> getStatisticAnswerOptionsFIB(Item item, QTIStatisticSearchParams searchParams) {
List<StatisticFIBOption> options = new ArrayList<>();
Map<String, StatisticFIBOption> optionMap = new HashMap<>();
boolean groupBy = true;
List<Response> responses = item.getQuestion().getResponses();
for (Response response : responses) {
if (response instanceof FIBResponse) {
FIBResponse fibResponse = (FIBResponse) response;
if (FIBResponse.TYPE_BLANK.equals(fibResponse.getType())) {
String ident = fibResponse.getIdent();
String[] correctFIBs = fibResponse.getCorrectBlank().split(";");
if (correctFIBs == null || correctFIBs.length == 0) {
continue;
}
StatisticFIBOption option = new StatisticFIBOption();
option.setCorrectBlank(correctFIBs[0]);
option.setAlternatives(Arrays.asList(correctFIBs));
boolean caseSensitive = "Yes".equals(fibResponse.getCaseSensitive());
groupBy &= !caseSensitive;
option.setCaseSensitive(caseSensitive);
option.setPoints(fibResponse.getPoints());
options.add(option);
optionMap.put(ident, option);
}
}
}
List<StatisticAnswerOption> answerOptions = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams, groupBy);
for (StatisticAnswerOption answerOption : answerOptions) {
long count = answerOption.getCount();
String concatenedAnswer = answerOption.getAnswer();
Map<String, String> parsedAnswerMap = QTIResultManager.parseResponseStrAnswers(concatenedAnswer);
for (Map.Entry<String, String> parsedAnswerEntry : parsedAnswerMap.entrySet()) {
String ident = parsedAnswerEntry.getKey();
StatisticFIBOption option = optionMap.get(ident);
if (option == null) {
continue;
}
String text = parsedAnswerEntry.getValue();
boolean correct;
if (option.isCaseSensitive()) {
correct = option.getAlternatives().contains(text);
} else {
correct = false;
for (String alt : option.getAlternatives()) {
if (alt.equalsIgnoreCase(text)) {
correct = true;
}
}
}
if (correct) {
option.setNumOfCorrect(option.getNumOfCorrect() + count);
} else {
option.setNumOfIncorrect(option.getNumOfIncorrect() + count);
option.getWrongAnswers().add(text);
}
}
}
return options;
}
use of org.olat.ims.qti.statistics.model.StatisticFIBOption in project openolat by klemens.
the class QTIStatisticsManagerImpl method getStatisticAnswerOptionsFIB.
@Override
public List<StatisticFIBOption> getStatisticAnswerOptionsFIB(Item item, QTIStatisticSearchParams searchParams) {
List<StatisticFIBOption> options = new ArrayList<>();
Map<String, StatisticFIBOption> optionMap = new HashMap<>();
boolean groupBy = true;
List<Response> responses = item.getQuestion().getResponses();
for (Response response : responses) {
if (response instanceof FIBResponse) {
FIBResponse fibResponse = (FIBResponse) response;
if (FIBResponse.TYPE_BLANK.equals(fibResponse.getType())) {
String ident = fibResponse.getIdent();
String[] correctFIBs = fibResponse.getCorrectBlank().split(";");
if (correctFIBs == null || correctFIBs.length == 0) {
continue;
}
StatisticFIBOption option = new StatisticFIBOption();
option.setCorrectBlank(correctFIBs[0]);
option.setAlternatives(Arrays.asList(correctFIBs));
boolean caseSensitive = "Yes".equals(fibResponse.getCaseSensitive());
groupBy &= !caseSensitive;
option.setCaseSensitive(caseSensitive);
option.setPoints(fibResponse.getPoints());
options.add(option);
optionMap.put(ident, option);
}
}
}
List<StatisticAnswerOption> answerOptions = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams, groupBy);
for (StatisticAnswerOption answerOption : answerOptions) {
long count = answerOption.getCount();
String concatenedAnswer = answerOption.getAnswer();
Map<String, String> parsedAnswerMap = QTIResultManager.parseResponseStrAnswers(concatenedAnswer);
for (Map.Entry<String, String> parsedAnswerEntry : parsedAnswerMap.entrySet()) {
String ident = parsedAnswerEntry.getKey();
StatisticFIBOption option = optionMap.get(ident);
if (option == null) {
continue;
}
String text = parsedAnswerEntry.getValue();
boolean correct;
if (option.isCaseSensitive()) {
correct = option.getAlternatives().contains(text);
} else {
correct = false;
for (String alt : option.getAlternatives()) {
if (alt.equalsIgnoreCase(text)) {
correct = true;
}
}
}
if (correct) {
option.setNumOfCorrect(option.getNumOfCorrect() + count);
} else {
option.setNumOfIncorrect(option.getNumOfIncorrect() + count);
option.getWrongAnswers().add(text);
}
}
}
return options;
}
Aggregations