Search in sources :

Example 61 with FileResourceManager

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

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)

Example 62 with FileResourceManager

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

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)

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