Search in sources :

Example 1 with FileResourceManager

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

the class QTIQPoolServiceProvider method importRepositoryEntry.

public List<QuestionItem> importRepositoryEntry(Identity owner, RepositoryEntry repositoryEntry, Locale defaultLocale) {
    OLATResourceable ores = repositoryEntry.getOlatResource();
    FileResourceManager frm = FileResourceManager.getInstance();
    File testFile = frm.getFileResource(ores);
    List<QuestionItem> importedItem = importItems(owner, defaultLocale, testFile.getName(), testFile);
    if (importedItem != null && importedItem.size() > 0) {
        dbInstance.getCurrentEntityManager().flush();
    }
    return importedItem;
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) OLATResourceable(org.olat.core.id.OLATResourceable) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 2 with FileResourceManager

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

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 3 with FileResourceManager

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

the class CPManagerImpl method getCPPackageConfig.

@Override
public CPPackageConfig getCPPackageConfig(OLATResourceable ores) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(ores);
    File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
    CPPackageConfig config;
    if (configXml.exists()) {
        config = (CPPackageConfig) configXstream.fromXML(configXml);
    } else {
        // set default config
        config = new CPPackageConfig();
        config.setDeliveryOptions(DeliveryOptions.defaultWithGlossary());
        setCPPackageConfig(ores, config);
    }
    return config;
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) File(java.io.File)

Example 4 with FileResourceManager

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

the class CPManagerImpl method setCPPackageConfig.

@Override
public void setCPPackageConfig(OLATResourceable ores, CPPackageConfig config) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(ores);
    File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
    if (config == null) {
        if (configXml.exists()) {
            configXml.delete();
        }
    } else {
        OutputStream out = null;
        try {
            out = new FileOutputStream(configXml);
            configXstream.toXML(config, out);
        } catch (IOException e) {
            log.error("", e);
        } finally {
            IOUtils.closeQuietly(out);
        }
    }
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Example 5 with FileResourceManager

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

the class ScormMainManager method setScormPackageConfig.

public void setScormPackageConfig(OLATResourceable ores, ScormPackageConfig config) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(ores);
    File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
    if (config == null) {
        if (configXml.exists()) {
            configXml.delete();
        }
    } else {
        OutputStream out = null;
        try {
            out = new FileOutputStream(configXml);
            configXstream.toXML(config, out);
        } catch (IOException e) {
            log.error("", e);
        } finally {
            IOUtils.closeQuietly(out);
        }
    }
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) 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