Search in sources :

Example 6 with GTAManager

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);
            }
        }
    }
}
Also used : Task(org.olat.course.nodes.gta.Task) ModuleConfiguration(org.olat.modules.ModuleConfiguration) GTAManager(org.olat.course.nodes.gta.GTAManager) File(java.io.File)

Example 7 with GTAManager

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);
}
Also used : GTAManager(org.olat.course.nodes.gta.GTAManager) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File)

Example 8 with GTAManager

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;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) GTACourseNode(org.olat.course.nodes.GTACourseNode) GTAManager(org.olat.course.nodes.gta.GTAManager) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 9 with GTAManager

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);
    }
}
Also used : GTAManager(org.olat.course.nodes.gta.GTAManager) File(java.io.File)

Example 10 with GTAManager

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);
}
Also used : GTAManager(org.olat.course.nodes.gta.GTAManager) RepositoryEntry(org.olat.repository.RepositoryEntry) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) File(java.io.File)

Aggregations

GTAManager (org.olat.course.nodes.gta.GTAManager)24 File (java.io.File)16 RepositoryEntry (org.olat.repository.RepositoryEntry)10 Identity (org.olat.core.id.Identity)8 ModuleConfiguration (org.olat.modules.ModuleConfiguration)8 TaskList (org.olat.course.nodes.gta.TaskList)6 OutputStream (java.io.OutputStream)4 Date (java.util.Date)4 ZipEntry (java.util.zip.ZipEntry)4 ZipOutputStream (java.util.zip.ZipOutputStream)4 ShieldOutputStream (org.olat.core.util.io.ShieldOutputStream)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 ICourse (org.olat.course.ICourse)4 Task (org.olat.course.nodes.gta.Task)4 BusinessGroup (org.olat.group.BusinessGroup)4 BusinessGroupService (org.olat.group.BusinessGroupService)4 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 IdentityRef (org.olat.basesecurity.IdentityRef)2