Search in sources :

Example 1 with StatisticAssessment

use of org.olat.ims.qti.statistics.model.StatisticAssessment in project openolat by klemens.

the class QTIStatisticsManagerImpl method getAssessmentStatistics.

@Override
public StatisticAssessment getAssessmentStatistics(QTIStatisticSearchParams searchParams) {
    StringBuilder sb = new StringBuilder();
    sb.append("select rset.score, rset.duration, rset.isPassed from ").append(QTIStatisticResultSet.class.getName()).append(" rset ");
    decorateRSet(sb, searchParams);
    sb.append(" order by rset.duration asc");
    TypedQuery<Object[]> rawDataQuery = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class);
    decorateRSetQuery(rawDataQuery, searchParams);
    List<Object[]> rawDatas = rawDataQuery.getResultList();
    int numOfPassed = 0;
    int numOfFailed = 0;
    double totalDuration = 0.0;
    double maxScore = 0.0;
    double minScore = Double.MAX_VALUE;
    double[] scores = new double[rawDatas.size()];
    double[] durationSecondes = new double[rawDatas.size()];
    double minDuration = Double.MAX_VALUE;
    double maxDuration = 0d;
    int dataPos = 0;
    for (Object[] rawData : rawDatas) {
        Boolean passed = (Boolean) rawData[2];
        if (passed != null) {
            if (passed.booleanValue()) {
                numOfPassed++;
            } else {
                numOfFailed++;
            }
        }
        Float score = (Float) rawData[0];
        if (score != null) {
            double scored = score.doubleValue();
            scores[dataPos] = scored;
            maxScore = Math.max(maxScore, scored);
            minScore = Math.min(minScore, scored);
        }
        Long duration = (Long) rawData[1];
        if (duration != null) {
            double durationd = duration.doubleValue();
            double durationSeconde = Math.round(durationd / 1000d);
            durationSecondes[dataPos] = durationSeconde;
            totalDuration += durationd;
            minDuration = Math.min(minDuration, durationSeconde);
            maxDuration = Math.max(maxDuration, durationSeconde);
        }
        dataPos++;
    }
    if (rawDatas.size() == 0) {
        minScore = 0;
    }
    Statistics statisticsHelper = new Statistics(scores);
    int numOfParticipants = rawDatas.size();
    StatisticAssessment stats = new StatisticAssessment();
    stats.setNumOfParticipants(numOfParticipants);
    stats.setNumOfPassed(numOfPassed);
    stats.setNumOfFailed(numOfFailed);
    long averageDuration = Math.round(totalDuration / numOfParticipants);
    stats.setAverageDuration(averageDuration);
    stats.setAverage(statisticsHelper.getMean());
    double range = maxScore - minScore;
    stats.setRange(range);
    stats.setMaxScore(maxScore);
    stats.setMinScore(minScore);
    stats.setStandardDeviation(statisticsHelper.getStdDev());
    stats.setMedian(statisticsHelper.median());
    stats.setMode(statisticsHelper.mode());
    stats.setDurations(durationSecondes);
    stats.setScores(scores);
    return stats;
}
Also used : StatisticAssessment(org.olat.ims.qti.statistics.model.StatisticAssessment)

Example 2 with StatisticAssessment

use of org.olat.ims.qti.statistics.model.StatisticAssessment in project openolat by klemens.

the class QTIStatisticsManagerLargeTest method testStatistics.

@Test
public void testStatistics() {
    long start = System.currentTimeMillis();
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(olatResource, olatResourceDetail);
    StatisticAssessment stats = qtim.getAssessmentStatistics(searchParams);
    log.info("Statistics of resource takes (ms): " + (System.currentTimeMillis() - start));
    Assert.assertNotNull(stats);
    Assert.assertEquals(averageScore, stats.getAverage(), 0.01);
    Assert.assertEquals(numberOfParticipants, stats.getNumOfParticipants());
    Assert.assertEquals(numberOfTestFailed, stats.getNumOfFailed());
    Assert.assertEquals(numberOfTestPassed, stats.getNumOfPassed());
    double maxScore = scorePerParticipant.get(scorePerParticipant.size() - 1).doubleValue();
    double minScore = scorePerParticipant.get(0).doubleValue();
    double range = maxScore - minScore;
    Assert.assertEquals(maxScore, stats.getMaxScore(), 0.1);
    Assert.assertEquals(minScore, stats.getMinScore(), 0.1);
    Assert.assertEquals(range, stats.getRange(), 0.1);
    Assert.assertEquals(averageDuration, stats.getAverageDuration(), 2);
    Assert.assertTrue(stats.getStandardDeviation() > 0);
    Assert.assertTrue(stats.getMedian() > 0);
    Assert.assertNotNull(stats.getDurations());
    Assert.assertNotNull(stats.getScores());
    Assert.assertNotNull(stats.getMode());
    Assert.assertFalse(stats.getMode().isEmpty());
}
Also used : QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) StatisticAssessment(org.olat.ims.qti.statistics.model.StatisticAssessment) Test(org.junit.Test)

Example 3 with StatisticAssessment

use of org.olat.ims.qti.statistics.model.StatisticAssessment in project openolat by klemens.

the class QTIStatisticsManagerTest method testResultSetStatistics.

@Test
public void testResultSetStatistics() {
    RepositoryEntry re = createRepository();
    long assessmentId = 837l;
    String resSubPath = "1237";
    for (int i = 0; i < 10; i++) {
        Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-stats-1" + i);
        float score = Math.round((Math.random() * 10) + 1l);
        createSet(score, assessmentId, id, re, resSubPath, modDate(3, 8, 8), modDate(3, 8, 12));
    }
    dbInstance.commit();
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(re.getOlatResource().getResourceableId(), resSubPath);
    StatisticAssessment stats = qtiStatisticsManager.getAssessmentStatistics(searchParams);
    Assert.assertNotNull(stats);
}
Also used : QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) StatisticAssessment(org.olat.ims.qti.statistics.model.StatisticAssessment) Test(org.junit.Test)

Example 4 with StatisticAssessment

use of org.olat.ims.qti.statistics.model.StatisticAssessment in project OpenOLAT by OpenOLAT.

the class QTIStatisticsManagerTest method testResultSetStatistics.

@Test
public void testResultSetStatistics() {
    RepositoryEntry re = createRepository();
    long assessmentId = 837l;
    String resSubPath = "1237";
    for (int i = 0; i < 10; i++) {
        Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("qti-stats-1" + i);
        float score = Math.round((Math.random() * 10) + 1l);
        createSet(score, assessmentId, id, re, resSubPath, modDate(3, 8, 8), modDate(3, 8, 12));
    }
    dbInstance.commit();
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(re.getOlatResource().getResourceableId(), resSubPath);
    StatisticAssessment stats = qtiStatisticsManager.getAssessmentStatistics(searchParams);
    Assert.assertNotNull(stats);
}
Also used : QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) StatisticAssessment(org.olat.ims.qti.statistics.model.StatisticAssessment) Test(org.junit.Test)

Example 5 with StatisticAssessment

use of org.olat.ims.qti.statistics.model.StatisticAssessment in project OpenOLAT by OpenOLAT.

the class QTIStatisticsManagerLargeTest method testStatistics.

@Test
public void testStatistics() {
    long start = System.currentTimeMillis();
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(olatResource, olatResourceDetail);
    StatisticAssessment stats = qtim.getAssessmentStatistics(searchParams);
    log.info("Statistics of resource takes (ms): " + (System.currentTimeMillis() - start));
    Assert.assertNotNull(stats);
    Assert.assertEquals(averageScore, stats.getAverage(), 0.01);
    Assert.assertEquals(numberOfParticipants, stats.getNumOfParticipants());
    Assert.assertEquals(numberOfTestFailed, stats.getNumOfFailed());
    Assert.assertEquals(numberOfTestPassed, stats.getNumOfPassed());
    double maxScore = scorePerParticipant.get(scorePerParticipant.size() - 1).doubleValue();
    double minScore = scorePerParticipant.get(0).doubleValue();
    double range = maxScore - minScore;
    Assert.assertEquals(maxScore, stats.getMaxScore(), 0.1);
    Assert.assertEquals(minScore, stats.getMinScore(), 0.1);
    Assert.assertEquals(range, stats.getRange(), 0.1);
    Assert.assertEquals(averageDuration, stats.getAverageDuration(), 2);
    Assert.assertTrue(stats.getStandardDeviation() > 0);
    Assert.assertTrue(stats.getMedian() > 0);
    Assert.assertNotNull(stats.getDurations());
    Assert.assertNotNull(stats.getScores());
    Assert.assertNotNull(stats.getMode());
    Assert.assertFalse(stats.getMode().isEmpty());
}
Also used : QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) StatisticAssessment(org.olat.ims.qti.statistics.model.StatisticAssessment) Test(org.junit.Test)

Aggregations

StatisticAssessment (org.olat.ims.qti.statistics.model.StatisticAssessment)10 Test (org.junit.Test)4 QTIStatisticSearchParams (org.olat.ims.qti.statistics.QTIStatisticSearchParams)4 BigDecimal (java.math.BigDecimal)2 Identity (org.olat.core.id.Identity)2 Statistics (org.olat.ims.qti.statistics.manager.Statistics)2 AbstractTextEntryInteractionStatistics (org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics)2 ChoiceStatistics (org.olat.ims.qti21.model.statistics.ChoiceStatistics)2 HotspotChoiceStatistics (org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)2 KPrimStatistics (org.olat.ims.qti21.model.statistics.KPrimStatistics)2 MatchStatistics (org.olat.ims.qti21.model.statistics.MatchStatistics)2 NumericalInputInteractionStatistics (org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics)2 TextEntryInteractionStatistics (org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2