Search in sources :

Example 16 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project openolat by klemens.

the class QTI21ResultsExportMediaResource method createResultDetail.

private List<ResultDetail> createResultDetail(Identity identity, ZipOutputStream zout, String idDir) throws IOException {
    List<ResultDetail> assessments = new ArrayList<>();
    List<AssessmentTestSession> sessions = qtiService.getAssessmentTestSessions(entry, courseNode.getIdent(), identity);
    for (AssessmentTestSession session : sessions) {
        Long assessmentID = session.getKey();
        String idPath = idDir + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1) + SEP;
        createZipDirectory(zout, idPath);
        // content of result table
        ResultDetail resultDetail = new ResultDetail(assessmentID.toString(), assessmentDateFormat.format(session.getCreationDate()), displayDateFormat.format(new Date(session.getDuration())), session.getScore(), session.getManualScore(), createPassedIcons(session.getPassed() == null ? true : session.getPassed()), idPath.replace(idDir, "") + assessmentID + ".html");
        assessments.add(resultDetail);
        // WindowControlMocker needed because this is not a controller
        WindowControl mockwControl = new WindowControlMocker();
        FileResourceManager frm = FileResourceManager.getInstance();
        RepositoryEntry testEntry = session.getTestEntry();
        testEntries.add(testEntry);
        File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
        // add test repo key
        String mapperUri = "../../../test" + testEntry.getKey() + "/";
        String submissionMapperUri = ".";
        String exportUri = "../" + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1);
        Controller assessmentResultController = new AssessmentResultController(ureq, mockwControl, identity, false, session, fUnzippedDirRoot, mapperUri, submissionMapperUri, QTI21AssessmentResultsOptions.allOptions(), false, true, false, exportUri);
        Component component = assessmentResultController.getInitialComponent();
        String componentHTML = createResultHTML(component);
        convertToZipEntry(zout, idPath + assessmentID + ".html", componentHTML);
        File resultXML = qtiService.getAssessmentResultFile(session);
        convertToZipEntry(zout, idPath + assessmentID + ".xml", resultXML);
        File signatureXML = qtiService.getAssessmentResultSignature(session);
        if (signatureXML != null) {
            convertToZipEntry(zout, idPath + "assessmentResultSignature.xml", signatureXML);
        }
        File submissionDir = qtiService.getSubmissionDirectory(session);
        String baseDir = idPath + "submissions";
        ZipUtil.addDirectoryToZip(submissionDir.toPath(), baseDir, zout);
    }
    return assessments;
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) Controller(org.olat.core.gui.control.Controller) Date(java.util.Date) FileResourceManager(org.olat.fileresource.FileResourceManager) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) Component(org.olat.core.gui.components.Component) File(java.io.File) WindowControlMocker(org.olat.core.gui.util.WindowControlMocker)

Example 17 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project openolat by klemens.

the class QTI21ResultsExportMediaResource method copyTestMaterials.

private void copyTestMaterials(RepositoryEntry testEntry, ZipOutputStream zout) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    String baseDir = exportFolderName + "/test" + testEntry.getKey();
    ZipUtil.addDirectoryToZip(fUnzippedDirRoot.toPath(), baseDir, zout);
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) File(java.io.File)

Example 18 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project openolat by klemens.

the class PortfolioServiceImpl method setDeliveryOptions.

@Override
public void setDeliveryOptions(OLATResource resource, BinderDeliveryOptions options) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(resource);
    File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
    if (options == null) {
        if (configXml.exists()) {
            configXml.delete();
        }
    } else {
        try (OutputStream out = new FileOutputStream(configXml)) {
            configXstream.toXML(options, out);
        } catch (IOException e) {
            log.error("", e);
        }
    }
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) FileOutputStream(java.io.FileOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Example 19 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project openolat by klemens.

the class PortfolioServiceImpl method getDeliveryOptions.

@Override
public BinderDeliveryOptions getDeliveryOptions(OLATResource resource) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(resource);
    File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
    BinderDeliveryOptions config;
    if (configXml.exists()) {
        config = (BinderDeliveryOptions) configXstream.fromXML(configXml);
    } else {
        // set default config
        config = BinderDeliveryOptions.defaultOptions();
        setDeliveryOptions(resource, config);
    }
    return config;
}
Also used : BinderDeliveryOptions(org.olat.modules.portfolio.BinderDeliveryOptions) FileResourceManager(org.olat.fileresource.FileResourceManager) File(java.io.File)

Example 20 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project openolat by klemens.

the class WikiHandler method copy.

@Override
public RepositoryEntry copy(Identity author, RepositoryEntry source, RepositoryEntry target) {
    final OLATResource sourceResource = source.getOlatResource();
    final OLATResource targetResource = target.getOlatResource();
    final FileResourceManager frm = FileResourceManager.getInstance();
    File sourceDir = frm.getFileResourceRoot(sourceResource);
    File targetDir = frm.getFileResourceRoot(targetResource);
    WikiManager.getInstance().copyWiki(sourceDir, targetDir);
    return target;
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) OLATResource(org.olat.resource.OLATResource) 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