use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.
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 klemens.
the class QTI21StatisticsManagerImpl method getHottextInteractionStatistics.
@Override
public List<ChoiceStatistics> getHottextInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, HottextInteraction hottextInteraction, QTI21StatisticSearchParams searchParams) {
List<RawData> results = getRawDatas(itemRefIdent, hottextInteraction.getResponseIdentifier().toString(), searchParams);
List<Hottext> hottexts = QueryUtils.search(Hottext.class, hottextInteraction);
long[] counts = new long[hottexts.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 = hottexts.size(); i-- > 0; ) {
String identifier = hottexts.get(i).getIdentifier().toString();
if (stringuifiedResponse.contains(identifier)) {
counts[i] += numOfAnswers.longValue();
}
}
}
}
List<ChoiceStatistics> choicesStatistics = new ArrayList<>();
for (int i = 0; i < hottexts.size(); i++) {
choicesStatistics.add(new ChoiceStatistics(hottexts.get(i), counts[i]));
}
return choicesStatistics;
}
use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.
the class QTI21StatisticsManagerImpl method getTextEntryInteractionsStatistic.
@Override
public List<AbstractTextEntryInteractionStatistics> getTextEntryInteractionsStatistic(String itemRefIdent, AssessmentItem item, List<TextEntryInteraction> interactions, QTI21StatisticSearchParams searchParams) {
List<AbstractTextEntryInteractionStatistics> options = new ArrayList<>();
Map<String, AbstractTextEntryInteractionStatistics> optionMap = new HashMap<>();
for (TextEntryInteraction interaction : interactions) {
Identifier responseIdentifier = interaction.getResponseIdentifier();
ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
if (responseDeclaration.hasBaseType(BaseType.STRING)) {
TextEntryInteractionStatistics stats = getTextEntryInteractionSettings(responseIdentifier, responseDeclaration);
optionMap.put(responseIdentifier.toString(), stats);
options.add(stats);
} else if (responseDeclaration.hasBaseType(BaseType.FLOAT)) {
NumericalInputInteractionStatistics stats = getNumericalInputInteractionSettings(responseIdentifier, responseDeclaration, item);
optionMap.put(responseIdentifier.toString(), stats);
options.add(stats);
}
}
for (TextEntryInteraction interaction : interactions) {
String responseIdentifier = interaction.getResponseIdentifier().toString();
List<RawData> datas = getRawDatas(itemRefIdent, responseIdentifier, searchParams);
for (RawData data : datas) {
Long count = data.getCount();
if (count != null && count.longValue() > 0) {
AbstractTextEntryInteractionStatistics stats = optionMap.get(responseIdentifier);
String response = data.getStringuifiedResponse();
if (response != null && response.length() >= 2 && response.startsWith("[") && response.endsWith("]")) {
response = response.substring(1, response.length() - 1);
}
if (stats.matchResponse(response)) {
stats.addCorrect(count.longValue());
} else {
stats.addIncorrect(count.longValue());
stats.addWrongResponses(response);
}
}
}
}
return options;
}
use of org.olat.ims.qti21.model.QTI21StatisticSearchParams 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.QTI21StatisticSearchParams in project openolat by klemens.
the class QTI21StatisticsManagerImpl method getStatisticPerItem.
@Override
public List<AssessmentItemStatistic> getStatisticPerItem(ResolvedAssessmentTest resolvedAssessmentTest, QTI21StatisticSearchParams searchParams, double numOfParticipants) {
StringBuilder sb = new StringBuilder();
sb.append("select isession.assessmentItemIdentifier, isession.score, isession.manualScore, count(*) from qtiassessmentitemsession isession").append(" inner join isession.assessmentTestSession asession");
decorateRSet(sb, searchParams, true);
sb.append(" and isession.duration > 0").append(" group by isession.assessmentItemIdentifier, isession.score, isession.manualScore");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class);
decorateRSetQuery(query, searchParams);
List<Object[]> results = query.getResultList();
if (results.isEmpty()) {
return new ArrayList<>();
}
Map<String, AssessmentItemRef> itemMap = new HashMap<>();
List<AssessmentItemRef> itemRefs = new ArrayList<>(resolvedAssessmentTest.getAssessmentItemRefs());
for (AssessmentItemRef itemRef : itemRefs) {
itemMap.put(itemRef.getIdentifier().toString(), itemRef);
}
Map<String, AssessmentItemHelper> identifierToHelpers = new HashMap<>();
for (Object[] result : results) {
int pos = 0;
String identifier = PersistenceHelper.extractString(result, pos++);
BigDecimal score = (BigDecimal) result[pos++];
BigDecimal manualScore = (BigDecimal) result[pos++];
Long count = PersistenceHelper.extractLong(result, pos++);
if (score == null || identifier == null || count == null) {
continue;
}
AssessmentItemHelper helper = identifierToHelpers.get(identifier);
if (helper == null) {
AssessmentItemRef itemRef = itemMap.get(identifier);
if (itemRef == null) {
continue;
}
ResolvedAssessmentItem item = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
if (item == null) {
continue;
}
helper = new AssessmentItemHelper(item.getRootNodeLookup().extractIfSuccessful());
identifierToHelpers.put(identifier, helper);
}
helper.addCount(count);
if (manualScore != null) {
helper.addTotalScore(count, manualScore);
} else {
helper.addTotalScore(count, score);
}
if (helper.getMaxScore() != null) {
double maxValue = helper.getMaxScore().doubleValue();
if (Math.abs(score.doubleValue() - maxValue) < 0.0001) {
helper.addCorrectAnswers(count);
}
}
}
List<AssessmentItemStatistic> statistics = new ArrayList<>(identifierToHelpers.size());
for (AssessmentItemRef itemRef : itemRefs) {
AssessmentItemHelper helper = identifierToHelpers.get(itemRef.getIdentifier().toString());
if (helper != null) {
long numOfAnswersItem = helper.count;
long numOfCorrectAnswers = helper.countCorrectAnswers;
double average = (helper.totalScore / helper.count);
double averageParticipants = (helper.totalScore / numOfParticipants);
statistics.add(new AssessmentItemStatistic(helper.getAssessmentItem(), average, averageParticipants, numOfAnswersItem, numOfCorrectAnswers));
} else {
ResolvedAssessmentItem item = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
if (item != null) {
statistics.add(new AssessmentItemStatistic(item.getRootNodeLookup().extractIfSuccessful(), 0.0d, 0.0d, 0l, 0l));
}
}
}
return statistics;
}
Aggregations