use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class LinkFileCombiCalloutController method doUnzip.
private VFSContainer doUnzip(VFSLeaf vfsItem, VFSContainer currentContainer) {
String name = vfsItem.getName();
// we make a new folder with the same name as the zip file
String sZipContainer = name.substring(0, name.length() - 4);
// if zip already exists, create another folder 1,2,3 etc.
VFSContainer zipContainer = currentContainer.createChildContainer(sZipContainer);
int i = 1;
while (zipContainer == null && i < 100) {
i++;
sZipContainer = FileUtils.appendNumberAtTheEndOfFilename(sZipContainer, i);
zipContainer = currentContainer.createChildContainer(sZipContainer);
}
if (!ZipUtil.unzip(vfsItem, zipContainer)) {
// operation failed - rollback
zipContainer.delete();
return null;
} else {
// check quota
long quotaLeftKB = VFSManager.getQuotaLeftKB(currentContainer);
if (quotaLeftKB != Quota.UNLIMITED && quotaLeftKB < 0) {
// quota exceeded - rollback
zipContainer.delete();
getWindowControl().setError(translate("QuotaExceeded"));
return null;
}
}
return zipContainer;
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class GTACoachController method stepSolution.
@Override
protected Task stepSolution(UserRequest ureq, Task assignedTask) {
assignedTask = super.stepSolution(ureq, assignedTask);
if (config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT) || config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT) || config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION) || config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.assignment || assignedTask.getTaskStatus() == TaskProcess.submit || assignedTask.getTaskStatus() == TaskProcess.review || assignedTask.getTaskStatus() == TaskProcess.correction || assignedTask.getTaskStatus() == TaskProcess.revision) {
mainVC.contextPut("solutionCssClass", "");
} else if (assignedTask.getTaskStatus() == TaskProcess.solution) {
mainVC.contextPut("solutionCssClass", "o_active");
} else {
mainVC.contextPut("solutionCssClass", "o_done");
}
} else if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.solution) {
mainVC.contextPut("solutionCssClass", "o_active");
} else {
mainVC.contextPut("solutionCssClass", "o_done");
}
File documentsDir = gtaManager.getSolutionsDirectory(courseEnv, gtaNode);
VFSContainer documentsContainer = gtaManager.getSolutionsContainer(courseEnv, gtaNode);
solutionsCtrl = new DirectoryController(ureq, getWindowControl(), documentsDir, documentsContainer, "run.solutions.description", "bulk.solutions", "solutions");
listenTo(solutionsCtrl);
mainVC.put("solutions", solutionsCtrl.getInitialComponent());
return assignedTask;
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class GTACoachController method stepSubmit.
@Override
protected Task stepSubmit(UserRequest ureq, Task assignedTask) {
assignedTask = super.stepSubmit(ureq, assignedTask);
if (collectSubmissionsLink != null) {
// clean up
mainVC.remove(collectSubmissionsLink);
}
if (backToSubmissionLink != null) {
mainVC.remove(backToSubmissionLink);
}
// calculate state
boolean viewSubmittedDocument = false;
if (config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT)) {
if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.assignment) {
mainVC.contextPut("submitCssClass", "");
} else if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.submit) {
mainVC.contextPut("submitCssClass", "o_active");
collect(assignedTask);
} else {
mainVC.contextPut("submitCssClass", "o_done");
viewSubmittedDocument = true;
}
} else if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.submit) {
mainVC.contextPut("submitCssClass", "o_active");
collect(assignedTask);
} else {
mainVC.contextPut("submitCssClass", "o_done");
viewSubmittedDocument = true;
}
if (assignedTask == null || (assignedTask.getTaskStatus() != TaskProcess.submit)) {
backToSubmission(assignedTask);
}
if (viewSubmittedDocument) {
File documentsDir;
VFSContainer documentsContainer = null;
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
documentsDir = gtaManager.getSubmitDirectory(courseEnv, gtaNode, assessedGroup);
documentsContainer = gtaManager.getSubmitContainer(courseEnv, gtaNode, assessedGroup);
} else {
documentsDir = gtaManager.getSubmitDirectory(courseEnv, gtaNode, assessedIdentity);
documentsContainer = gtaManager.getSubmitContainer(courseEnv, gtaNode, assessedIdentity);
}
boolean hasDocuments = TaskHelper.hasDocuments(documentsDir);
if (hasDocuments) {
submittedDocCtrl = new DirectoryController(ureq, getWindowControl(), documentsDir, documentsContainer, "coach.submitted.documents.description", "bulk.submitted.documents", "submission");
listenTo(submittedDocCtrl);
mainVC.put("submittedDocs", submittedDocCtrl.getInitialComponent());
} else {
TextFactory.createTextComponentFromI18nKey("submittedDocs", "coach.submitted.nofiles", getTranslator(), null, true, mainVC);
}
}
return assignedTask;
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class GTACoachController method setUploadCorrections.
private void setUploadCorrections(UserRequest ureq, Task task) {
File documentsDir;
VFSContainer documentsContainer;
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
documentsDir = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, assessedGroup);
documentsContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedGroup);
} else {
documentsDir = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, assessedIdentity);
documentsContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedIdentity);
}
submitCorrectionsCtrl = new SubmitDocumentsController(ureq, getWindowControl(), task, documentsDir, documentsContainer, -1, gtaNode, courseEnv, coachCourseEnv.isCourseReadOnly(), null, "coach.document");
listenTo(submitCorrectionsCtrl);
mainVC.put("corrections", submitCorrectionsCtrl.getInitialComponent());
reviewedButton.setVisible(!coachCourseEnv.isCourseReadOnly());
if (config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
needRevisionsButton.setVisible(!coachCourseEnv.isCourseReadOnly());
}
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class GTACoachController method setCorrections.
private void setCorrections(UserRequest ureq, boolean hasRevisions) {
File documentsDir;
VFSContainer documentsContainer;
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
documentsDir = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, assessedGroup);
documentsContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedGroup);
} else {
documentsDir = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, assessedIdentity);
documentsContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedIdentity);
}
boolean hasDocuments = TaskHelper.hasDocuments(documentsDir);
if (hasDocuments) {
correctionsCtrl = new DirectoryController(ureq, getWindowControl(), documentsDir, documentsContainer, "coach.corrections.description", "bulk.review", "review");
listenTo(correctionsCtrl);
mainVC.put("corrections", correctionsCtrl.getInitialComponent());
} else if (hasRevisions) {
String msg = "<i class='o_icon o_icon_warn'> </i> " + translate("coach.corrections.rejected");
TextFactory.createTextComponentFromString("corrections", msg, null, true, mainVC);
} else {
String msg = "<i class='o_icon o_icon_ok'> </i> " + translate("coach.corrections.closed");
TextFactory.createTextComponentFromString("corrections", msg, null, true, mainVC);
}
}
Aggregations