Search in sources :

Example 51 with FileResourceManager

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

the class ScormMainManager method getScormPackageConfig.

public ScormPackageConfig getScormPackageConfig(OLATResourceable ores) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(ores);
    File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
    if (configXml.exists()) {
        ScormPackageConfig config = (ScormPackageConfig) configXstream.fromXML(configXml);
        return config;
    }
    return null;
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) File(java.io.File)

Example 52 with FileResourceManager

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

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)

Example 53 with FileResourceManager

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

the class QTI21EditForm method update.

protected void update(RepositoryEntry testEntry) {
    Double minValue = null;
    Double maxValue = null;
    Double cutValue = null;
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
    if (assessmentTest != null) {
        AssessmentTestBuilder testBuilder = new AssessmentTestBuilder(assessmentTest);
        maxValue = testBuilder.getMaxScore();
        cutValue = testBuilder.getCutValue();
        if (maxValue != null && "OpenOLAT".equals(assessmentTest.getToolName())) {
            minValue = 0d;
        }
    }
    // Put values to module configuration
    minScoreEl.setValue(minValue == null ? "" : AssessmentHelper.getRoundedScore(minValue));
    minScoreEl.setVisible(minValue != null);
    maxScoreEl.setValue(maxValue == null ? "" : AssessmentHelper.getRoundedScore(maxValue));
    maxScoreEl.setVisible(maxValue != null);
    cutValueEl.setValue(cutValue == null ? "" : AssessmentHelper.getRoundedScore(cutValue));
    cutValueEl.setVisible(cutValue != null);
    update();
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) AssessmentTestBuilder(org.olat.ims.qti21.model.xml.AssessmentTestBuilder) FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File)

Example 54 with FileResourceManager

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

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

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

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)

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