Search in sources :

Example 26 with QTI21StatisticSearchParams

use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.

the class IQTESTCourseNode method createStatisticNodeResult.

@Override
public StatisticResourceResult createStatisticNodeResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, StatisticResourceOption options, QTIType... types) {
    if (!isQTITypeAllowed(types))
        return null;
    Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
    OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", courseId);
    RepositoryEntry qtiTestEntry = getReferencedRepositoryEntry();
    if (ImsQTI21Resource.TYPE_NAME.equals(qtiTestEntry.getOlatResource().getResourceableTypeName())) {
        RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
        QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(qtiTestEntry, courseEntry, getIdent());
        boolean admin = userCourseEnv.isAdmin();
        if (options.getParticipantsGroups() != null) {
            searchParams.setLimitToGroups(options.getParticipantsGroups());
        }
        QTI21StatisticsSecurityCallback secCallback = new QTI21StatisticsSecurityCallback(admin, admin && isGuestAllowedForQTI21(qtiTestEntry));
        return new QTI21StatisticResourceResult(qtiTestEntry, courseEntry, this, searchParams, secCallback);
    }
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(courseOres.getResourceableId(), getIdent());
    searchParams.setLimitToGroups(options.getParticipantsGroups());
    return new QTIStatisticResourceResult(courseOres, this, qtiTestEntry, searchParams);
}
Also used : QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) OLATResourceable(org.olat.core.id.OLATResourceable) QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) QTI21StatisticResourceResult(org.olat.ims.qti21.ui.statistics.QTI21StatisticResourceResult) QTIStatisticResourceResult(org.olat.ims.qti.statistics.QTIStatisticResourceResult) QTI21StatisticsSecurityCallback(org.olat.ims.qti21.ui.statistics.QTI21StatisticsSecurityCallback) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 27 with QTI21StatisticSearchParams

use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.

the class IQTESTCourseNode method archiveNodeData.

@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
    String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
    Long courseResourceableId = course.getResourceableId();
    // 1) prepare result export
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    try {
        RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
        boolean onyx = OnyxModule.isOnyxTest(re.getOlatResource());
        if (onyx) {
            return true;
        } else if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
            // 2a) create export resource
            List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
            new QTI21ResultsExportMediaResource(courseEnv, identities, this, locale).exportTestResults(exportStream);
            // excel results
            RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, re, courseEntry, getIdent());
            QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(locale, searchParams);
            qaf.exportCourseElement(exportStream);
            return true;
        } else {
            // 2b) create export resource
            List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
            new QTI12ResultsExportMediaResource(courseEnv, locale, identities, this).exportTestResults(exportStream);
            // excel results
            String shortTitle = getShortTitle();
            QTIExportManager qem = QTIExportManager.getInstance();
            QTIExportFormatter qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
            if (options != null && options.getExportFormat() != null) {
                Map<Class<?>, QTIExportItemFormatConfig> itemConfigs = new HashMap<>();
                Class<?>[] itemTypes = new Class<?>[] { QTIExportSCQItemFormatConfig.class, QTIExportMCQItemFormatConfig.class, QTIExportKPRIMItemFormatConfig.class, QTIExportFIBItemFormatConfig.class, QTIExportEssayItemFormatConfig.class };
                for (Class<?> itemClass : itemTypes) {
                    itemConfigs.put(itemClass, new QTIExportItemFormatDelegate(options.getExportFormat()));
                }
                qef.setMapWithExportItemConfigs(itemConfigs);
            }
            return qem.selectAndExportResults(qef, courseResourceableId, shortTitle, getIdent(), re, exportStream, locale, ".xls");
        }
    } catch (IOException e) {
        log.error("", e);
        return false;
    }
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) QTIExportFormatterCSVType1(org.olat.ims.qti.export.QTIExportFormatterCSVType1) RepositoryEntry(org.olat.repository.RepositoryEntry) QTIExportItemFormatDelegate(org.olat.ims.qti.export.QTIExportItemFormatDelegate) IOException(java.io.IOException) QTI21ResultsExportMediaResource(org.olat.ims.qti21.resultexport.QTI21ResultsExportMediaResource) QTI12ResultsExportMediaResource(org.olat.ims.qti.resultexport.QTI12ResultsExportMediaResource) QTIExportFormatter(org.olat.ims.qti.export.QTIExportFormatter) QTIExportManager(org.olat.ims.qti.export.QTIExportManager) List(java.util.List) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat) Map(java.util.Map) HashMap(java.util.HashMap)

Example 28 with QTI21StatisticSearchParams

use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.

the class IQSELFCourseNode method archiveNodeData.

@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
    String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
    try {
        if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
            RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, re, courseEntry, getIdent());
            QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(locale, searchParams);
            qaf.exportCourseElement(exportStream);
            return true;
        } else {
            QTIExportManager qem = QTIExportManager.getInstance();
            QTIExportFormatterCSVType1 qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
            qef.setAnonymous(true);
            if (options != null && options.getExportFormat() != null) {
                Map<Class<?>, QTIExportItemFormatConfig> itemConfigs = new HashMap<>();
                Class<?>[] itemTypes = new Class<?>[] { QTIExportSCQItemFormatConfig.class, QTIExportMCQItemFormatConfig.class, QTIExportKPRIMItemFormatConfig.class, QTIExportFIBItemFormatConfig.class, QTIExportEssayItemFormatConfig.class };
                for (Class<?> itemClass : itemTypes) {
                    itemConfigs.put(itemClass, new QTIExportItemFormatDelegate(options.getExportFormat()));
                }
                qef.setMapWithExportItemConfigs(itemConfigs);
            }
            return qem.selectAndExportResults(qef, course.getResourceableId(), getShortTitle(), getIdent(), re, exportStream, locale, ".xls");
        }
    } catch (IOException e) {
        log.error("", e);
        return false;
    }
}
Also used : QTIExportMCQItemFormatConfig(org.olat.ims.qti.export.QTIExportMCQItemFormatConfig) QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) HashMap(java.util.HashMap) QTIExportFormatterCSVType1(org.olat.ims.qti.export.QTIExportFormatterCSVType1) RepositoryEntry(org.olat.repository.RepositoryEntry) QTIExportItemFormatDelegate(org.olat.ims.qti.export.QTIExportItemFormatDelegate) IOException(java.io.IOException) QTIExportFIBItemFormatConfig(org.olat.ims.qti.export.QTIExportFIBItemFormatConfig) QTIExportEssayItemFormatConfig(org.olat.ims.qti.export.QTIExportEssayItemFormatConfig) QTIExportManager(org.olat.ims.qti.export.QTIExportManager) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat) QTIExportSCQItemFormatConfig(org.olat.ims.qti.export.QTIExportSCQItemFormatConfig) QTIExportKPRIMItemFormatConfig(org.olat.ims.qti.export.QTIExportKPRIMItemFormatConfig) QTIExportItemFormatConfig(org.olat.ims.qti.export.QTIExportItemFormatConfig)

Example 29 with QTI21StatisticSearchParams

use of org.olat.ims.qti21.model.QTI21StatisticSearchParams in project openolat by klemens.

the class QTIArchiver method hasResults.

public boolean hasResults() {
    if (results != null)
        return results.booleanValue();
    ICourse course = CourseFactory.loadCourse(courseOres);
    RepositoryEntry testRe = courseNode.getReferencedRepositoryEntry();
    boolean success = false;
    if (ImsQTI21Resource.TYPE_NAME.equals(testRe.getOlatResource().getResourceableTypeName())) {
        type = Type.qti21;
        RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
        QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testRe, courseEntry, courseNode.getIdent(), allUsers, anonymUsers);
        success = new QTI21ArchiveFormat(locale, searchParams).hasResults();
    } else {
        type = Type.qti12;
        success = qrm.hasResultSets(courseOres.getResourceableId(), courseNode.getIdent(), testRe.getKey());
    }
    results = Boolean.valueOf(success);
    return success;
}
Also used : QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat)

Example 30 with QTI21StatisticSearchParams

use of org.olat.ims.qti21.model.QTI21StatisticSearchParams 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

QTI21StatisticSearchParams (org.olat.ims.qti21.model.QTI21StatisticSearchParams)16 ArrayList (java.util.ArrayList)14 QTI21ArchiveFormat (org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 HashMap (java.util.HashMap)10 HotspotChoiceStatistics (org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics)8 IOException (java.io.IOException)6 ChoiceStatistics (org.olat.ims.qti21.model.statistics.ChoiceStatistics)6 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)5 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 List (java.util.List)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 ICourse (org.olat.course.ICourse)4 QTIExportFormatterCSVType1 (org.olat.ims.qti.export.QTIExportFormatterCSVType1)4 QTIExportItemFormatDelegate (org.olat.ims.qti.export.QTIExportItemFormatDelegate)4 QTIExportManager (org.olat.ims.qti.export.QTIExportManager)4 KPrimStatistics (org.olat.ims.qti21.model.statistics.KPrimStatistics)4 MatchStatistics (org.olat.ims.qti21.model.statistics.MatchStatistics)4 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)4