Search in sources :

Example 11 with Task

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

the class GTAManagerTest method updateTaskName_paranoia.

@Test
public void updateTaskName_paranoia() {
    // 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);
    // create a reference individual task
    GTACourseNode nodeRef = new GTACourseNode();
    nodeRef.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    TaskList taskListRef = gtaManager.createIfNotExists(re, nodeRef);
    dbInstance.commit();
    Assert.assertNotNull(taskListRef);
    // select
    gtaManager.selectTask(id1, taskList, node, new File("work_1.txt"));
    gtaManager.selectTask(id1, taskListRef, nodeRef, 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());
    Task assignedTaskRefToId1 = gtaManager.getTask(id1, taskListRef);
    Assert.assertNotNull(assignedTaskRefToId1);
    Assert.assertEquals("work_1.txt", assignedTaskRefToId1.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 12 with Task

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

the class GTAManagerTest method deleteTaskList_withRevisionDates.

@Test
public void deleteTaskList_withRevisionDates() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-9");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-10");
    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);
    // check that there is tasks
    List<Task> assignedTasks = gtaManager.getTasks(participant, re, node);
    Assert.assertNotNull(assignedTasks);
    Assert.assertEquals(1, assignedTasks.size());
    // create a revision date
    gtaManager.createAndPersistTaskRevisionDate(assignedTasks.get(0), 2, TaskProcess.correction);
    dbInstance.commitAndCloseSession();
    // delete
    int numOfDeletedObjects = gtaManager.deleteTaskList(re, node);
    Assert.assertEquals(3, numOfDeletedObjects);
    dbInstance.commitAndCloseSession();
    // check that there isn't any tasks
    List<Task> deletedAssignedTasks = gtaManager.getTasks(participant, re, node);
    Assert.assertNotNull(deletedAssignedTasks);
    Assert.assertEquals(0, deletedAssignedTasks.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 13 with Task

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

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 14 with Task

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

the class GTAAbstractController method process.

protected final void process(UserRequest ureq) {
    Task task;
    if (businessGroupTask) {
        task = gtaManager.getTask(assessedGroup, taskList);
    } else {
        task = gtaManager.getTask(assessedIdentity, taskList);
    }
    if (withSubscription && subsContext != null) {
        contextualSubscriptionCtr = new ContextualSubscriptionController(ureq, getWindowControl(), subsContext, publisherData);
        listenTo(contextualSubscriptionCtr);
        mainVC.put("contextualSubscription", contextualSubscriptionCtr.getInitialComponent());
    }
    boolean assignment = config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT);
    mainVC.contextPut("assignmentEnabled", assignment);
    if (assignment) {
        task = stepAssignment(ureq, task);
    } else if (task == null) {
        TaskProcess firstStep = gtaManager.firstStep(gtaNode);
        task = gtaManager.createTask(null, taskList, firstStep, assessedGroup, assessedIdentity, gtaNode);
    }
    boolean submit = config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT);
    mainVC.contextPut("submitEnabled", submit);
    if (submit) {
        task = stepSubmit(ureq, task);
    } else if (task != null && task.getTaskStatus() == TaskProcess.submit) {
        task = gtaManager.nextStep(task, gtaNode, Role.auto);
    }
    boolean reviewAndCorrection = config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION);
    mainVC.contextPut("reviewAndCorrectionEnabled", reviewAndCorrection);
    if (reviewAndCorrection) {
        task = stepReviewAndCorrection(ureq, task);
    } else if (task != null && task.getTaskStatus() == TaskProcess.review) {
        task = gtaManager.nextStep(task, gtaNode, Role.auto);
    }
    boolean revision = config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD);
    mainVC.contextPut("revisionEnabled", reviewAndCorrection && revision);
    if (reviewAndCorrection && revision) {
        task = stepRevision(ureq, task);
    } else if (task != null && (task.getTaskStatus() == TaskProcess.revision || task.getTaskStatus() == TaskProcess.correction)) {
        task = gtaManager.nextStep(task, gtaNode, Role.auto);
    }
    boolean solution = config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION);
    mainVC.contextPut("solutionEnabled", solution);
    if (solution) {
        stepSolution(ureq, task);
    } else if (task != null && task.getTaskStatus() == TaskProcess.solution) {
        task = gtaManager.nextStep(task, gtaNode, Role.auto);
    }
    boolean grading = config.getBooleanSafe(GTACourseNode.GTASK_GRADING);
    mainVC.contextPut("gradingEnabled", grading);
    if (grading) {
        stepGrading(ureq, task);
    } else if (task != null && task.getTaskStatus() == TaskProcess.grading) {
        task = gtaManager.nextStep(task, gtaNode, Role.auto);
    }
    mainVC.contextPut("changelogconfig", courseModule.isDisplayChangeLog());
    resetTask(ureq, task);
    nodeLog();
    collapsedContents(task);
}
Also used : Task(org.olat.course.nodes.gta.Task) ContextualSubscriptionController(org.olat.core.commons.services.notifications.ui.ContextualSubscriptionController) TaskProcess(org.olat.course.nodes.gta.TaskProcess)

Example 15 with Task

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

the class GTAManagerImpl method resetTask.

@Override
public Task resetTask(Task task, GTACourseNode cNode, CourseEnvironment courseEnv) {
    TaskImpl taskImpl = (TaskImpl) task;
    taskImpl.setTaskName(null);
    taskImpl.setAllowResetDate(null);
    Task updatedTask = updateTask(task, TaskProcess.assignment, cNode, Role.user);
    File submissionDir = null;
    if (updatedTask.getBusinessGroup() != null) {
        submissionDir = getSubmitDirectory(courseEnv, cNode, updatedTask.getBusinessGroup());
    } else if (updatedTask.getIdentity() != null) {
        submissionDir = getSubmitDirectory(courseEnv, cNode, updatedTask.getIdentity());
    }
    if (submissionDir != null) {
        FileUtils.deleteDirsAndFiles(submissionDir, true, false);
    }
    return updatedTask;
}
Also used : Task(org.olat.course.nodes.gta.Task) TaskImpl(org.olat.course.nodes.gta.model.TaskImpl) 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