Search in sources :

Example 71 with Task

use of org.olat.course.nodes.gta.Task in project openolat by klemens.

the class GTAManagerTest method getTasks.

@Test
public void getTasks() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-3");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-4");
    BusinessGroup businessGroup = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRole(participant, businessGroup, GroupRole.participant.name());
    dbInstance.commit();
    RepositoryEntry re = deployGTACourse();
    GTACourseNode node = getGTACourseNode(re);
    node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    File taskFile = new File("bg.txt");
    Assert.assertNotNull(tasks);
    dbInstance.commit();
    // select
    AssignmentResponse response = gtaManager.selectTask(businessGroup, tasks, node, taskFile);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(response);
    List<Task> assignedTasks = gtaManager.getTasks(participant, re, node);
    Assert.assertNotNull(assignedTasks);
    Assert.assertEquals(1, assignedTasks.size());
}
Also used : Task(org.olat.course.nodes.gta.Task) BusinessGroup(org.olat.group.BusinessGroup) TaskList(org.olat.course.nodes.gta.TaskList) GTACourseNode(org.olat.course.nodes.GTACourseNode) AssignmentResponse(org.olat.course.nodes.gta.AssignmentResponse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) File(java.io.File) Test(org.junit.Test)

Example 72 with Task

use of org.olat.course.nodes.gta.Task in project openolat by klemens.

the class GTAManagerTest method updateTaskName.

@Test
public void updateTaskName() {
    // create an individual task
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-7");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-8");
    RepositoryEntry re = deployGTACourse();
    GTACourseNode node = getGTACourseNode(re);
    node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    TaskList taskList = gtaManager.createIfNotExists(re, node);
    dbInstance.commit();
    Assert.assertNotNull(taskList);
    // select
    gtaManager.selectTask(id1, taskList, node, new File("work_1.txt"));
    gtaManager.selectTask(id2, taskList, node, new File("work_2.txt"));
    dbInstance.commit();
    // change a name
    int rowUpdated = gtaManager.updateTaskName(taskList, "work_1.txt", "changed_work.txt");
    dbInstance.commitAndCloseSession();
    Assert.assertEquals(1, rowUpdated);
    // check
    Task assignedTaskToId1 = gtaManager.getTask(id1, taskList);
    Assert.assertNotNull(assignedTaskToId1);
    Assert.assertEquals("changed_work.txt", assignedTaskToId1.getTaskName());
    List<Task> assignedTaskToId2 = gtaManager.getTasks(id2, re, node);
    Assert.assertNotNull(assignedTaskToId2);
    Assert.assertEquals(1, assignedTaskToId2.size());
    Assert.assertEquals("work_2.txt", assignedTaskToId2.get(0).getTaskName());
}
Also used : Task(org.olat.course.nodes.gta.Task) TaskList(org.olat.course.nodes.gta.TaskList) GTACourseNode(org.olat.course.nodes.GTACourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) File(java.io.File) Test(org.junit.Test)

Example 73 with Task

use of org.olat.course.nodes.gta.Task in project openolat by klemens.

the class GTAManagerTest method getTaskRevisions.

@Test
public void getTaskRevisions() {
    // prepare
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-21");
    RepositoryEntry re = deployGTACourse();
    GTACourseNode node = getGTACourseNode(re);
    node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    dbInstance.commit();
    // create a task
    Task task = gtaManager.createAndPersistTask(null, tasks, TaskProcess.assignment, null, participant, node);
    dbInstance.commitAndCloseSession();
    // add the revision log
    TaskRevisionDate taskRevision = gtaManager.createAndPersistTaskRevisionDate(task, 2, TaskProcess.correction);
    Assert.assertNotNull(taskRevision);
    dbInstance.commitAndCloseSession();
    // load the revisions
    List<TaskRevisionDate> taskRevisions = gtaManager.getTaskRevisions(task);
    Assert.assertNotNull(taskRevisions);
    Assert.assertEquals(1, taskRevisions.size());
    TaskRevisionDate loadedTaskRevision = taskRevisions.get(0);
    Assert.assertNotNull(loadedTaskRevision.getKey());
    Assert.assertNotNull(loadedTaskRevision.getDate());
    Assert.assertEquals(task, loadedTaskRevision.getTask());
    Assert.assertEquals(2, loadedTaskRevision.getRevisionLoop());
    Assert.assertEquals(TaskProcess.correction, loadedTaskRevision.getTaskStatus());
}
Also used : Task(org.olat.course.nodes.gta.Task) TaskList(org.olat.course.nodes.gta.TaskList) GTACourseNode(org.olat.course.nodes.GTACourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) Test(org.junit.Test)

Example 74 with Task

use of org.olat.course.nodes.gta.Task in project openolat by klemens.

the class GTACourseNode method archiveNodeData.

public void archiveNodeData(ICourse course, BusinessGroup businessGroup, TaskList taskList, String dirName, ZipOutputStream exportStream) {
    ModuleConfiguration config = getModuleConfiguration();
    GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
    // for beautiful ordering
    int flow = 0;
    String groupDirName = dirName + "/" + StringHelper.transformDisplayNameToFileSystemName(businessGroup.getName()) + "_" + businessGroup.getKey();
    Task task = gtaManager.getTask(businessGroup, 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 = groupDirName + "/" + (++flow) + "_task/" + taskFile.getName();
            ZipUtil.addFileToZip(path, taskFile, exportStream);
        }
    }
    if (config.getBooleanSafe(GTASK_SUBMIT)) {
        File submitDirectory = gtaManager.getSubmitDirectory(course.getCourseEnvironment(), this, businessGroup);
        String submissionDirName = groupDirName + "/" + (++flow) + "_submissions";
        ZipUtil.addDirectoryToZip(submitDirectory.toPath(), submissionDirName, exportStream);
    }
    if (config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION)) {
        File correctionsDir = gtaManager.getCorrectionDirectory(course.getCourseEnvironment(), this, businessGroup);
        String correctionDirName = groupDirName + "/" + (++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, businessGroup);
            String revisionDirName = groupDirName + "/" + (++flow) + "_revisions_" + i;
            ZipUtil.addDirectoryToZip(revisionDirectory.toPath(), revisionDirName, exportStream);
            File correctionDirectory = gtaManager.getRevisedDocumentsCorrectionsDirectory(course.getCourseEnvironment(), this, i, businessGroup);
            String correctionDirName = groupDirName + "/" + (++flow) + "_corrections_" + i;
            ZipUtil.addDirectoryToZip(correctionDirectory.toPath(), correctionDirName, exportStream);
        }
    }
    // assessment documents for all participants of the group
    if (config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_INDIVIDUAL_ASSESSMENT_DOCS, false)) {
        List<Identity> assessedIdentities = CoreSpringFactory.getImpl(BusinessGroupService.class).getMembers(businessGroup, GroupRoles.participant.name());
        String assessmentDirName = groupDirName + "/" + (++flow) + "_assessment";
        for (Identity assessedIdentity : assessedIdentities) {
            List<File> assessmentDocuments = course.getCourseEnvironment().getAssessmentManager().getIndividualAssessmentDocuments(this, assessedIdentity);
            if (assessmentDocuments != null && !assessmentDocuments.isEmpty()) {
                String name = assessedIdentity.getUser().getLastName() + "_" + assessedIdentity.getUser().getFirstName() + "_" + assessedIdentity.getName();
                String userDirName = assessmentDirName + "/" + StringHelper.transformDisplayNameToFileSystemName(name);
                for (File document : assessmentDocuments) {
                    String path = userDirName + "/" + document.getName();
                    ZipUtil.addFileToZip(path, document, exportStream);
                }
            }
        }
    }
}
Also used : Task(org.olat.course.nodes.gta.Task) ModuleConfiguration(org.olat.modules.ModuleConfiguration) BusinessGroupService(org.olat.group.BusinessGroupService) GTAManager(org.olat.course.nodes.gta.GTAManager) Identity(org.olat.core.id.Identity) File(java.io.File)

Example 75 with Task

use of org.olat.course.nodes.gta.Task in project openolat by klemens.

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)

Aggregations

Task (org.olat.course.nodes.gta.Task)86 TaskList (org.olat.course.nodes.gta.TaskList)36 Identity (org.olat.core.id.Identity)34 RepositoryEntry (org.olat.repository.RepositoryEntry)34 File (java.io.File)32 Test (org.junit.Test)24 GTACourseNode (org.olat.course.nodes.GTACourseNode)24 AssignmentResponse (org.olat.course.nodes.gta.AssignmentResponse)20 BusinessGroup (org.olat.group.BusinessGroup)18 TaskProcess (org.olat.course.nodes.gta.TaskProcess)16 TaskRevisionDate (org.olat.course.nodes.gta.TaskRevisionDate)14 DueDate (org.olat.course.nodes.gta.model.DueDate)10 Date (java.util.Date)8 TaskDueDate (org.olat.course.nodes.gta.TaskDueDate)8 SubmitEvent (org.olat.course.nodes.gta.ui.events.SubmitEvent)8 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 TaskImpl (org.olat.course.nodes.gta.model.TaskImpl)6 ModuleConfiguration (org.olat.modules.ModuleConfiguration)6