Search in sources :

Example 46 with FileResourceManager

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

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

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

the class QTI21AssessmentDetailsController method doOpenResult.

private void doOpenResult(UserRequest ureq, AssessmentTestSession session) {
    if (resultCtrl != null)
        return;
    // reload it to prevent lazy loading issues
    session = qtiService.getAssessmentTestSession(session.getKey());
    FileResourceManager frm = FileResourceManager.getInstance();
    File fUnzippedDirRoot = frm.unzipFileResource(session.getTestEntry().getOlatResource());
    URI assessmentObjectUri = qtiService.createAssessmentTestUri(fUnzippedDirRoot);
    File submissionDir = qtiService.getSubmissionDirectory(session);
    String mapperUri = registerCacheableMapper(ureq, "QTI21DetailsResources::" + session.getKey(), new ResourcesMapper(assessmentObjectUri, submissionDir));
    resultCtrl = new AssessmentResultController(ureq, getWindowControl(), assessedIdentity, false, session, fUnzippedDirRoot, mapperUri, null, QTI21AssessmentResultsOptions.allOptions(), true, true, true);
    listenTo(resultCtrl);
    cmc = new CloseableModalController(getWindowControl(), "close", resultCtrl.getInitialComponent(), true, translate("results.report"));
    cmc.activate();
    listenTo(cmc);
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) File(java.io.File) URI(java.net.URI)

Example 48 with FileResourceManager

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

the class CPOfflineReadableManager method makeCPOfflineReadable.

/**
 * "exports" the the given CP (specified by its OLATResourceable) to a
 * zipFile.<br />
 * The resulting zip contains a "offline-readable" version of the CP.
 * including style-sheets, menu-Tree and OpenOLAT branding
 *
 * @param ores
 *            the OLATResourceable (expected to be a CP)
 * @param zipName
 *            the resulting zip-filename
 */
public void makeCPOfflineReadable(OLATResourceable ores, String zipName) {
    try {
        String repositoryHome = FolderConfig.getCanonicalRepositoryHome();
        FileResourceManager fm = FileResourceManager.getInstance();
        String relPath = fm.getUnzippedDirRel(ores);
        String resId = ores.getResourceableId().toString();
        File unzippedDir = new File(repositoryHome + "/" + relPath);
        File targetZip = new File(repositoryHome + "/" + resId + "/" + zipName);
        File cpOfflineMat = new File(WebappHelper.getContextRealPath("/static/" + DIRNAME_CPOFFLINEMENUMAT));
        writeOfflineCPStartHTMLFile(unzippedDir);
        zipOfflineReadableCP(unzippedDir, targetZip, cpOfflineMat);
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) IOException(java.io.IOException) File(java.io.File)

Example 49 with FileResourceManager

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

the class QTI21StatisticResourceResult method getSubTreeModel.

/**
 * Return the tree model for a course and a specific test.
 */
@Override
public TreeModel getSubTreeModel() {
    GenericTreeModel subTreeModel = new GenericTreeModel();
    StatisticResourceNode rootTreeNode = new StatisticResourceNode(courseNode, this);
    subTreeModel.setRootNode(rootTreeNode);
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest test = resolvedAssessmentTest.getTestLookup().getRootNodeHolder().getRootNode();
    buildRecursively(test, rootTreeNode);
    return subTreeModel;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) StatisticResourceNode(org.olat.course.statistic.StatisticResourceNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) File(java.io.File)

Example 50 with FileResourceManager

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

the class QTI21StatisticResourceResult method getTreeModel.

/**
 * Return the tree model for a test learn resource.
 *
 * @return
 */
public TreeModel getTreeModel() {
    GenericTreeModel treeModel = new GenericTreeModel();
    GenericTreeNode rootTreeNode = new GenericTreeNode();
    treeModel.setRootNode(rootTreeNode);
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest test = resolvedAssessmentTest.getTestLookup().getRootNodeHolder().getRootNode();
    rootTreeNode.setTitle(test.getTitle());
    rootTreeNode.setUserObject(test);
    rootTreeNode.setIconCssClass("o_icon o_icon-lg o_qtiassessment_icon");
    buildRecursively(test, rootTreeNode);
    return treeModel;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) 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