use of org.olat.ims.qti21.model.statistics.KPrimStatistics in project OpenOLAT by OpenOLAT.
the class QTI21StatisticsManagerImpl method getKPrimStatistics.
// stringuifiedResponse: [a93247453265982 correct][b93247453265983 correct][c93247453265984 correct][d93247453265985 correct]
@Override
public List<KPrimStatistics> getKPrimStatistics(String itemRefIdent, AssessmentItem item, MatchInteraction interaction, QTI21StatisticSearchParams searchParams) {
List<RawData> rawDatas = getRawDatas(itemRefIdent, interaction.getResponseIdentifier().toString(), searchParams);
List<SimpleMatchSet> matchSets = interaction.getSimpleMatchSets();
List<KPrimStatistics> kprimPoints = new ArrayList<>();
SimpleMatchSet fourMatchSet = matchSets.get(0);
ResponseDeclaration responseDeclaration = item.getResponseDeclaration(interaction.getResponseIdentifier());
// readable responses
Set<String> rightResponses = new HashSet<>();
List<MapEntry> mapEntries = responseDeclaration.getMapping().getMapEntries();
for (MapEntry mapEntry : mapEntries) {
SingleValue mapKey = mapEntry.getMapKey();
if (mapKey instanceof DirectedPairValue) {
DirectedPairValue pairValue = (DirectedPairValue) mapKey;
String source = pairValue.sourceValue().toString();
String destination = pairValue.destValue().toString();
rightResponses.add("[" + source + " " + destination + "]");
}
}
for (SimpleAssociableChoice choice : fourMatchSet.getSimpleAssociableChoices()) {
String choiceIdentifier = choice.getIdentifier().toString();
String markerCorrect = "[" + choiceIdentifier + " correct]";
String markerWrong = "[" + choiceIdentifier + " wrong]";
boolean isCorrectRight = rightResponses.contains(markerCorrect);
String rightFlag = isCorrectRight ? markerCorrect : markerWrong;
String wrongFlag = isCorrectRight ? markerWrong : markerCorrect;
long numCorrect = 0;
long numIncorrect = 0;
long numUnanswered = 0;
for (RawData rawData : rawDatas) {
String response = rawData.getStringuifiedResponse();
if (response.indexOf(rightFlag) >= 0) {
numCorrect += rawData.getCount();
} else if (response.indexOf(wrongFlag) >= 0) {
numIncorrect += rawData.getCount();
} else {
numUnanswered += rawData.getCount();
}
}
kprimPoints.add(new KPrimStatistics(choice.getIdentifier(), isCorrectRight, numCorrect, numIncorrect, numUnanswered));
}
return kprimPoints;
}
use of org.olat.ims.qti21.model.statistics.KPrimStatistics in project openolat by klemens.
the class QTI21StatisticsManagerImpl method getKPrimStatistics.
// stringuifiedResponse: [a93247453265982 correct][b93247453265983 correct][c93247453265984 correct][d93247453265985 correct]
@Override
public List<KPrimStatistics> getKPrimStatistics(String itemRefIdent, AssessmentItem item, MatchInteraction interaction, QTI21StatisticSearchParams searchParams) {
List<RawData> rawDatas = getRawDatas(itemRefIdent, interaction.getResponseIdentifier().toString(), searchParams);
List<SimpleMatchSet> matchSets = interaction.getSimpleMatchSets();
List<KPrimStatistics> kprimPoints = new ArrayList<>();
SimpleMatchSet fourMatchSet = matchSets.get(0);
ResponseDeclaration responseDeclaration = item.getResponseDeclaration(interaction.getResponseIdentifier());
// readable responses
Set<String> rightResponses = new HashSet<>();
List<MapEntry> mapEntries = responseDeclaration.getMapping().getMapEntries();
for (MapEntry mapEntry : mapEntries) {
SingleValue mapKey = mapEntry.getMapKey();
if (mapKey instanceof DirectedPairValue) {
DirectedPairValue pairValue = (DirectedPairValue) mapKey;
String source = pairValue.sourceValue().toString();
String destination = pairValue.destValue().toString();
rightResponses.add("[" + source + " " + destination + "]");
}
}
for (SimpleAssociableChoice choice : fourMatchSet.getSimpleAssociableChoices()) {
String choiceIdentifier = choice.getIdentifier().toString();
String markerCorrect = "[" + choiceIdentifier + " correct]";
String markerWrong = "[" + choiceIdentifier + " wrong]";
boolean isCorrectRight = rightResponses.contains(markerCorrect);
String rightFlag = isCorrectRight ? markerCorrect : markerWrong;
String wrongFlag = isCorrectRight ? markerWrong : markerCorrect;
long numCorrect = 0;
long numIncorrect = 0;
long numUnanswered = 0;
for (RawData rawData : rawDatas) {
String response = rawData.getStringuifiedResponse();
if (response.indexOf(rightFlag) >= 0) {
numCorrect += rawData.getCount();
} else if (response.indexOf(wrongFlag) >= 0) {
numIncorrect += rawData.getCount();
} else {
numUnanswered += rawData.getCount();
}
}
kprimPoints.add(new KPrimStatistics(choice.getIdentifier(), isCorrectRight, numCorrect, numIncorrect, numUnanswered));
}
return kprimPoints;
}
use of org.olat.ims.qti21.model.statistics.KPrimStatistics 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.ims.qti21.model.statistics.KPrimStatistics in project openolat by klemens.
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;
}
Aggregations