use of org.olat.ims.qti.statistics.model.StatisticAnswerOption 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.StatisticAnswerOption in project OpenOLAT by OpenOLAT.
the class QTIStatisticsManagerImpl method getNumbersInKPrim.
@Override
public List<StatisticKPrimOption> getNumbersInKPrim(Item item, QTIStatisticSearchParams searchParams) {
List<StatisticAnswerOption> rawDatas = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
List<Response> responses = item.getQuestion().getResponses();
List<StatisticKPrimOption> kprimPoints = new ArrayList<>();
for (Response response : responses) {
String answerIdent = response.getIdent();
boolean isCorrect = response.isCorrect();
String rightFlag = answerIdent + ":" + (isCorrect ? "correct" : "wrong");
String wrongFlag = answerIdent + ":" + (isCorrect ? "wrong" : "correct");
long numCorrect = 0;
long numIncorrect = 0;
long numUnanswered = 0;
for (StatisticAnswerOption rawData : rawDatas) {
String answer = rawData.getAnswer();
if (answer.indexOf(rightFlag) >= 0) {
numCorrect += rawData.getCount();
} else if (answer.indexOf(wrongFlag) >= 0) {
numIncorrect += rawData.getCount();
} else {
numUnanswered += rawData.getCount();
}
}
kprimPoints.add(new StatisticKPrimOption(response, numCorrect, numIncorrect, numUnanswered));
}
return kprimPoints;
}
use of org.olat.ims.qti.statistics.model.StatisticAnswerOption 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.StatisticAnswerOption 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;
}
use of org.olat.ims.qti.statistics.model.StatisticAnswerOption in project openolat by klemens.
the class QTIStatisticsManagerImpl method getNumbersInKPrim.
@Override
public List<StatisticKPrimOption> getNumbersInKPrim(Item item, QTIStatisticSearchParams searchParams) {
List<StatisticAnswerOption> rawDatas = getStatisticAnswerOptionsOfItem(item.getIdent(), searchParams);
List<Response> responses = item.getQuestion().getResponses();
List<StatisticKPrimOption> kprimPoints = new ArrayList<>();
for (Response response : responses) {
String answerIdent = response.getIdent();
boolean isCorrect = response.isCorrect();
String rightFlag = answerIdent + ":" + (isCorrect ? "correct" : "wrong");
String wrongFlag = answerIdent + ":" + (isCorrect ? "wrong" : "correct");
long numCorrect = 0;
long numIncorrect = 0;
long numUnanswered = 0;
for (StatisticAnswerOption rawData : rawDatas) {
String answer = rawData.getAnswer();
if (answer.indexOf(rightFlag) >= 0) {
numCorrect += rawData.getCount();
} else if (answer.indexOf(wrongFlag) >= 0) {
numIncorrect += rawData.getCount();
} else {
numUnanswered += rawData.getCount();
}
}
kprimPoints.add(new StatisticKPrimOption(response, numCorrect, numIncorrect, numUnanswered));
}
return kprimPoints;
}
Aggregations