Search in sources :

Example 21 with QTI21StatisticSearchParams

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

the class QTI21StatisticsManagerImpl method getTextEntryInteractionsStatistic.

@Override
public List<AbstractTextEntryInteractionStatistics> getTextEntryInteractionsStatistic(String itemRefIdent, AssessmentItem item, List<TextEntryInteraction> interactions, QTI21StatisticSearchParams searchParams) {
    List<AbstractTextEntryInteractionStatistics> options = new ArrayList<>();
    Map<String, AbstractTextEntryInteractionStatistics> optionMap = new HashMap<>();
    for (TextEntryInteraction interaction : interactions) {
        Identifier responseIdentifier = interaction.getResponseIdentifier();
        ResponseDeclaration responseDeclaration = item.getResponseDeclaration(responseIdentifier);
        if (responseDeclaration.hasBaseType(BaseType.STRING)) {
            TextEntryInteractionStatistics stats = getTextEntryInteractionSettings(responseIdentifier, responseDeclaration);
            optionMap.put(responseIdentifier.toString(), stats);
            options.add(stats);
        } else if (responseDeclaration.hasBaseType(BaseType.FLOAT)) {
            NumericalInputInteractionStatistics stats = getNumericalInputInteractionSettings(responseIdentifier, responseDeclaration, item);
            optionMap.put(responseIdentifier.toString(), stats);
            options.add(stats);
        }
    }
    for (TextEntryInteraction interaction : interactions) {
        String responseIdentifier = interaction.getResponseIdentifier().toString();
        List<RawData> datas = getRawDatas(itemRefIdent, responseIdentifier, searchParams);
        for (RawData data : datas) {
            Long count = data.getCount();
            if (count != null && count.longValue() > 0) {
                AbstractTextEntryInteractionStatistics stats = optionMap.get(responseIdentifier);
                String response = data.getStringuifiedResponse();
                if (response != null && response.length() >= 2 && response.startsWith("[") && response.endsWith("]")) {
                    response = response.substring(1, response.length() - 1);
                }
                if (stats.matchResponse(response)) {
                    stats.addCorrect(count.longValue());
                } else {
                    stats.addIncorrect(count.longValue());
                    stats.addWrongResponses(response);
                }
            }
        }
    }
    return options;
}
Also used : TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) TextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.TextEntryInteractionStatistics) AbstractTextEntryInteractionStatistics(org.olat.ims.qti21.model.statistics.AbstractTextEntryInteractionStatistics) NumericalInputInteractionStatistics(org.olat.ims.qti21.model.statistics.NumericalInputInteractionStatistics) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 22 with QTI21StatisticSearchParams

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

the class QTI21ResultsExportMediaResource method exportExcelResults.

private void exportExcelResults(RepositoryEntry testEntry, ZipOutputStream zout) {
    ArchiveOptions options = new ArchiveOptions();
    options.setIdentities(identities);
    QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, testEntry, entry, courseNode.getIdent());
    searchParams.setLimitToIdentities(identities);
    QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(translator.getLocale(), searchParams);
    String label = StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName() + "_" + testEntry.getDisplayname()) + "_" + Formatter.formatDatetimeWithMinutes(new Date()) + ".xlsx";
    qaf.exportCourseElement(exportFolderName + "/" + label, zout);
}
Also used : QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) ArchiveOptions(org.olat.course.nodes.ArchiveOptions) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat) Date(java.util.Date)

Example 23 with QTI21StatisticSearchParams

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

the class QTI21ResetDataController method archiveData.

private void archiveData(RepositoryEntry testEntry) {
    // backup
    String archiveName = "qti21test_" + StringHelper.transformDisplayNameToFileSystemName(testEntry.getDisplayname()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".zip";
    Path exportPath = Paths.get(FolderConfig.getCanonicalRoot(), FolderConfig.getUserHomes(), getIdentity().getName(), "private", "archive", StringHelper.transformDisplayNameToFileSystemName(testEntry.getDisplayname()), archiveName);
    File exportFile = exportPath.toFile();
    exportFile.getParentFile().mkdirs();
    try (FileOutputStream fileStream = new FileOutputStream(exportFile);
        ZipOutputStream exportStream = new ZipOutputStream(fileStream)) {
        // author can do this, also they can archive all users and anonyme users
        QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testEntry, null, null, true, true);
        new QTI21ArchiveFormat(getLocale(), searchParams).exportResource(exportStream);
    } catch (IOException e) {
        logError("", e);
    }
}
Also used : Path(java.nio.file.Path) QTI21StatisticSearchParams(org.olat.ims.qti21.model.QTI21StatisticSearchParams) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) QTI21ArchiveFormat(org.olat.ims.qti21.manager.archive.QTI21ArchiveFormat) Date(java.util.Date)

Example 24 with QTI21StatisticSearchParams

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

the class IQSURVCourseNode 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 qtiSurveyEntry = getReferencedRepositoryEntry();
    if (ImsQTI21Resource.TYPE_NAME.equals(qtiSurveyEntry.getOlatResource().getResourceableTypeName())) {
        RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
        QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(qtiSurveyEntry, courseEntry, getIdent());
        searchParams.setLimitToGroups(options.getParticipantsGroups());
        QTI21DeliveryOptions deliveryOptions = CoreSpringFactory.getImpl(QTI21Service.class).getDeliveryOptions(qtiSurveyEntry);
        boolean admin = userCourseEnv.isAdmin();
        QTI21StatisticsSecurityCallback secCallback = new QTI21StatisticsSecurityCallback(admin, admin && deliveryOptions.isAllowAnonym());
        return new QTI21StatisticResourceResult(qtiSurveyEntry, courseEntry, this, searchParams, secCallback);
    }
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(courseOres.getResourceableId(), getIdent());
    searchParams.setLimitToGroups(options.getParticipantsGroups());
    return new QTIStatisticResourceResult(courseOres, this, qtiSurveyEntry, searchParams);
}
Also used : QTI21DeliveryOptions(org.olat.ims.qti21.QTI21DeliveryOptions) QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) QTI21Service(org.olat.ims.qti21.QTI21Service) 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 25 with QTI21StatisticSearchParams

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

the class IQSURVCourseNode 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 qtiSurveyEntry = getReferencedRepositoryEntry();
    if (ImsQTI21Resource.TYPE_NAME.equals(qtiSurveyEntry.getOlatResource().getResourceableTypeName())) {
        RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
        QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(qtiSurveyEntry, courseEntry, getIdent());
        searchParams.setLimitToGroups(options.getParticipantsGroups());
        QTI21DeliveryOptions deliveryOptions = CoreSpringFactory.getImpl(QTI21Service.class).getDeliveryOptions(qtiSurveyEntry);
        boolean admin = userCourseEnv.isAdmin();
        QTI21StatisticsSecurityCallback secCallback = new QTI21StatisticsSecurityCallback(admin, admin && deliveryOptions.isAllowAnonym());
        return new QTI21StatisticResourceResult(qtiSurveyEntry, courseEntry, this, searchParams, secCallback);
    }
    QTIStatisticSearchParams searchParams = new QTIStatisticSearchParams(courseOres.getResourceableId(), getIdent());
    searchParams.setLimitToGroups(options.getParticipantsGroups());
    return new QTIStatisticResourceResult(courseOres, this, qtiSurveyEntry, searchParams);
}
Also used : QTI21DeliveryOptions(org.olat.ims.qti21.QTI21DeliveryOptions) QTIStatisticSearchParams(org.olat.ims.qti.statistics.QTIStatisticSearchParams) QTI21Service(org.olat.ims.qti21.QTI21Service) 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)

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