use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project OpenOLAT by OpenOLAT.
the class QTI21StatisticsManagerImpl method getHotspotInteractionStatistics.
@Override
public List<HotspotChoiceStatistics> getHotspotInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, HotspotInteraction hotspotInteraction, QTI21StatisticSearchParams searchParams) {
List<RawData> results = getRawDatas(itemRefIdent, hotspotInteraction.getResponseIdentifier().toString(), searchParams);
List<HotspotChoice> hotspotChoices = hotspotInteraction.getHotspotChoices();
long[] counts = new long[hotspotChoices.size()];
for (int i = counts.length; i-- > 0; ) {
counts[i] = 0l;
}
for (RawData result : results) {
Long numOfAnswers = result.getCount();
;
if (numOfAnswers != null && numOfAnswers.longValue() > 0) {
String stringuifiedResponse = result.getStringuifiedResponse();
for (int i = hotspotChoices.size(); i-- > 0; ) {
String identifier = hotspotChoices.get(i).getIdentifier().toString();
if (stringuifiedResponse.contains(identifier)) {
counts[i] += numOfAnswers.longValue();
}
}
}
}
List<HotspotChoiceStatistics> choicesStatistics = new ArrayList<>();
for (int i = 0; i < hotspotChoices.size(); i++) {
choicesStatistics.add(new HotspotChoiceStatistics(hotspotChoices.get(i), counts[i]));
}
return choicesStatistics;
}
use of org.olat.ims.qti21.model.QTI21StatisticSearchParams 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.QTI21StatisticSearchParams in project OpenOLAT by OpenOLAT.
the class QTI21StatisticsManagerImpl method getChoiceInteractionStatistics.
@Override
public List<ChoiceStatistics> getChoiceInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, ChoiceInteraction choiceInteraction, QTI21StatisticSearchParams searchParams) {
List<RawData> results = getRawDatas(itemRefIdent, choiceInteraction.getResponseIdentifier().toString(), searchParams);
List<SimpleChoice> simpleChoices = choiceInteraction.getSimpleChoices();
long[] counts = new long[simpleChoices.size()];
for (int i = counts.length; i-- > 0; ) {
counts[i] = 0l;
}
for (RawData result : results) {
Long numOfAnswers = result.getCount();
;
if (numOfAnswers != null && numOfAnswers.longValue() > 0) {
String stringuifiedResponse = result.getStringuifiedResponse();
for (int i = simpleChoices.size(); i-- > 0; ) {
String identifier = simpleChoices.get(i).getIdentifier().toString();
if (stringuifiedResponse.contains(identifier)) {
counts[i] += numOfAnswers.longValue();
}
}
}
}
List<ChoiceStatistics> choicesStatistics = new ArrayList<>();
for (int i = 0; i < simpleChoices.size(); i++) {
choicesStatistics.add(new ChoiceStatistics(simpleChoices.get(i), counts[i]));
}
return choicesStatistics;
}
use of org.olat.ims.qti21.model.QTI21StatisticSearchParams 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.QTI21StatisticSearchParams in project OpenOLAT by OpenOLAT.
the class QTIArchiver method exportQTI21.
public MediaResource exportQTI21() {
ICourse course = CourseFactory.loadCourse(courseOres);
RepositoryEntry testRe = courseNode.getReferencedRepositoryEntry();
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testRe, courseEntry, courseNode.getIdent(), allUsers, anonymUsers);
return new QTI21ArchiveFormat(locale, searchParams).exportCourseElement();
}
Aggregations