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