use of org.olat.course.nodes.gta.GTAManager in project OpenOLAT by OpenOLAT.
the class GTACourseNode method archiveNodeData.
private void archiveNodeData(ICourse course, Identity assessedIdentity, TaskList taskList, String dirName, ZipOutputStream exportStream) {
ModuleConfiguration config = getModuleConfiguration();
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
String name = assessedIdentity.getUser().getLastName() + "_" + assessedIdentity.getUser().getFirstName() + "_" + assessedIdentity.getName();
// for beautiful ordering
int flow = 0;
String userDirName = dirName + "/" + StringHelper.transformDisplayNameToFileSystemName(name);
Task task = gtaManager.getTask(assessedIdentity, taskList);
if (task != null && task.getTaskName() != null && config.getBooleanSafe(GTASK_ASSIGNMENT)) {
File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
File taskFile = new File(taskDirectory, task.getTaskName());
if (taskFile.exists()) {
String path = userDirName + "/" + (++flow) + "_task/" + taskFile.getName();
ZipUtil.addFileToZip(path, taskFile, exportStream);
}
}
if (config.getBooleanSafe(GTASK_SUBMIT)) {
File submitDirectory = gtaManager.getSubmitDirectory(course.getCourseEnvironment(), this, assessedIdentity);
String submissionDirName = userDirName + "/" + (++flow) + "_submissions";
ZipUtil.addDirectoryToZip(submitDirectory.toPath(), submissionDirName, exportStream);
}
if (config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION)) {
File correctionsDir = gtaManager.getCorrectionDirectory(course.getCourseEnvironment(), this, assessedIdentity);
String correctionDirName = userDirName + "/" + (++flow) + "_corrections";
ZipUtil.addDirectoryToZip(correctionsDir.toPath(), correctionDirName, exportStream);
}
if (task != null && config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
int numOfIteration = task.getRevisionLoop();
for (int i = 1; i <= numOfIteration; i++) {
File revisionDirectory = gtaManager.getRevisedDocumentsDirectory(course.getCourseEnvironment(), this, i, assessedIdentity);
String revisionDirName = userDirName + "/" + (++flow) + "_revisions_" + i;
ZipUtil.addDirectoryToZip(revisionDirectory.toPath(), revisionDirName, exportStream);
File correctionDirectory = gtaManager.getRevisedDocumentsCorrectionsDirectory(course.getCourseEnvironment(), this, i, assessedIdentity);
String correctionDirName = userDirName + "/" + (++flow) + "_corrections_" + i;
ZipUtil.addDirectoryToZip(correctionDirectory.toPath(), correctionDirName, exportStream);
}
}
// assessment documents
if (config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_INDIVIDUAL_ASSESSMENT_DOCS, false)) {
List<File> assessmentDocuments = course.getCourseEnvironment().getAssessmentManager().getIndividualAssessmentDocuments(this, assessedIdentity);
if (assessmentDocuments != null && !assessmentDocuments.isEmpty()) {
String assessmentDir = userDirName + "/" + (++flow) + "_assessment/";
for (File document : assessmentDocuments) {
String path = assessmentDir + document.getName();
ZipUtil.addFileToZip(path, document, exportStream);
}
}
}
}
use of org.olat.course.nodes.gta.GTAManager in project OpenOLAT by OpenOLAT.
the class GTACourseNode method importNode.
@Override
public void importNode(File importDirectory, ICourse course, Identity owner, Locale locale, boolean withReferences) {
File fNodeImportDir = new File(importDirectory, getIdent());
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
// import tasks
File tasksImportDir = new File(fNodeImportDir, "tasks");
File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
FileUtils.copyDirContentsToDir(tasksImportDir, taskDirectory, false, "import task course node");
File taskDefinitions = new File(tasksImportDir.getParentFile(), GTAManager.TASKS_DEFINITIONS);
if (taskDefinitions.exists()) {
File copyTaskDefinitions = new File(taskDirectory.getParentFile(), GTAManager.TASKS_DEFINITIONS);
FileUtils.copyFileToFile(taskDefinitions, copyTaskDefinitions, false);
}
// import solutions
File fSolImportDir = new File(fNodeImportDir, "solutions");
File solutionsDirectory = gtaManager.getSolutionsDirectory(course.getCourseEnvironment(), this);
FileUtils.copyDirContentsToDir(fSolImportDir, solutionsDirectory, false, "import task course node solutions");
File solutionDefinitions = new File(fSolImportDir.getParentFile(), GTAManager.SOLUTIONS_DEFINITIONS);
if (solutionDefinitions.exists()) {
File copySolutionDefinitions = new File(solutionsDirectory.getParentFile(), GTAManager.SOLUTIONS_DEFINITIONS);
FileUtils.copyFileToFile(solutionDefinitions, copySolutionDefinitions, false);
}
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
gtaManager.createIfNotExists(entry, this);
}
use of org.olat.course.nodes.gta.GTAManager in project openolat by klemens.
the class BulkAssessmentTask method getReturnBox.
/**
* Return the target folder of the assessed identity. This is a factory method which take care
* of the type of the course node.
*
* @param uce
* @param courseNode
* @param identity
* @return
*/
private VFSContainer getReturnBox(UserCourseEnvironment uce, CourseNode courseNode, Identity identity) {
VFSContainer returnContainer = null;
if (courseNode instanceof GTACourseNode) {
final GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
CourseEnvironment courseEnv = uce.getCourseEnvironment();
returnContainer = gtaManager.getCorrectionContainer(courseEnv, (GTACourseNode) courseNode, identity);
} else {
String returnPath = ReturnboxController.getReturnboxPathRelToFolderRoot(uce.getCourseEnvironment(), courseNode);
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(returnPath, null);
VFSItem assessedItem = rootFolder.resolve(identity.getName());
if (assessedItem == null) {
returnContainer = rootFolder.createChildContainer(identity.getName());
} else if (assessedItem instanceof VFSContainer) {
returnContainer = (VFSContainer) assessedItem;
}
}
return returnContainer;
}
use of org.olat.course.nodes.gta.GTAManager in project openolat by klemens.
the class GTACourseNode method exportNode.
/**
* The files are exported in export/{node ident}/tasks and export/{node ident}/solutions
*/
@Override
public void exportNode(File fExportDirectory, ICourse course) {
File fNodeExportDir = new File(fExportDirectory, getIdent());
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
// export the tasks
File tasksExportDir = new File(fNodeExportDir, "tasks");
File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
fNodeExportDir.mkdirs();
FileUtils.copyDirContentsToDir(taskDirectory, tasksExportDir, false, "export task course node");
File taskDefinitions = new File(taskDirectory.getParentFile(), GTAManager.TASKS_DEFINITIONS);
if (taskDefinitions.exists()) {
File copyTaskDefinitions = new File(tasksExportDir.getParentFile(), GTAManager.TASKS_DEFINITIONS);
FileUtils.copyFileToFile(taskDefinitions, copyTaskDefinitions, false);
}
// export the solutions
File fSolExportDir = new File(fNodeExportDir, "solutions");
File solutionsDirectory = gtaManager.getSolutionsDirectory(course.getCourseEnvironment(), this);
fSolExportDir.mkdirs();
FileUtils.copyDirContentsToDir(solutionsDirectory, fSolExportDir, false, "export task course node solutions");
File solutionDefinitions = new File(solutionsDirectory.getParentFile(), GTAManager.SOLUTIONS_DEFINITIONS);
if (solutionDefinitions.exists()) {
File copySolutionDefinitions = new File(fSolExportDir.getParentFile(), GTAManager.SOLUTIONS_DEFINITIONS);
FileUtils.copyFileToFile(solutionDefinitions, copySolutionDefinitions, false);
}
}
use of org.olat.course.nodes.gta.GTAManager in project openolat by klemens.
the class GTACourseNode method cleanupOnDelete.
@Override
public void cleanupOnDelete(ICourse course) {
super.cleanupOnDelete(course);
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
// tasks
File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
FileUtils.deleteDirsAndFiles(taskDirectory, true, true);
// solutions
File solutionsDirectory = gtaManager.getSolutionsDirectory(course.getCourseEnvironment(), this);
FileUtils.deleteDirsAndFiles(solutionsDirectory, true, true);
// clean up database
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
gtaManager.deleteTaskList(entry, this);
// clean subscription
SubscriptionContext subscriptionContext = gtaManager.getSubscriptionContext(course.getCourseEnvironment(), this);
NotificationsManager.getInstance().delete(subscriptionContext);
}
Aggregations