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;
}
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);
}
}
Aggregations