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();
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations