Search in sources :

Example 41 with FileResourceManager

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

the class QTI21ServiceImpl method setDeliveryOptions.

@Override
public void setDeliveryOptions(RepositoryEntry testEntry, QTI21DeliveryOptions options) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(testEntry.getOlatResource());
    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 42 with FileResourceManager

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

the class QTI21ServiceImpl method needManualCorrection.

@Override
public boolean needManualCorrection(RepositoryEntry testEntry) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
    return AssessmentTestHelper.needManualCorrection(resolvedAssessmentTest);
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File)

Example 43 with FileResourceManager

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

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

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

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

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

the class QTIEditorPackageImpl method unzipPackage.

/**
 * Unzip package into temporary directory.
 * @return true if successfull, false otherwise
 */
private boolean unzipPackage() {
    FileResourceManager frm = FileResourceManager.getInstance();
    File fPackageZIP = frm.getFileResource(fileResource);
    return ZipUtil.unzip(fPackageZIP, packageDir);
}
Also used : 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