Search in sources :

Example 66 with Task

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

the class EditMultipleDueDatesController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    ModuleConfiguration config = gtaNode.getModuleConfiguration();
    assignmentDueDateEl = uifactory.addDateChooser("assignment.duedate", null, formLayout);
    assignmentDueDateEl.setDateChooserTimeEnabled(true);
    DueDate standardAssignmentDueDate = gtaManager.getAssignmentDueDate(null, null, null, gtaNode, courseEntry, false);
    setDueDateExplanation(assignmentDueDateEl, standardAssignmentDueDate);
    assignmentDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT));
    submissionDueDateEl = uifactory.addDateChooser("submission.duedate", null, formLayout);
    submissionDueDateEl.setDateChooserTimeEnabled(true);
    DueDate standardSubmissionDueDate = gtaManager.getSubmissionDueDate(null, null, null, gtaNode, courseEntry, false);
    setDueDateExplanation(submissionDueDateEl, standardSubmissionDueDate);
    boolean submissionDeadline = config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT);
    submissionDueDateEl.setVisible(submissionDeadline);
    if (submissionDeadline) {
        for (Task task : tasks) {
            if (task.getTaskStatus().ordinal() > TaskProcess.submit.ordinal()) {
                StaticTextElement warningReopenEl = uifactory.addStaticTextElement("reopen", translate("warning.reopen"), formLayout);
                warningReopenEl.setElementCssClass("o_gta_reopen_warning");
                warningReopenEl.setLabel(null, null);
                break;
            }
        }
    }
    revisionDueDateEl = uifactory.addDateChooser("revisions.duedate", null, formLayout);
    revisionDueDateEl.setDateChooserTimeEnabled(true);
    revisionDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD));
    solutionDueDateEl = uifactory.addDateChooser("solution.duedate", null, formLayout);
    solutionDueDateEl.setDateChooserTimeEnabled(true);
    DueDate standardSolutionDueDate = gtaManager.getSolutionDueDate(null, null, null, gtaNode, courseEntry, false);
    setDueDateExplanation(solutionDueDateEl, standardSolutionDueDate);
    solutionDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION));
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
    uifactory.addFormSubmitButton("save", buttonsCont);
}
Also used : Task(org.olat.course.nodes.gta.Task) ModuleConfiguration(org.olat.modules.ModuleConfiguration) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) DueDate(org.olat.course.nodes.gta.model.DueDate) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate)

Example 67 with Task

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

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

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

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

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

the class GTAManagerTest method deleteAllTaskLists.

@Test
public void deleteAllTaskLists() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-9");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-10");
    dbInstance.commit();
    RepositoryEntry re = deployGTACourse();
    repositoryEntryRelationDao.addRole(coach, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(participant, re, GroupRoles.participant.name());
    GTACourseNode node = getGTACourseNode(re);
    node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    File taskFile = new File("bg.txt");
    Assert.assertNotNull(tasks);
    dbInstance.commit();
    // select
    AssignmentResponse response = gtaManager.selectTask(participant, 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());
    // delete
    int numOfDeletedObjects = gtaManager.deleteAllTaskLists(re);
    Assert.assertEquals(2, 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) 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 70 with Task

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

the class GTAManagerTest method selectTask_identity.

@Test
public void selectTask_identity() {
    // prepare
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-1");
    RepositoryEntry re = deployGTACourse();
    GTACourseNode node = getGTACourseNode(re);
    node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    File taskFile = new File("solo.txt");
    Assert.assertNotNull(tasks);
    dbInstance.commit();
    // select
    AssignmentResponse response = gtaManager.selectTask(participant, tasks, node, taskFile);
    dbInstance.commitAndCloseSession();
    // check
    Assert.assertNotNull(response);
    Assert.assertNotNull(response.getTask());
    Assert.assertEquals(AssignmentResponse.Status.ok, response.getStatus());
    Task task = response.getTask();
    Assert.assertNotNull(task.getKey());
    Assert.assertNull(task.getBusinessGroup());
    Assert.assertNotNull(task.getCreationDate());
    Assert.assertNotNull(task.getLastModified());
    Assert.assertEquals(tasks, task.getTaskList());
    Assert.assertEquals("solo.txt", task.getTaskName());
    Assert.assertEquals(participant, task.getIdentity());
}
Also used : Task(org.olat.course.nodes.gta.Task) 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)

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