Search in sources :

Example 26 with TaskList

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

the class GTAManagerImpl method toggleMark.

@Override
public boolean toggleMark(RepositoryEntry entry, GTACourseNode gtaNode, Identity marker, Identity participant) {
    if (entry == null || gtaNode == null || marker == null || participant == null)
        return false;
    TaskList taskList = getTaskList(entry, gtaNode);
    boolean isMarked = gtaMarkDao.isMarked(taskList, marker, participant);
    if (isMarked) {
        gtaMarkDao.deleteMark(taskList, marker, participant);
    } else {
        gtaMarkDao.createAndPersisitMark(taskList, marker, participant);
    }
    return !isMarked;
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList)

Example 27 with TaskList

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

the class GTAManagerImpl method deleteAllTaskLists.

@Override
public int deleteAllTaskLists(RepositoryEntryRef entry) {
    String q = "select tasks from gtatasklist tasks where tasks.entry.key=:entryKey";
    List<TaskList> taskLists = dbInstance.getCurrentEntityManager().createQuery(q, TaskList.class).setParameter("entryKey", entry.getKey()).getResultList();
    String deleteTasks = "delete from gtatask as task where task.taskList.key=:taskListKey";
    Query deleteTaskQuery = dbInstance.getCurrentEntityManager().createQuery(deleteTasks);
    int numOfDeletedObjects = 0;
    for (TaskList taskList : taskLists) {
        int numOfTasks = deleteTaskQuery.setParameter("taskListKey", taskList.getKey()).executeUpdate();
        numOfDeletedObjects += numOfTasks;
        int numOfMarks = gtaMarkDao.deleteMark(taskList);
        numOfDeletedObjects += numOfMarks;
    }
    String deleteTaskLists = "delete from gtatasklist as tasks where tasks.entry.key=:entryKey";
    numOfDeletedObjects += dbInstance.getCurrentEntityManager().createQuery(deleteTaskLists).setParameter("entryKey", entry.getKey()).executeUpdate();
    return numOfDeletedObjects;
}
Also used : Query(javax.persistence.Query) TaskList(org.olat.course.nodes.gta.TaskList)

Example 28 with TaskList

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

the class GTAManagerImpl method assignTaskAutomatically.

private AssignmentResponse assignTaskAutomatically(TaskList tasks, BusinessGroup businessGroup, Identity identity, CourseEnvironment courseEnv, GTACourseNode cNode) {
    Task currentTask;
    if (businessGroup != null) {
        currentTask = getTask(businessGroup, tasks);
    } else {
        currentTask = getTask(identity, tasks);
    }
    AssignmentResponse response;
    if (currentTask == null) {
        TaskList reloadedTasks = loadForUpdate(tasks);
        File tasksFolder = getTasksDirectory(courseEnv, cNode);
        String[] taskFiles = tasksFolder.list(SystemFilenameFilter.FILES_ONLY);
        List<String> assignedFilenames = getAssignedTasks(reloadedTasks);
        String taskName;
        if (GTACourseNode.GTASK_SAMPLING_UNIQUE.equals(cNode.getModuleConfiguration().get(GTACourseNode.GTASK_SAMPLING))) {
            taskName = nextUnique(taskFiles, assignedFilenames);
        } else {
            taskName = nextSlotRoundRobin(taskFiles, assignedFilenames);
        }
        if (taskName == null) {
            response = AssignmentResponse.NO_MORE_TASKS;
        } else {
            TaskProcess nextStep = nextStep(TaskProcess.assignment, cNode);
            TaskImpl task = createTask(taskName, reloadedTasks, nextStep, businessGroup, identity, cNode);
            task.setAssignmentDate(new Date());
            dbInstance.getCurrentEntityManager().persist(task);
            dbInstance.commit();
            syncAssessmentEntry((TaskImpl) currentTask, cNode, Role.user);
            response = new AssignmentResponse(task, Status.ok);
        }
    } else {
        if (currentTask.getTaskStatus() == TaskProcess.assignment) {
            ((TaskImpl) currentTask).setTaskStatus(TaskProcess.submit);
        }
        currentTask = dbInstance.getCurrentEntityManager().merge(currentTask);
        syncAssessmentEntry((TaskImpl) currentTask, cNode, Role.user);
        response = new AssignmentResponse(currentTask, Status.ok);
    }
    return response;
}
Also used : Task(org.olat.course.nodes.gta.Task) TaskProcess(org.olat.course.nodes.gta.TaskProcess) TaskImpl(org.olat.course.nodes.gta.model.TaskImpl) TaskList(org.olat.course.nodes.gta.TaskList) AssignmentResponse(org.olat.course.nodes.gta.AssignmentResponse) File(java.io.File) Date(java.util.Date) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 29 with TaskList

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

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 30 with TaskList

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

the class GTAIdentityMarkDAOTest method shouldCreateAndPersistMark.

@Test
public void shouldCreateAndPersistMark() {
    TaskList taskList = createTaskList();
    Identity marker = JunitTestHelper.createAndPersistIdentityAsAuthor("coach");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsUser("participant");
    dbInstance.commitAndCloseSession();
    sut.createAndPersisitMark(taskList, marker, participant);
    dbInstance.commitAndCloseSession();
    IdentityMark reloadedMark = sut.loadMarks(taskList, marker).get(0);
    assertThat(reloadedMark).isNotNull();
    assertThat(reloadedMark.getCreationDate()).isNotNull();
    assertThat(reloadedMark.getLastModified()).isNotNull();
    assertThat(reloadedMark.getTaskList()).isEqualTo(taskList);
    assertThat(reloadedMark.getMarker()).isEqualTo(marker);
    assertThat(reloadedMark.getParticipant()).isEqualTo(participant);
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) Identity(org.olat.core.id.Identity) IdentityMark(org.olat.course.nodes.gta.IdentityMark) Test(org.junit.Test)

Aggregations

TaskList (org.olat.course.nodes.gta.TaskList)102 Identity (org.olat.core.id.Identity)68 Test (org.junit.Test)64 RepositoryEntry (org.olat.repository.RepositoryEntry)60 GTACourseNode (org.olat.course.nodes.GTACourseNode)48 File (java.io.File)36 Task (org.olat.course.nodes.gta.Task)36 AssignmentResponse (org.olat.course.nodes.gta.AssignmentResponse)32 BusinessGroup (org.olat.group.BusinessGroup)20 ArrayList (java.util.ArrayList)16 Date (java.util.Date)12 List (java.util.List)12 TaskRevisionDate (org.olat.course.nodes.gta.TaskRevisionDate)12 TaskProcess (org.olat.course.nodes.gta.TaskProcess)10 ReminderRuleImpl (org.olat.modules.reminder.model.ReminderRuleImpl)10 IdentityMark (org.olat.course.nodes.gta.IdentityMark)8 ModuleConfiguration (org.olat.modules.ModuleConfiguration)8 Calendar (java.util.Calendar)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 GTAManager (org.olat.course.nodes.gta.GTAManager)6