use of org.olat.course.nodes.gta.Task in project OpenOLAT by OpenOLAT.
the class ConvertToGTACourseNode method convertAssessmentDatas.
private void convertAssessmentDatas(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, ICourse course) {
CourseEnvironment courseEnv = course.getCourseEnvironment();
CoursePropertyManager propertyMgr = courseEnv.getCoursePropertyManager();
Map<Long, AssessmentEntry> datas = new HashMap<>();
List<AssessmentEntry> properties = courseEnv.getAssessmentManager().getAssessmentEntries(sourceNode);
for (AssessmentEntry property : properties) {
Identity identity = property.getIdentity();
datas.put(identity.getKey(), property);
}
properties = null;
DBFactory.getInstance().getCurrentEntityManager().clear();
AssessmentManager assessmentMgr = courseEnv.getAssessmentManager();
for (AssessmentEntry assessmentData : datas.values()) {
Identity assessedIdentity = securityManager.loadIdentityByKey(assessmentData.getIdentity().getKey());
if (assessmentData.getPassed() != null || assessmentData.getScore() != null) {
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
Float score = assessmentData.getScore() == null ? null : assessmentData.getScore().floatValue();
ScoreEvaluation scoreEval = new ScoreEvaluation(score, assessmentData.getPassed());
assessmentMgr.saveScoreEvaluation(gtaNode, null, assessedIdentity, scoreEval, userCourseEnv, false, Role.auto);
// set graded
Task task = gtaManager.getTask(assessedIdentity, taskList);
if (task == null) {
gtaManager.createTask(null, taskList, TaskProcess.graded, null, assessedIdentity, gtaNode);
} else {
gtaManager.updateTask(task, TaskProcess.graded, gtaNode, Role.auto);
}
}
if (assessmentData.getAttempts() != null) {
assessmentMgr.saveNodeAttempts(gtaNode, null, assessedIdentity, assessmentData.getAttempts().intValue(), Role.auto);
}
if (StringHelper.containsNonWhitespace(assessmentData.getCoachComment())) {
assessmentMgr.saveNodeCoachComment(gtaNode, assessedIdentity, assessmentData.getCoachComment());
}
if (StringHelper.containsNonWhitespace(assessmentData.getComment())) {
assessmentMgr.saveNodeComment(gtaNode, null, assessedIdentity, assessmentData.getComment());
}
}
DBFactory.getInstance().getCurrentEntityManager().clear();
// copy log entries
List<Property> logEntries = propertyMgr.listCourseNodeProperties(sourceNode, null, null, UserNodeAuditManager.LOG_IDENTIFYER);
for (Property logEntry : logEntries) {
String logText = logEntry.getTextValue();
Identity identity = securityManager.loadIdentityByKey(logEntry.getIdentity().getKey());
Property targetProp = propertyMgr.findCourseNodeProperty(gtaNode, identity, null, UserNodeAuditManager.LOG_IDENTIFYER);
if (targetProp == null) {
targetProp = propertyMgr.createCourseNodePropertyInstance(gtaNode, identity, null, UserNodeAuditManager.LOG_IDENTIFYER, null, null, null, logText);
} else {
targetProp.setTextValue(logText);
}
propertyMgr.saveProperty(targetProp);
}
}
use of org.olat.course.nodes.gta.Task in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method deleteTaskList_parano.
/**
* Create 2 pseudo nodes in a course, and delete the task of the first node
* and check that the task of second are always there.
*/
@Test
public void deleteTaskList_parano() {
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-9");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-10");
BusinessGroup businessGroup = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRole(participant, businessGroup, GroupRole.participant.name());
dbInstance.commit();
RepositoryEntry re = deployGTACourse();
// node 1
GTACourseNode node1 = getGTACourseNode(re);
node1.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
TaskList tasks1 = gtaManager.createIfNotExists(re, node1);
File taskFile = new File("bg.txt");
Assert.assertNotNull(tasks1);
dbInstance.commit();
// node 2
GTACourseNode node2 = new GTACourseNode();
node2.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
TaskList tasks2 = gtaManager.createIfNotExists(re, node2);
Assert.assertNotNull(tasks2);
dbInstance.commit();
// select node 1
AssignmentResponse response1 = gtaManager.selectTask(businessGroup, tasks1, node1, taskFile);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(response1);
// select node 2
AssignmentResponse response2 = gtaManager.selectTask(businessGroup, tasks2, node2, taskFile);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(response2);
// check that there is tasks
List<Task> assignedTasks1 = gtaManager.getTasks(participant, re, node1);
Assert.assertNotNull(assignedTasks1);
Assert.assertEquals(1, assignedTasks1.size());
// create a revision date
gtaManager.createAndPersistTaskRevisionDate(assignedTasks1.get(0), 2, TaskProcess.correction);
List<Task> assignedTasks2 = gtaManager.getTasks(participant, re, node2);
Assert.assertNotNull(assignedTasks2);
Assert.assertEquals(1, assignedTasks2.size());
// create a revision date
gtaManager.createAndPersistTaskRevisionDate(assignedTasks2.get(0), 2, TaskProcess.correction);
dbInstance.commitAndCloseSession();
// delete
int numOfDeletedObjects = gtaManager.deleteTaskList(re, node1);
Assert.assertEquals(3, numOfDeletedObjects);
dbInstance.commitAndCloseSession();
// check that there isn't any tasks in node 1
List<Task> deletedAssignedTasks = gtaManager.getTasks(participant, re, node1);
Assert.assertNotNull(deletedAssignedTasks);
Assert.assertEquals(0, deletedAssignedTasks.size());
List<TaskRevisionDate> revisionsTask1 = gtaManager.getTaskRevisions(assignedTasks1.get(0));
Assert.assertNotNull(revisionsTask1);
Assert.assertEquals(0, revisionsTask1.size());
// but always in node 2
List<Task> notDeletedAssignedTasks2 = gtaManager.getTasks(participant, re, node2);
Assert.assertNotNull(notDeletedAssignedTasks2);
Assert.assertEquals(1, notDeletedAssignedTasks2.size());
List<TaskRevisionDate> revisionsTask2 = gtaManager.getTaskRevisions(notDeletedAssignedTasks2.get(0));
Assert.assertNotNull(revisionsTask2);
Assert.assertEquals(1, revisionsTask2.size());
}
use of org.olat.course.nodes.gta.Task in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method deleteAllTaskLists.
@Test
public void deleteAllTaskLists() {
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-9");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-10");
dbInstance.commit();
RepositoryEntry re = deployGTACourse();
repositoryEntryRelationDao.addRole(coach, re, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(participant, re, GroupRoles.participant.name());
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
File taskFile = new File("bg.txt");
Assert.assertNotNull(tasks);
dbInstance.commit();
// select
AssignmentResponse response = gtaManager.selectTask(participant, tasks, node, taskFile);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(response);
// check that there is tasks
List<Task> assignedTasks = gtaManager.getTasks(participant, re, node);
Assert.assertNotNull(assignedTasks);
Assert.assertEquals(1, assignedTasks.size());
// delete
int numOfDeletedObjects = gtaManager.deleteAllTaskLists(re);
Assert.assertEquals(2, numOfDeletedObjects);
dbInstance.commitAndCloseSession();
// check that there isn't any tasks
List<Task> deletedAssignedTasks = gtaManager.getTasks(participant, re, node);
Assert.assertNotNull(deletedAssignedTasks);
Assert.assertEquals(0, deletedAssignedTasks.size());
}
use of org.olat.course.nodes.gta.Task in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method getTaskRevisions.
@Test
public void getTaskRevisions() {
// prepare
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-21");
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
dbInstance.commit();
// create a task
Task task = gtaManager.createAndPersistTask(null, tasks, TaskProcess.assignment, null, participant, node);
dbInstance.commitAndCloseSession();
// add the revision log
TaskRevisionDate taskRevision = gtaManager.createAndPersistTaskRevisionDate(task, 2, TaskProcess.correction);
Assert.assertNotNull(taskRevision);
dbInstance.commitAndCloseSession();
// load the revisions
List<TaskRevisionDate> taskRevisions = gtaManager.getTaskRevisions(task);
Assert.assertNotNull(taskRevisions);
Assert.assertEquals(1, taskRevisions.size());
TaskRevisionDate loadedTaskRevision = taskRevisions.get(0);
Assert.assertNotNull(loadedTaskRevision.getKey());
Assert.assertNotNull(loadedTaskRevision.getDate());
Assert.assertEquals(task, loadedTaskRevision.getTask());
Assert.assertEquals(2, loadedTaskRevision.getRevisionLoop());
Assert.assertEquals(TaskProcess.correction, loadedTaskRevision.getTaskStatus());
}
use of org.olat.course.nodes.gta.Task in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method deleteTaskList.
@Test
public void deleteTaskList() {
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-9");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-10");
BusinessGroup businessGroup = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRole(participant, businessGroup, GroupRole.participant.name());
dbInstance.commit();
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
File taskFile = new File("bg.txt");
Assert.assertNotNull(tasks);
dbInstance.commit();
// select
AssignmentResponse response = gtaManager.selectTask(businessGroup, tasks, node, taskFile);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(response);
// check that there is tasks
List<Task> assignedTasks = gtaManager.getTasks(participant, re, node);
Assert.assertNotNull(assignedTasks);
Assert.assertEquals(1, assignedTasks.size());
// delete
int numOfDeletedObjects = gtaManager.deleteTaskList(re, node);
Assert.assertEquals(2, numOfDeletedObjects);
dbInstance.commitAndCloseSession();
// check that there isn't any tasks
List<Task> deletedAssignedTasks = gtaManager.getTasks(participant, re, node);
Assert.assertNotNull(deletedAssignedTasks);
Assert.assertEquals(0, deletedAssignedTasks.size());
}
Aggregations