use of org.olat.ims.qti.statistics.model.StatisticsItem in project OpenOLAT by OpenOLAT.
the class QTIStatisticsManagerImpl method getItemStatistics.
@Override
public StatisticsItem getItemStatistics(String itemIdent, double maxScore, QTIStatisticSearchParams searchParams) {
StringBuilder sb = new StringBuilder();
sb.append("select res.score, count(res.key), avg(res.duration) from qtistatsresult res ").append(" inner join res.resultSet rset");
decorateRSet(sb, searchParams);
sb.append(" and res.itemIdent=:itemIdent and res.duration > 0 group by res.score");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("itemIdent", itemIdent);
decorateRSetQuery(query, searchParams);
List<Object[]> results = query.getResultList();
if (results.isEmpty()) {
return new StatisticsItem();
}
int totalResults = 0;
double totalScore = 0.0;
double totalDuration = 0.0;
long numOfCorrectAnswers = 0;
long numOfIncorrectAnswers = 0;
for (Object[] result : results) {
long numOfResults = ((Long) result[1]).longValue();
// average
double score = ((Float) result[0]).doubleValue();
totalScore += (score * numOfResults);
totalResults += numOfResults;
if ((maxScore - score) < 0.0001) {
numOfCorrectAnswers += numOfResults;
} else {
numOfIncorrectAnswers += numOfResults;
}
double averageDuration = ((Double) result[2]).doubleValue();
totalDuration += (averageDuration * numOfResults);
}
double averageScore = totalScore / totalResults;
// difficulty (p-value)
double difficulty = numOfCorrectAnswers / (double) totalResults;
double averageDuration = totalDuration / totalResults;
StatisticsItem stats = new StatisticsItem();
stats.setAverageDuration(Math.round(averageDuration));
stats.setAverageScore(averageScore);
stats.setNumOfResults(totalResults);
stats.setDifficulty(difficulty);
stats.setNumOfCorrectAnswers(numOfCorrectAnswers);
stats.setNumOfIncorrectAnswers(numOfIncorrectAnswers);
return stats;
}
use of org.olat.ims.qti.statistics.model.StatisticsItem in project OpenOLAT by OpenOLAT.
the class QTI12ItemStatisticsController method initItemStatistics.
protected StatisticsItem initItemStatistics() {
boolean survey = QTIType.survey.equals(resourceResult.getType());
double maxScore;
if (survey) {
maxScore = 1d;
} else if (item.getQuestion().isSingleCorrect()) {
maxScore = item.getQuestion().getSingleCorrectScore();
} else {
maxScore = item.getQuestion().getMaxValue();
}
StatisticsItem itemStats = qtiStatisticsManager.getItemStatistics(item.getIdent(), maxScore, searchParams);
if (survey) {
long notAnswered = numOfParticipants - itemStats.getNumOfResults();
mainVC.contextPut("notAnswered", notAnswered);
} else {
long rightAnswers = itemStats.getNumOfCorrectAnswers();
long wrongAnswers = itemStats.getNumOfIncorrectAnswers();
long notAnswered = numOfParticipants - rightAnswers - wrongAnswers;
mainVC.contextPut("maxScore", maxScore);
mainVC.contextPut("rightAnswers", rightAnswers);
mainVC.contextPut("wrongAnswers", wrongAnswers);
if (item.getQuestion().getType() != Question.TYPE_FIB) {
mainVC.contextPut("notAnswered", notAnswered);
}
mainVC.contextPut("itemDifficulty", formatTwo(itemStats.getDifficulty()));
mainVC.contextPut("averageScore", formatTwo(itemStats.getAverageScore()));
}
mainVC.contextPut("averageDuration", duration(itemStats.getAverageDuration()));
return itemStats;
}
use of org.olat.ims.qti.statistics.model.StatisticsItem in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentItemStatisticsController method initItemStatistics.
protected StatisticsItem initItemStatistics() {
boolean survey = QTIType.survey.equals(resourceResult.getType());
double maxScore = 0.0d;
Double maxScoreSettings = QtiNodesExtractor.extractMaxScore(item);
if (maxScoreSettings != null) {
maxScore = maxScoreSettings.doubleValue();
}
StatisticsItem itemStats = qtiStatisticsManager.getAssessmentItemStatistics(itemRef.getIdentifier().toString(), maxScore, searchParams);
int numOfParticipants = resourceResult.getQTIStatisticAssessment().getNumOfParticipants();
if (survey) {
long notAnswered = numOfParticipants - itemStats.getNumOfResults();
mainVC.contextPut("notAnswered", notAnswered);
} else {
long rightAnswers = itemStats.getNumOfCorrectAnswers();
long wrongAnswers = itemStats.getNumOfIncorrectAnswers();
long notAnswered = numOfParticipants - rightAnswers - wrongAnswers;
mainVC.contextPut("maxScore", maxScore);
mainVC.contextPut("rightAnswers", rightAnswers);
mainVC.contextPut("wrongAnswers", wrongAnswers);
mainVC.contextPut("notAnswered", notAnswered);
mainVC.contextPut("itemDifficulty", formatTwo(itemStats.getDifficulty()));
mainVC.contextPut("averageScore", formatTwo(itemStats.getAverageScore()));
mainVC.contextPut("numOfParticipants", numOfParticipants);
}
mainVC.contextPut("averageDuration", duration(itemStats.getAverageDuration()));
return itemStats;
}
use of org.olat.ims.qti.statistics.model.StatisticsItem in project OpenOLAT by OpenOLAT.
the class QTIStatisticsManagerLargeTest method testItemStatistics_singleChoice_0.
@Test
public void testItemStatistics_singleChoice_0() {
QTIItemObject itemObject = itemObjects.get(0);
double maxValue = Double.parseDouble(itemObject.getItemMaxValue());
QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(olatResource, olatResourceDetail);
StatisticsItem stats = qtim.getItemStatistics(itemObject.getItemIdent(), maxValue, searchParams);
Assert.assertEquals(scoreQ1, stats.getAverageScore(), 0.1);
}
use of org.olat.ims.qti.statistics.model.StatisticsItem in project OpenOLAT by OpenOLAT.
the class QTIStatisticsManagerLargeTest method testItemStatistics_kprim_2.
@Test
public void testItemStatistics_kprim_2() {
QTIItemObject itemObject = itemObjects.get(2);
double maxValue = Double.parseDouble(itemObject.getItemMaxValue());
QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(olatResource, olatResourceDetail);
StatisticsItem stats = qtim.getItemStatistics(itemObject.getItemIdent(), maxValue, searchParams);
float durationQ3InSec = durationQ3;
Assert.assertEquals(durationQ3InSec, stats.getAverageDuration(), 1.0f);
}
Aggregations