Search in sources :

Example 71 with TaskList

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

the class GTAManagerImpl method syncWithTaskList.

private void syncWithTaskList(CourseEnvironment courseEnv, GTACourseNode cNode, TaskListSynched synched) {
    TaskList tasks = getTaskList(courseEnv.getCourseGroupManager().getCourseEntry(), cNode);
    if (tasks != null) {
        loadForUpdate(tasks);
        synched.sync();
        dbInstance.commit();
    } else {
        synched.sync();
    }
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList)

Example 72 with TaskList

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

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

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

the class GTAManagerImpl method selectTask.

private AssignmentResponse selectTask(Identity identity, BusinessGroup businessGroup, TaskList tasks, GTACourseNode cNode, File taskFile) {
    Task currentTask;
    if (businessGroup != null) {
        currentTask = getTask(businessGroup, tasks);
    } else {
        currentTask = getTask(identity, tasks);
    }
    AssignmentResponse response;
    if (currentTask == null) {
        String taskName = taskFile.getName();
        TaskList reloadedTasks = loadForUpdate(tasks);
        String sampling = cNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_SAMPLING);
        if (GTACourseNode.GTASK_SAMPLING_UNIQUE.equals(sampling) && isTaskAssigned(reloadedTasks, taskName)) {
            response = new AssignmentResponse(null, Status.alreadyAssigned);
        } else {
            TaskProcess nextStep = nextStep(TaskProcess.assignment, cNode);
            TaskImpl task = createTask(taskName, reloadedTasks, nextStep, businessGroup, identity, cNode);
            task.setAssignmentDate(new Date());
            dbInstance.getCurrentEntityManager().persist(task);
            syncAssessmentEntry(task, cNode, Role.user);
            response = new AssignmentResponse(task, Status.ok);
        }
        dbInstance.commit();
    } else {
        if (currentTask.getTaskStatus() == TaskProcess.assignment) {
            TaskProcess nextStep = nextStep(currentTask.getTaskStatus(), cNode);
            ((TaskImpl) currentTask).setTaskStatus(nextStep);
            if (taskFile != null) {
                ((TaskImpl) currentTask).setTaskName(taskFile.getName());
            }
        }
        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) 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 74 with TaskList

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

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

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

the class GTAManagerImpl method createIfNotExists.

@Override
public TaskList createIfNotExists(RepositoryEntry entry, GTACourseNode cNode) {
    TaskList tasks = getTaskList(entry, cNode);
    if (tasks == null) {
        TaskListImpl tasksImpl = new TaskListImpl();
        Date creationDate = new Date();
        tasksImpl.setCreationDate(creationDate);
        tasksImpl.setLastModified(creationDate);
        tasksImpl.setEntry(entry);
        tasksImpl.setCourseNodeIdent(cNode.getIdent());
        dbInstance.getCurrentEntityManager().persist(tasksImpl);
        tasks = tasksImpl;
    }
    return tasks;
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) TaskListImpl(org.olat.course.nodes.gta.model.TaskListImpl) 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)

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