use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class WikiHandler method copy.
@Override
public RepositoryEntry copy(Identity author, RepositoryEntry source, RepositoryEntry target) {
final OLATResource sourceResource = source.getOlatResource();
final OLATResource targetResource = target.getOlatResource();
final FileResourceManager frm = FileResourceManager.getInstance();
File sourceDir = frm.getFileResourceRoot(sourceResource);
File targetDir = frm.getFileResourceRoot(targetResource);
WikiManager.getInstance().copyWiki(sourceDir, targetDir);
return target;
}
use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class QTI21QPoolServiceProvider method importRepositoryEntry.
public List<QuestionItem> importRepositoryEntry(Identity owner, RepositoryEntry repositoryEntry, Locale defaultLocale) {
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(repositoryEntry.getOlatResource());
ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, true);
ManifestBuilder clonedManifestBuilder = ManifestBuilder.read(new File(unzippedDirRoot, "imsmanifest.xml"));
List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getAssessmentItemRefs();
List<QuestionItem> importedItems = new ArrayList<>(itemRefs.size());
for (AssessmentItemRef itemRef : itemRefs) {
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
RootNodeLookup<AssessmentItem> rootNode = resolvedAssessmentItem.getItemLookup();
URI itemUri = rootNode.getSystemId();
File itemFile = new File(itemUri);
String relativePathToManifest = unzippedDirRoot.toPath().relativize(itemFile.toPath()).toString();
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
ResourceType resource = clonedManifestBuilder.getResourceTypeByHref(relativePathToManifest);
ManifestMetadataBuilder metadata = clonedManifestBuilder.getMetadataBuilder(resource, true);
QuestionItem qitem = importAssessmentItemRef(owner, assessmentItem, itemFile, metadata, defaultLocale);
importedItems.add(qitem);
}
return importedItems;
}
use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class QTI21ResultsExportMediaResource method createResultDetail.
private List<ResultDetail> createResultDetail(Identity identity, ZipOutputStream zout, String idDir) throws IOException {
List<ResultDetail> assessments = new ArrayList<>();
List<AssessmentTestSession> sessions = qtiService.getAssessmentTestSessions(entry, courseNode.getIdent(), identity);
for (AssessmentTestSession session : sessions) {
Long assessmentID = session.getKey();
String idPath = idDir + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1) + SEP;
createZipDirectory(zout, idPath);
// content of result table
ResultDetail resultDetail = new ResultDetail(assessmentID.toString(), assessmentDateFormat.format(session.getCreationDate()), displayDateFormat.format(new Date(session.getDuration())), session.getScore(), session.getManualScore(), createPassedIcons(session.getPassed() == null ? true : session.getPassed()), idPath.replace(idDir, "") + assessmentID + ".html");
assessments.add(resultDetail);
// WindowControlMocker needed because this is not a controller
WindowControl mockwControl = new WindowControlMocker();
FileResourceManager frm = FileResourceManager.getInstance();
RepositoryEntry testEntry = session.getTestEntry();
testEntries.add(testEntry);
File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
// add test repo key
String mapperUri = "../../../test" + testEntry.getKey() + "/";
String submissionMapperUri = ".";
String exportUri = "../" + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1);
Controller assessmentResultController = new AssessmentResultController(ureq, mockwControl, identity, false, session, fUnzippedDirRoot, mapperUri, submissionMapperUri, QTI21AssessmentResultsOptions.allOptions(), false, true, false, exportUri);
Component component = assessmentResultController.getInitialComponent();
String componentHTML = createResultHTML(component);
convertToZipEntry(zout, idPath + assessmentID + ".html", componentHTML);
File resultXML = qtiService.getAssessmentResultFile(session);
convertToZipEntry(zout, idPath + assessmentID + ".xml", resultXML);
File signatureXML = qtiService.getAssessmentResultSignature(session);
if (signatureXML != null) {
convertToZipEntry(zout, idPath + "assessmentResultSignature.xml", signatureXML);
}
File submissionDir = qtiService.getSubmissionDirectory(session);
String baseDir = idPath + "submissions";
ZipUtil.addDirectoryToZip(submissionDir.toPath(), baseDir, zout);
}
return assessments;
}
use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class QTI21RuntimeController method getAssessableElement.
private AssessableResource getAssessableElement(RepositoryEntry testEntry) {
FileResourceManager frm = FileResourceManager.getInstance();
File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentTest);
Double minScore = QtiNodesExtractor.extractMinScore(assessmentTest);
boolean hasScore = assessmentTest.getOutcomeDeclaration(QTI21Constants.SCORE_IDENTIFIER) != null;
boolean hasPassed = assessmentTest.getOutcomeDeclaration(QTI21Constants.PASS_IDENTIFIER) != null;
return new QTI21AssessableResource(hasScore, hasPassed, true, true, minScore, maxScore, null);
}
use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
the class QTI21QPoolServiceProvider method importRepositoryEntry.
public List<QuestionItem> importRepositoryEntry(Identity owner, RepositoryEntry repositoryEntry, Locale defaultLocale) {
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedDirRoot = frm.unzipFileResource(repositoryEntry.getOlatResource());
ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, true);
ManifestBuilder clonedManifestBuilder = ManifestBuilder.read(new File(unzippedDirRoot, "imsmanifest.xml"));
List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getAssessmentItemRefs();
List<QuestionItem> importedItems = new ArrayList<>(itemRefs.size());
for (AssessmentItemRef itemRef : itemRefs) {
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
RootNodeLookup<AssessmentItem> rootNode = resolvedAssessmentItem.getItemLookup();
URI itemUri = rootNode.getSystemId();
File itemFile = new File(itemUri);
String relativePathToManifest = unzippedDirRoot.toPath().relativize(itemFile.toPath()).toString();
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
ResourceType resource = clonedManifestBuilder.getResourceTypeByHref(relativePathToManifest);
ManifestMetadataBuilder metadata = clonedManifestBuilder.getMetadataBuilder(resource, true);
QuestionItem qitem = importAssessmentItemRef(owner, assessmentItem, itemFile, metadata, defaultLocale);
importedItems.add(qitem);
}
return importedItems;
}
Aggregations