Search in sources :

Example 1 with Statistics

use of org.olat.ims.qti.statistics.manager.Statistics in project OpenOLAT by OpenOLAT.

the class QTI21StatisticsManagerImpl method getAssessmentStatistics.

@Override
public StatisticAssessment getAssessmentStatistics(QTI21StatisticSearchParams searchParams) {
    StringBuilder sb = new StringBuilder();
    sb.append("select asession.score, asession.manualScore, asession.passed, asession.duration from qtiassessmenttestsession asession ");
    decorateRSet(sb, searchParams, true);
    sb.append(" order by asession.key 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[] durationSeconds = new double[rawDatas.size()];
    double minDuration = Double.MAX_VALUE;
    double maxDuration = 0d;
    int dataPos = 0;
    boolean hasScore = false;
    for (Object[] rawData : rawDatas) {
        int pos = 0;
        BigDecimal score = (BigDecimal) rawData[pos++];
        BigDecimal manualScore = (BigDecimal) rawData[pos++];
        if (score == null) {
            score = manualScore;
        } else if (manualScore != null) {
            score = score.add(manualScore);
        }
        if (score != null) {
            double scored = score.doubleValue();
            scores[dataPos] = scored;
            maxScore = Math.max(maxScore, scored);
            minScore = Math.min(minScore, scored);
            hasScore = true;
        }
        Boolean passed = (Boolean) rawData[pos++];
        if (passed != null) {
            if (passed.booleanValue()) {
                numOfPassed++;
            } else {
                numOfFailed++;
            }
        }
        Long duration = (Long) rawData[pos++];
        if (duration != null) {
            double durationd = duration.doubleValue();
            double durationSecond = Math.round(durationd / 1000d);
            durationSeconds[dataPos] = durationSecond;
            totalDuration += durationd;
            minDuration = Math.min(minDuration, durationSecond);
            maxDuration = Math.max(maxDuration, durationSecond);
        }
        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());
    if (hasScore) {
        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.setScores(scores);
    stats.setDurations(durationSeconds);
    return stats;
}
Also used : MatchStatistics(org.olat.ims.qti21.model.statistics.MatchStatistics) ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) NumericalInputInteractionStatistics(org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics) KPrimStatistics(org.olat.ims.qti21.model.statistics.KPrimStatistics) Statistics(org.olat.ims.qti.statistics.manager.Statistics) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics) StatisticAssessment(org.olat.ims.qti.statistics.model.StatisticAssessment) BigDecimal(java.math.BigDecimal)

Example 2 with Statistics

use of org.olat.ims.qti.statistics.manager.Statistics in project openolat by klemens.

the class QTI21StatisticsManagerImpl method getAssessmentStatistics.

@Override
public StatisticAssessment getAssessmentStatistics(QTI21StatisticSearchParams searchParams) {
    StringBuilder sb = new StringBuilder();
    sb.append("select asession.score, asession.manualScore, asession.passed, asession.duration from qtiassessmenttestsession asession ");
    decorateRSet(sb, searchParams, true);
    sb.append(" order by asession.key 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[] durationSeconds = new double[rawDatas.size()];
    double minDuration = Double.MAX_VALUE;
    double maxDuration = 0d;
    int dataPos = 0;
    boolean hasScore = false;
    for (Object[] rawData : rawDatas) {
        int pos = 0;
        BigDecimal score = (BigDecimal) rawData[pos++];
        BigDecimal manualScore = (BigDecimal) rawData[pos++];
        if (score == null) {
            score = manualScore;
        } else if (manualScore != null) {
            score = score.add(manualScore);
        }
        if (score != null) {
            double scored = score.doubleValue();
            scores[dataPos] = scored;
            maxScore = Math.max(maxScore, scored);
            minScore = Math.min(minScore, scored);
            hasScore = true;
        }
        Boolean passed = (Boolean) rawData[pos++];
        if (passed != null) {
            if (passed.booleanValue()) {
                numOfPassed++;
            } else {
                numOfFailed++;
            }
        }
        Long duration = (Long) rawData[pos++];
        if (duration != null) {
            double durationd = duration.doubleValue();
            double durationSecond = Math.round(durationd / 1000d);
            durationSeconds[dataPos] = durationSecond;
            totalDuration += durationd;
            minDuration = Math.min(minDuration, durationSecond);
            maxDuration = Math.max(maxDuration, durationSecond);
        }
        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());
    if (hasScore) {
        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.setScores(scores);
    stats.setDurations(durationSeconds);
    return stats;
}
Also used : MatchStatistics(org.olat.ims.qti21.model.statistics.MatchStatistics) ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) NumericalInputInteractionStatistics(org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics) KPrimStatistics(org.olat.ims.qti21.model.statistics.KPrimStatistics) Statistics(org.olat.ims.qti.statistics.manager.Statistics) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics) StatisticAssessment(org.olat.ims.qti.statistics.model.StatisticAssessment) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)2 Statistics (org.olat.ims.qti.statistics.manager.Statistics)2 StatisticAssessment (org.olat.ims.qti.statistics.model.StatisticAssessment)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