Search in sources :

Example 51 with Task

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

the class AbstractDueDateTaskRuleSPI method getIndividualsToRemind.

protected List<Identity> getIndividualsToRemind(TaskList taskList, RepositoryEntry entry, GTACourseNode gtaNode) {
    List<Task> tasks = gtaManager.getTasks(taskList, gtaNode);
    Set<Identity> doneTasks = new HashSet<Identity>();
    for (Task task : tasks) {
        if (task.getIdentity() != null) {
            doneTasks.add(task.getIdentity());
        }
    }
    List<Identity> identities = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.both, GroupRoles.participant.name());
    for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
        if (doneTasks.contains(identityIt.next())) {
            identityIt.remove();
        }
    }
    return identities;
}
Also used : Task(org.olat.course.nodes.gta.Task) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 52 with Task

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

the class GTANotifications method createIndividualSubscriptionInfo.

private void createIndividualSubscriptionInfo(Identity subscriberIdentity) {
    RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
    List<String> roles = repositoryService.getRoles(subscriberIdentity, entry);
    boolean owner = roles.contains(GroupRoles.owner.name());
    boolean coach = roles.contains(GroupRoles.coach.name());
    if (owner || coach) {
        Set<Identity> duplicateKiller = new HashSet<>();
        List<Identity> assessableIdentities = new ArrayList<>();
        List<Identity> participants;
        List<BusinessGroup> coachedGroups = null;
        if (owner) {
            participants = businessGroupService.getMembersOf(entry, false, true);
        } else {
            SearchBusinessGroupParams params = new SearchBusinessGroupParams(subscriberIdentity, true, false);
            coachedGroups = businessGroupService.findBusinessGroups(params, entry, 0, -1);
            participants = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
        }
        for (Identity participant : participants) {
            if (!duplicateKiller.contains(participant)) {
                assessableIdentities.add(participant);
                duplicateKiller.add(participant);
            }
        }
        boolean repoTutor = owner || (coachedGroups.isEmpty() && repositoryService.hasRole(subscriberIdentity, entry, GroupRoles.coach.name()));
        if (repoTutor) {
            List<Identity> courseParticipants = repositoryService.getMembers(entry, GroupRoles.participant.name());
            for (Identity participant : courseParticipants) {
                if (!duplicateKiller.contains(participant)) {
                    assessableIdentities.add(participant);
                    duplicateKiller.add(participant);
                }
            }
        }
        for (Identity assessedIdentity : assessableIdentities) {
            createIndividualSubscriptionInfo(assessedIdentity, true);
        }
        createCoachSolutionItems();
    } else {
        Task task = gtaManager.getTask(subscriberIdentity, taskList);
        if (task != null) {
            header = translator.translate("notifications.individual.header.task", new String[] { getTaskName(task), displayName });
        }
    }
    if (roles.contains(GroupRoles.participant.name())) {
        createIndividualSubscriptionInfo(subscriberIdentity, false);
        Task task = gtaManager.getTask(subscriberIdentity, taskList);
        if (isSolutionVisible(subscriberIdentity, null, task)) {
            createParticipantSolutionItems(task, subscriberIdentity, null);
        }
        if (task != null && task.getTaskStatus() == TaskProcess.graded) {
            createAssessmentItem(task, subscriberIdentity, false);
        }
    }
}
Also used : Task(org.olat.course.nodes.gta.Task) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 53 with Task

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

the class GTANotifications method createBusinessGroupsSubscriptionInfo.

private void createBusinessGroupsSubscriptionInfo(Identity subscriberIdentity) {
    RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
    Membership membership = gtaManager.getMembership(subscriberIdentity, entry, gtaNode);
    boolean owner = repositoryService.hasRole(subscriberIdentity, entry, GroupRoles.owner.name());
    if (owner) {
        List<BusinessGroup> groups = gtaManager.getBusinessGroups(gtaNode);
        for (BusinessGroup group : groups) {
            createBusinessGroupsSubscriptionItems(group, true);
        }
        createCoachSolutionItems();
    } else if (membership.isCoach()) {
        List<BusinessGroup> groups = gtaManager.getCoachedBusinessGroups(subscriberIdentity, gtaNode);
        for (BusinessGroup group : groups) {
            createBusinessGroupsSubscriptionItems(group, true);
        }
        createCoachSolutionItems();
    }
    if (membership.isParticipant()) {
        List<BusinessGroup> groups = gtaManager.getParticipatingBusinessGroups(subscriberIdentity, gtaNode);
        if (groups.size() == 1 && !owner && !membership.isCoach()) {
            Task task = gtaManager.getTask(groups.get(0), taskList);
            if (task != null) {
                header = translator.translate("notifications.group.header.task", new String[] { getTaskName(task), displayName });
            }
        }
        for (BusinessGroup group : groups) {
            createBusinessGroupsSubscriptionItems(group, false);
            Task task = gtaManager.getTask(group, taskList);
            if (createParticipantSolutionItems(task, null, group)) {
                break;
            }
        }
    }
}
Also used : Task(org.olat.course.nodes.gta.Task) BusinessGroup(org.olat.group.BusinessGroup) Membership(org.olat.course.nodes.gta.model.Membership) List(java.util.List) ArrayList(java.util.ArrayList) TaskList(org.olat.course.nodes.gta.TaskList) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 54 with Task

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

the class GTANotifications method createIndividualSubscriptionInfo.

private void createIndividualSubscriptionInfo(Identity assessedIdentity, boolean coach) {
    Task task = gtaManager.getTask(assessedIdentity, taskList);
    if (coach && gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_SUBMIT)) {
        task = checkSubmitStep(assessedIdentity, null, task);
        // show after the step submit, if submission date after compare date
        if (task != null && notInStep(task, TaskProcess.assignment, TaskProcess.submit) && task.getSubmissionDate() != null && task.getSubmissionDate().after(compareDate)) {
            Date submissionDate = task.getSubmissionDate();
            String fullName = userManager.getUserDisplayName(assessedIdentity);
            File submitDirectory = gtaManager.getSubmitDirectory(courseEnv, gtaNode, assessedIdentity);
            File[] submissions = submitDirectory.listFiles(SystemFileFilter.FILES_ONLY);
            if (submissions.length == 0) {
                String[] params = new String[] { // {0}
                getTaskName(task), // {1}
                displayName, // {2}
                fullName };
                appendSubscriptionItem("notifications.submission.individual", params, assessedIdentity, submissionDate, coach);
            } else {
                for (File submission : submissions) {
                    String[] params = new String[] { // {0}
                    getTaskName(task), // {1}
                    displayName, // {2}
                    submission.getName(), // {3}
                    fullName };
                    appendSubscriptionItemForFile("notifications.submission.individual.doc", params, assessedIdentity, "[submit:0]", submission, submissionDate, coach);
                }
            }
        }
    }
    createReviewAndRevisionsItems(task, assessedIdentity, null, coach);
    createAcceptedItem(task, assessedIdentity, null, coach);
}
Also used : Task(org.olat.course.nodes.gta.Task) File(java.io.File) Date(java.util.Date) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 55 with Task

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

the class GTANotifications method createBusinessGroupsSubscriptionItems.

private void createBusinessGroupsSubscriptionItems(BusinessGroup group, boolean coach) {
    Task task = gtaManager.getTask(group, taskList);
    if (gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_SUBMIT)) {
        task = checkSubmitStep(null, group, task);
        if (task != null && notInStep(task, TaskProcess.assignment, TaskProcess.submit) && (task.getSubmissionDate() == null || task.getSubmissionDate().after(compareDate))) {
            File submitDirectory = gtaManager.getSubmitDirectory(courseEnv, gtaNode, group);
            VFSContainer submitContainer = gtaManager.getSubmitContainer(courseEnv, gtaNode, group);
            Date submissionDate = task.getSubmissionDate();
            File[] submisssions = submitDirectory.listFiles(SystemFileFilter.FILES_ONLY);
            if (submisssions.length == 0) {
                String[] params = new String[] { getTaskName(task), displayName, group.getName() };
                appendSubscriptionItem("notifications.submission.group", params, group, submissionDate, coach);
            } else {
                for (File submission : submisssions) {
                    String author = getAuthor(submission, submitContainer);
                    String[] params = new String[] { // {0}
                    getTaskName(task), // {1}
                    displayName, // {2}
                    submission.getName(), // {3}
                    author, // {3}
                    group.getName() };
                    appendSubscriptionItemForFile("notifications.submission.group.doc", params, group, "[submit:0]", submission, submissionDate, coach);
                }
            }
        }
    }
    createReviewAndRevisionsItems(task, null, group, coach);
    createAcceptedItem(task, null, group, coach);
}
Also used : Task(org.olat.course.nodes.gta.Task) VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File) Date(java.util.Date) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

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