Search in sources :

Example 11 with StatisticsItem

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

the class QTI21StatisticsManagerImpl method getAssessmentItemStatistics.

@Override
public StatisticsItem getAssessmentItemStatistics(String itemIdent, double maxScore, QTI21StatisticSearchParams searchParams) {
    StringBuilder sb = new StringBuilder();
    sb.append("select isession.score, isession.manualScore, count(isession.key), avg(isession.duration) from qtiassessmentitemsession isession ").append(" inner join isession.assessmentTestSession asession");
    decorateRSet(sb, searchParams, true);
    sb.append(" and isession.assessmentItemIdentifier=:itemIdent and isession.duration > 0").append(" group by isession.score, isession.manualScore");
    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) {
        BigDecimal score = (BigDecimal) result[0];
        BigDecimal manualScore = (BigDecimal) result[1];
        if (score == null) {
            score = manualScore;
        } else if (manualScore != null) {
            score = score.add(manualScore);
        }
        long numOfResults = ((Number) result[2]).longValue();
        double averageDuration = ((Number) result[3]).doubleValue();
        // average
        double dScore = score == null ? 0.0d : score.doubleValue();
        totalScore += (dScore * numOfResults);
        totalResults += numOfResults;
        if ((maxScore - dScore) < 0.0001) {
            numOfCorrectAnswers += numOfResults;
        } else {
            numOfIncorrectAnswers += numOfResults;
        }
        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;
}
Also used : StatisticsItem(org.olat.ims.qti.statistics.model.StatisticsItem) BigDecimal(java.math.BigDecimal)

Example 12 with StatisticsItem

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

the class QTI12ItemStatisticsController method initEssay.

protected void initEssay() {
    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);
    mainVC.contextPut("solution", item.getQuestion().getSolutionText());
    int numOfResults = itemStats.getNumOfResults();
    if (!survey) {
        mainVC.contextPut("maxScore", maxScore);
    }
    mainVC.contextPut("averageDuration", duration(itemStats.getAverageDuration()));
    List<String> answers = qtiStatisticsManager.getAnswers(item.getIdent(), searchParams);
    List<String> cleanedAnswers = new ArrayList<>();
    for (String string : answers) {
        String strippedAnswer = stripAnswerText(string);
        if (strippedAnswer == null || strippedAnswer.length() == 0) {
            numOfResults--;
        } else {
            cleanedAnswers.add(strippedAnswer);
        }
    }
    mainVC.contextPut("numOfResults", Math.max(0, numOfResults));
    mainVC.contextPut("studentAnswers", cleanedAnswers);
}
Also used : StatisticsItem(org.olat.ims.qti.statistics.model.StatisticsItem) ArrayList(java.util.ArrayList)

Example 13 with StatisticsItem

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

the class QTI21AssessmentItemStatisticsController method updateData.

private void updateData(UserRequest ureq) {
    StatisticsItem itemStats = initItemStatistics();
    List<String> interactionIds = initInteractionControllers(ureq, itemStats);
    mainVC.contextPut("interactionIds", interactionIds);
}
Also used : StatisticsItem(org.olat.ims.qti.statistics.model.StatisticsItem)

Example 14 with StatisticsItem

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

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);
}
Also used : QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) StatisticsItem(org.olat.ims.qti.statistics.model.StatisticsItem) Test(org.junit.Test)

Example 15 with StatisticsItem

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

the class QTIStatisticsManagerLargeTest method testItemStatistics_multipleChoice_1.

@Test
public void testItemStatistics_multipleChoice_1() {
    QTIItemObject itemObject = itemObjects.get(1);
    double maxValue = Double.parseDouble(itemObject.getItemMaxValue());
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(olatResource, olatResourceDetail);
    StatisticsItem stats = qtim.getItemStatistics(itemObject.getItemIdent(), maxValue, searchParams);
    double difficulty = rightAnswersQ2 / (double) numberOfParticipants;
    Assert.assertEquals(difficulty, stats.getDifficulty(), 0.1);
    Assert.assertEquals(scoreQ2, stats.getAverageScore(), 0.1);
    Assert.assertEquals(wrongAnswersQ2, stats.getNumOfIncorrectAnswers());
    Assert.assertEquals(numberOfParticipants - wrongAnswersQ2, stats.getNumOfCorrectAnswers());
}
Also used : QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) QTIItemObject(org.olat.ims.qti.export.helper.QTIItemObject) StatisticsItem(org.olat.ims.qti.statistics.model.StatisticsItem) Test(org.junit.Test)

Aggregations

StatisticsItem (org.olat.ims.qti.statistics.model.StatisticsItem)18 Test (org.junit.Test)6 QTIItemObject (org.olat.ims.qti.export.helper.QTIItemObject)6 QTIStatisticSearchParams (org.olat.ims.qti.statistics.QTIStatisticSearchParams)6 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2