Search in sources :

Example 36 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.

the class QTI21EditLayoutForm method getMaxTimeLimit.

/**
 * @return The time limit of the assessment test in seconds or -1 if not configured
 */
private long getMaxTimeLimit() {
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
    long timeLimit = -1;
    if (assessmentTest != null && assessmentTest.getTimeLimits() != null && assessmentTest.getTimeLimits().getMaximum() != null) {
        timeLimit = assessmentTest.getTimeLimits().getMaximum().longValue();
    }
    return timeLimit;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File)

Example 37 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.

the class AssessmentTestPreWarm method run.

@Override
public void run() {
    long start = System.nanoTime();
    FileResourceManager frm = FileResourceManager.getInstance();
    List<RepositoryEntry> entries = repositoryEntryDao.getLastUsedRepositoryEntries(ImsQTI21Resource.TYPE_NAME, 0, 20);
    for (RepositoryEntry entry : entries) {
        try {
            File fUnzippedDirRoot = frm.unzipFileResource(entry.getOlatResource());
            qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
        } catch (RuntimeException e) {
            log.error("Loading the AssessmentTest of repository entry: " + entry.getKey() + " (" + entry.getDisplayname() + ")", e);
        }
    }
    log.info(entries.size() + " AssessmentTest preloaded in (ms): " + CodeHelper.nanoToMilliTime(start));
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File)

Example 38 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.

the class QTI21ArchiveFormat method exportCourseElement.

public MediaResource exportCourseElement() {
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(searchParams.getTestEntry().getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    ICourse course = CourseFactory.loadCourse(searchParams.getCourseEntry());
    courseNode = course.getRunStructure().getNode(searchParams.getNodeIdent());
    String label = courseNode.getType() + "_" + StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())) + ".xlsx";
    if ("iqself".equals(courseNode.getType())) {
        anonymizerCallback = course.getCourseEnvironment().getCoursePropertyManager();
    }
    // content
    final List<AssessmentTestSession> sessions = testSessionDao.getTestSessionsOfResponse(searchParams);
    final List<AssessmentResponse> responses = responseDao.getResponse(searchParams);
    return new OpenXMLWorkbookResource(label) {

        @Override
        protected void generate(OutputStream out) {
            try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(out, 1)) {
                // headers
                OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
                exportSheet.setHeaderRows(2);
                writeHeaders_1(exportSheet, workbook);
                writeHeaders_2(exportSheet, workbook);
                writeData(sessions, responses, exportSheet, workbook);
            } catch (Exception e) {
                log.error("", e);
            }
        }
    };
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) OpenXMLWorkbookResource(org.olat.core.util.openxml.OpenXMLWorkbookResource) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) ZipOutputStream(java.util.zip.ZipOutputStream) OutputStream(java.io.OutputStream) ICourse(org.olat.course.ICourse) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) Date(java.util.Date) IOException(java.io.IOException) FileResourceManager(org.olat.fileresource.FileResourceManager) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) File(java.io.File)

Example 39 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.

the class QTI21ArchiveFormat method exportWorkbook.

public void exportWorkbook(OutputStream exportStream) {
    RepositoryEntry testEntry = searchParams.getTestEntry();
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    // content
    final List<AssessmentTestSession> sessions = testSessionDao.getTestSessionsOfResponse(searchParams);
    final List<AssessmentResponse> responses = responseDao.getResponse(searchParams);
    try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(exportStream, 1)) {
        // headers
        OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
        exportSheet.setHeaderRows(2);
        writeHeaders_1(exportSheet, workbook);
        writeHeaders_2(exportSheet, workbook);
        writeData(sessions, responses, exportSheet, workbook);
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) FileResourceManager(org.olat.fileresource.FileResourceManager) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) RepositoryEntry(org.olat.repository.RepositoryEntry) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) File(java.io.File) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) IOException(java.io.IOException)

Example 40 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method getDeliveryOptions.

@Override
public QTI21DeliveryOptions getDeliveryOptions(RepositoryEntry testEntry) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(testEntry.getOlatResource());
    File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
    QTI21DeliveryOptions config;
    if (configXml.exists()) {
        config = (QTI21DeliveryOptions) configXstream.fromXML(configXml);
    } else {
        // set default config
        config = QTI21DeliveryOptions.defaultSettings();
        setDeliveryOptions(testEntry, config);
    }
    return config;
}
Also used : QTI21DeliveryOptions(org.olat.ims.qti21.QTI21DeliveryOptions) FileResourceManager(org.olat.fileresource.FileResourceManager) File(java.io.File)

Aggregations

FileResourceManager (org.olat.fileresource.FileResourceManager)62 File (java.io.File)60 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)16 IOException (java.io.IOException)14 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)12 OutputStream (java.io.OutputStream)10 FileOutputStream (java.io.FileOutputStream)8 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 URI (java.net.URI)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)4 OpenXMLWorkbook (org.olat.core.util.openxml.OpenXMLWorkbook)4 AssessmentResultController (org.olat.ims.qti21.ui.AssessmentResultController)4 QuestionItem (org.olat.modules.qpool.QuestionItem)4 OpenXMLWorksheet (org.olat.core.util.openxml.OpenXMLWorksheet)3 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)3 ZipOutputStream (java.util.zip.ZipOutputStream)2 Attribute (org.dom4j.Attribute)2