Search in sources :

Example 31 with QTI21StatisticSearchParams

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

the class QTI21StatisticsManagerImpl method getChoiceInteractionStatistics.

@Override
public List<ChoiceStatistics> getChoiceInteractionStatistics(String itemRefIdent, AssessmentItem assessmentItem, ChoiceInteraction choiceInteraction, QTI21StatisticSearchParams searchParams) {
    List<RawData> results = getRawDatas(itemRefIdent, choiceInteraction.getResponseIdentifier().toString(), searchParams);
    List<SimpleChoice> simpleChoices = choiceInteraction.getSimpleChoices();
    long[] counts = new long[simpleChoices.size()];
    for (int i = counts.length; i-- > 0; ) {
        counts[i] = 0l;
    }
    for (RawData result : results) {
        Long numOfAnswers = result.getCount();
        ;
        if (numOfAnswers != null && numOfAnswers.longValue() > 0) {
            String stringuifiedResponse = result.getStringuifiedResponse();
            for (int i = simpleChoices.size(); i-- > 0; ) {
                String identifier = simpleChoices.get(i).getIdentifier().toString();
                if (stringuifiedResponse.contains(identifier)) {
                    counts[i] += numOfAnswers.longValue();
                }
            }
        }
    }
    List<ChoiceStatistics> choicesStatistics = new ArrayList<>();
    for (int i = 0; i < simpleChoices.size(); i++) {
        choicesStatistics.add(new ChoiceStatistics(simpleChoices.get(i), counts[i]));
    }
    return choicesStatistics;
}
Also used : ChoiceStatistics(org.olat.ims.qti21.model.statistics.ChoiceStatistics) HotspotChoiceStatistics(org.olat.ims.qti21.model.statistics.HotspotChoiceStatistics) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) ArrayList(java.util.ArrayList)

Example 32 with QTI21StatisticSearchParams

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

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)

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