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