use of org.olat.course.nodes.gta.TaskList in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method updateTaskName.
@Test
public void updateTaskName() {
// create an individual task
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-7");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-8");
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList taskList = gtaManager.createIfNotExists(re, node);
dbInstance.commit();
Assert.assertNotNull(taskList);
// select
gtaManager.selectTask(id1, taskList, node, new File("work_1.txt"));
gtaManager.selectTask(id2, taskList, node, new File("work_2.txt"));
dbInstance.commit();
// change a name
int rowUpdated = gtaManager.updateTaskName(taskList, "work_1.txt", "changed_work.txt");
dbInstance.commitAndCloseSession();
Assert.assertEquals(1, rowUpdated);
// check
Task assignedTaskToId1 = gtaManager.getTask(id1, taskList);
Assert.assertNotNull(assignedTaskToId1);
Assert.assertEquals("changed_work.txt", assignedTaskToId1.getTaskName());
List<Task> assignedTaskToId2 = gtaManager.getTasks(id2, re, node);
Assert.assertNotNull(assignedTaskToId2);
Assert.assertEquals(1, assignedTaskToId2.size());
Assert.assertEquals("work_2.txt", assignedTaskToId2.get(0).getTaskName());
}
use of org.olat.course.nodes.gta.TaskList in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method deleteAllTaskLists_parano.
/**
* Create 2 pseudo courses in a course, and delete the task of the first course
* and check that the task of second are always there.
*/
@Test
public void deleteAllTaskLists_parano() {
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-20");
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-21");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-22");
RepositoryEntry re1 = deployGTACourse();
repositoryEntryRelationDao.addRole(coach, re1, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(participant1, re1, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(participant2, re1, GroupRoles.participant.name());
// course 1
GTACourseNode node1 = getGTACourseNode(re1);
node1.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList tasks1 = gtaManager.createIfNotExists(re1, node1);
File taskFile = new File("bg.txt");
Assert.assertNotNull(tasks1);
dbInstance.commit();
RepositoryEntry re2 = deployGTACourse();
repositoryEntryRelationDao.addRole(coach, re2, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(participant1, re2, GroupRoles.participant.name());
// participant 2 course 2
GTACourseNode node2 = getGTACourseNode(re2);
node2.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList tasks2 = gtaManager.createIfNotExists(re2, node2);
Assert.assertNotNull(tasks2);
dbInstance.commit();
// participant 1 and 2 select course 1
AssignmentResponse response1_1 = gtaManager.selectTask(participant1, tasks1, node1, taskFile);
AssignmentResponse response1_2 = gtaManager.selectTask(participant2, tasks1, node1, taskFile);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(response1_1);
Assert.assertNotNull(response1_2);
// participant 2 select node 2
AssignmentResponse response2_2 = gtaManager.selectTask(participant2, tasks2, node2, taskFile);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(response2_2);
// check that there is tasks
List<Task> assignedTasks1_1 = gtaManager.getTasks(participant1, re1, node1);
Assert.assertNotNull(assignedTasks1_1);
Assert.assertEquals(1, assignedTasks1_1.size());
List<Task> assignedTasks1_2 = gtaManager.getTasks(participant2, re1, node1);
Assert.assertNotNull(assignedTasks1_2);
Assert.assertEquals(1, assignedTasks1_2.size());
List<Task> assignedTasks2_2 = gtaManager.getTasks(participant2, re2, node2);
Assert.assertNotNull(assignedTasks2_2);
Assert.assertEquals(1, assignedTasks2_2.size());
// delete
int numOfDeletedObjects = gtaManager.deleteAllTaskLists(re1);
Assert.assertEquals(3, numOfDeletedObjects);
dbInstance.commitAndCloseSession();
// check that there isn't any tasks in node 1
List<Task> deletedAssignedTasks1_1 = gtaManager.getTasks(participant1, re1, node1);
Assert.assertNotNull(deletedAssignedTasks1_1);
Assert.assertEquals(0, deletedAssignedTasks1_1.size());
List<Task> deletedAssignedTasks1_2 = gtaManager.getTasks(participant2, re1, node1);
Assert.assertNotNull(deletedAssignedTasks1_2);
Assert.assertEquals(0, deletedAssignedTasks1_2.size());
// but always in node 2
List<Task> notDeletedAssignedTasks2_2 = gtaManager.getTasks(participant2, re2, node2);
Assert.assertNotNull(notDeletedAssignedTasks2_2);
Assert.assertEquals(1, notDeletedAssignedTasks2_2.size());
}
use of org.olat.course.nodes.gta.TaskList 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;
}
}
}
}
use of org.olat.course.nodes.gta.TaskList in project OpenOLAT by OpenOLAT.
the class GTACoachedParticipantListController method doEditMultipleDueDates.
private void doEditMultipleDueDates(UserRequest ureq, List<CoachedIdentityRow> rows) {
if (editMultipleDueDatesCtrl != null)
return;
if (rows.isEmpty()) {
showWarning("error.atleast.task");
} else {
List<Task> tasks = new ArrayList<>(rows.size());
RepositoryEntry entry = coachCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
for (CoachedIdentityRow row : rows) {
if (row.getTask() == null) {
TaskProcess firstStep = gtaManager.firstStep(gtaNode);
TaskList taskList = gtaManager.getTaskList(entry, gtaNode);
tasks.add(gtaManager.createAndPersistTask(null, taskList, firstStep, null, securityManager.loadIdentityByKey(row.getIdentity().getIdentityKey()), gtaNode));
} else {
tasks.add(gtaManager.getTask(row.getTask()));
}
}
editMultipleDueDatesCtrl = new EditMultipleDueDatesController(ureq, getWindowControl(), tasks, gtaNode, entry, courseEnv);
listenTo(editMultipleDueDatesCtrl);
String title = translate("duedates.multiple.user");
cmc = new CloseableModalController(getWindowControl(), "close", editMultipleDueDatesCtrl.getInitialComponent(), true, title, true);
listenTo(cmc);
cmc.activate();
}
}
use of org.olat.course.nodes.gta.TaskList in project OpenOLAT by OpenOLAT.
the class GTACoachedParticipantListController method doEditDueDate.
private void doEditDueDate(UserRequest ureq, CoachedIdentityRow row) {
if (editDueDatesCtrl != null)
return;
Task task;
Identity assessedIdentity = securityManager.loadIdentityByKey(row.getIdentity().getIdentityKey());
RepositoryEntry entry = coachCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (row.getTask() == null) {
TaskProcess firstStep = gtaManager.firstStep(gtaNode);
TaskList taskList = gtaManager.getTaskList(entry, gtaNode);
task = gtaManager.createAndPersistTask(null, taskList, firstStep, null, assessedIdentity, gtaNode);
} else {
task = gtaManager.getTask(row.getTask());
}
editDueDatesCtrl = new EditDueDatesController(ureq, getWindowControl(), task, assessedIdentity, null, gtaNode, entry, courseEnv);
listenTo(editDueDatesCtrl);
String fullname = userManager.getUserDisplayName(assessedIdentity);
String title = translate("duedates.user", new String[] { fullname });
cmc = new CloseableModalController(getWindowControl(), "close", editDueDatesCtrl.getInitialComponent(), true, title, true);
listenTo(cmc);
cmc.activate();
}
Aggregations