use of org.olat.ims.qti21.model.statistics.MatchStatistics in project OpenOLAT by OpenOLAT.
the class QTI21StatisticsManagerImpl method getMatchStatistics.
@Override
public List<MatchStatistics> getMatchStatistics(String itemRefIdent, AssessmentItem item, MatchInteraction interaction, QTI21StatisticSearchParams searchParams) {
List<RawData> rawDatas = getRawDatas(itemRefIdent, interaction.getResponseIdentifier().toString(), searchParams);
SimpleMatchSet sourceMatchSets = interaction.getSimpleMatchSets().get(0);
SimpleMatchSet targetMatchSets = interaction.getSimpleMatchSets().get(1);
List<MatchStatistics> matchPoints = new ArrayList<>();
ResponseDeclaration responseDeclaration = item.getResponseDeclaration(interaction.getResponseIdentifier());
// readable responses
Map<Identifier, List<Identifier>> associations = new HashMap<>();
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
QtiNodesExtractor.extractIdentifiersFromCorrectResponse(correctResponse, associations);
for (SimpleAssociableChoice sourceChoice : sourceMatchSets.getSimpleAssociableChoices()) {
for (SimpleAssociableChoice targetChoice : targetMatchSets.getSimpleAssociableChoices()) {
DirectedPairValue dKey = new DirectedPairValue(sourceChoice.getIdentifier(), targetChoice.getIdentifier());
String choiceIdentifier = dKey.toQtiString();
String marker = "[" + choiceIdentifier + "]";
boolean correct = associations.containsKey(sourceChoice.getIdentifier()) && associations.get(sourceChoice.getIdentifier()).contains(targetChoice.getIdentifier());
long numCorrect = 0;
long numIncorrect = 0;
for (RawData rawData : rawDatas) {
String response = rawData.getStringuifiedResponse();
if (response.indexOf(marker) >= 0) {
if (correct) {
numCorrect += rawData.getCount();
} else {
numIncorrect += rawData.getCount();
}
}
}
matchPoints.add(new MatchStatistics(sourceChoice.getIdentifier(), targetChoice.getIdentifier(), numCorrect, numIncorrect));
}
}
return matchPoints;
}
use of org.olat.ims.qti21.model.statistics.MatchStatistics in project openolat by klemens.
the class QTI21StatisticsManagerImpl method getMatchStatistics.
@Override
public List<MatchStatistics> getMatchStatistics(String itemRefIdent, AssessmentItem item, MatchInteraction interaction, QTI21StatisticSearchParams searchParams) {
List<RawData> rawDatas = getRawDatas(itemRefIdent, interaction.getResponseIdentifier().toString(), searchParams);
SimpleMatchSet sourceMatchSets = interaction.getSimpleMatchSets().get(0);
SimpleMatchSet targetMatchSets = interaction.getSimpleMatchSets().get(1);
List<MatchStatistics> matchPoints = new ArrayList<>();
ResponseDeclaration responseDeclaration = item.getResponseDeclaration(interaction.getResponseIdentifier());
// readable responses
Map<Identifier, List<Identifier>> associations = new HashMap<>();
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
QtiNodesExtractor.extractIdentifiersFromCorrectResponse(correctResponse, associations);
for (SimpleAssociableChoice sourceChoice : sourceMatchSets.getSimpleAssociableChoices()) {
for (SimpleAssociableChoice targetChoice : targetMatchSets.getSimpleAssociableChoices()) {
DirectedPairValue dKey = new DirectedPairValue(sourceChoice.getIdentifier(), targetChoice.getIdentifier());
String choiceIdentifier = dKey.toQtiString();
String marker = "[" + choiceIdentifier + "]";
boolean correct = associations.containsKey(sourceChoice.getIdentifier()) && associations.get(sourceChoice.getIdentifier()).contains(targetChoice.getIdentifier());
long numCorrect = 0;
long numIncorrect = 0;
for (RawData rawData : rawDatas) {
String response = rawData.getStringuifiedResponse();
if (response.indexOf(marker) >= 0) {
if (correct) {
numCorrect += rawData.getCount();
} else {
numIncorrect += rawData.getCount();
}
}
}
matchPoints.add(new MatchStatistics(sourceChoice.getIdentifier(), targetChoice.getIdentifier(), numCorrect, numIncorrect));
}
}
return matchPoints;
}
use of org.olat.ims.qti21.model.statistics.MatchStatistics in project OpenOLAT by OpenOLAT.
the class MatchStatisticsController method renderMatch.
private void renderMatch() {
List<MatchStatistics> statisticResponses = qtiStatisticsManager.getMatchStatistics(itemRef.getIdentifier().toString(), assessmentItem, interaction, resourceResult.getSearchParams());
long max = 0;
for (MatchStatistics statistics : statisticResponses) {
max = Math.max(max, statistics.getNumOfCorrect() + statistics.getNumOfIncorrect());
}
for (MatchStatistics statistics : statisticResponses) {
Identifier sourceIdentifier = statistics.getSourceIdentifier();
Identifier targetIdentifier = statistics.getDestinationIdentifier();
String key = sourceIdentifier.toString() + "-" + targetIdentifier.toString();
StatisticsWrapper sWrapper = new StatisticsWrapper(sourceIdentifier, targetIdentifier, statistics, max);
mainVC.contextPut(key, sWrapper);
}
// fill the blanks
for (ChoiceWrapper sourceChoice : sourceWrappers) {
for (ChoiceWrapper targetChoice : targetWrappers) {
Identifier sourceIdentifier = sourceChoice.getChoiceIdentifier();
Identifier targetIdentifier = targetChoice.getChoiceIdentifier();
String key = sourceIdentifier.toString() + "-" + targetIdentifier.toString();
if (mainVC.contextGet(key) == null) {
mainVC.contextPut(key, new StatisticsWrapper(sourceIdentifier, targetIdentifier, null, max));
}
}
}
}
use of org.olat.ims.qti21.model.statistics.MatchStatistics in project openolat by klemens.
the class MatchStatisticsController method renderMatch.
private void renderMatch() {
List<MatchStatistics> statisticResponses = qtiStatisticsManager.getMatchStatistics(itemRef.getIdentifier().toString(), assessmentItem, interaction, resourceResult.getSearchParams());
long max = 0;
for (MatchStatistics statistics : statisticResponses) {
max = Math.max(max, statistics.getNumOfCorrect() + statistics.getNumOfIncorrect());
}
for (MatchStatistics statistics : statisticResponses) {
Identifier sourceIdentifier = statistics.getSourceIdentifier();
Identifier targetIdentifier = statistics.getDestinationIdentifier();
String key = sourceIdentifier.toString() + "-" + targetIdentifier.toString();
StatisticsWrapper sWrapper = new StatisticsWrapper(sourceIdentifier, targetIdentifier, statistics, max);
mainVC.contextPut(key, sWrapper);
}
// fill the blanks
for (ChoiceWrapper sourceChoice : sourceWrappers) {
for (ChoiceWrapper targetChoice : targetWrappers) {
Identifier sourceIdentifier = sourceChoice.getChoiceIdentifier();
Identifier targetIdentifier = targetChoice.getChoiceIdentifier();
String key = sourceIdentifier.toString() + "-" + targetIdentifier.toString();
if (mainVC.contextGet(key) == null) {
mainVC.contextPut(key, new StatisticsWrapper(sourceIdentifier, targetIdentifier, null, max));
}
}
}
}
Aggregations