use of org.olat.course.nodes.gta.TaskRevisionDate in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method createTaskRevisionDate.
@Test
public void createTaskRevisionDate() {
// prepare
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-20");
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 task
Task task = gtaManager.createAndPersistTask(null, tasks, TaskProcess.assignment, null, participant, node);
dbInstance.commitAndCloseSession();
// create the revision log
TaskRevisionDate taskRevision = gtaManager.createAndPersistTaskRevisionDate(task, 2, TaskProcess.correction);
Assert.assertNotNull(taskRevision);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(taskRevision.getKey());
Assert.assertNotNull(taskRevision.getDate());
Assert.assertEquals(task, taskRevision.getTask());
Assert.assertEquals(2, taskRevision.getRevisionLoop());
Assert.assertEquals(TaskProcess.correction, taskRevision.getTaskStatus());
}
use of org.olat.course.nodes.gta.TaskRevisionDate in project OpenOLAT by OpenOLAT.
the class GTAManagerImpl method createAndPersistTaskRevisionDate.
public TaskRevisionDate createAndPersistTaskRevisionDate(Task task, int revisionLoop, TaskProcess status) {
TaskRevisionDateImpl rev = new TaskRevisionDateImpl();
rev.setCreationDate(new Date());
rev.setDate(rev.getCreationDate());
rev.setRevisionLoop(revisionLoop);
rev.setStatus(status.name());
rev.setTask(task);
dbInstance.getCurrentEntityManager().persist(rev);
return rev;
}
use of org.olat.course.nodes.gta.TaskRevisionDate in project openolat by klemens.
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.TaskRevisionDate in project openolat by klemens.
the class GTAManagerImpl method createAndPersistTaskRevisionDate.
public TaskRevisionDate createAndPersistTaskRevisionDate(Task task, int revisionLoop, TaskProcess status) {
TaskRevisionDateImpl rev = new TaskRevisionDateImpl();
rev.setCreationDate(new Date());
rev.setDate(rev.getCreationDate());
rev.setRevisionLoop(revisionLoop);
rev.setStatus(status.name());
rev.setTask(task);
dbInstance.getCurrentEntityManager().persist(rev);
return rev;
}
use of org.olat.course.nodes.gta.TaskRevisionDate in project openolat by klemens.
the class GTANotifications method createReviewAndRevisionsItems.
private void createReviewAndRevisionsItems(Task task, Identity assessedIdentity, BusinessGroup group, boolean coach) {
if (task == null)
return;
String name;
if (group != null) {
name = group.getName();
} else {
name = userManager.getUserDisplayName(assessedIdentity);
}
boolean sendNotificationDueDate = true;
List<TaskRevisionDate> taskRevisions = gtaManager.getTaskRevisions(task);
if (!coach && gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION)) {
// check task revision 1
if (task != null && notInStep(task, TaskProcess.assignment, TaskProcess.submit, TaskProcess.review) && checkRevisionLoop(TaskProcess.revision, 1, taskRevisions)) {
File correctionDirectory;
VFSContainer correctionContainer;
if (group != null) {
correctionDirectory = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, group);
correctionContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, group);
} else {
correctionDirectory = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, assessedIdentity);
correctionContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedIdentity);
}
Date correctionDate = getRevisionLoopDate(TaskProcess.revision, 1, taskRevisions);
if (sendNotificationDueDate) {
if (task.getRevisionsDueDate() != null) {
String[] params = new String[] { getTaskName(task), displayName, formatter.formatDateAndTime(task.getRevisionsDueDate()) };
if (group != null) {
appendSubscriptionItem("notifications.correction.duedate", params, group, correctionDate, coach);
} else {
appendSubscriptionItem("notifications.correction.duedate", params, assessedIdentity, correctionDate, coach);
}
} else {
String[] params = new String[] { getTaskName(task), displayName };
if (group != null) {
appendSubscriptionItem("notifications.correction", params, group, correctionDate, coach);
} else {
appendSubscriptionItem("notifications.correction", params, assessedIdentity, correctionDate, coach);
}
}
sendNotificationDueDate = false;
}
File[] corrections = correctionDirectory.listFiles(SystemFileFilter.FILES_ONLY);
for (File correction : corrections) {
String author = getAuthor(correction, correctionContainer);
String[] params = new String[] { getTaskName(task), displayName, correction.getName(), author };
if (group != null) {
appendSubscriptionItemForFile("notifications.correction.doc", params, group, "[correction:0]", correction, correctionDate, coach);
} else {
appendSubscriptionItemForFile("notifications.correction.doc", params, assessedIdentity, "[correction:0]", correction, correctionDate, coach);
}
}
}
}
if (gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
task = checkRevisionStep(assessedIdentity, null, task);
if (task != null && notInStep(task, TaskProcess.assignment, TaskProcess.submit, TaskProcess.review)) {
int currentIteration = task.getRevisionLoop();
for (int i = 1; i <= currentIteration; i++) {
if (coach) {
// revision of the students
if (checkRevisionLoop(TaskProcess.correction, i, taskRevisions)) {
File revisionDirectory;
VFSContainer revisionContainer;
if (group != null) {
revisionDirectory = gtaManager.getRevisedDocumentsDirectory(courseEnv, gtaNode, i, group);
revisionContainer = gtaManager.getRevisedDocumentsContainer(courseEnv, gtaNode, i, group);
} else {
revisionDirectory = gtaManager.getRevisedDocumentsDirectory(courseEnv, gtaNode, i, assessedIdentity);
revisionContainer = gtaManager.getRevisedDocumentsContainer(courseEnv, gtaNode, i, assessedIdentity);
}
Date revisionDate = getRevisionLoopDate(TaskProcess.correction, i, taskRevisions);
File[] revisions = revisionDirectory.listFiles(SystemFileFilter.FILES_ONLY);
if (revisions.length == 0) {
String[] params = new String[] { getTaskName(task), displayName, name };
if (group != null) {
appendSubscriptionItem("notifications.revision.group", params, group, revisionDate, coach);
} else {
appendSubscriptionItem("notifications.revision.individual", params, assessedIdentity, revisionDate, coach);
}
} else {
for (File revision : revisions) {
String author = getAuthor(revision, revisionContainer);
String[] params = new String[] { getTaskName(task), displayName, revision.getName(), name, author };
if (group != null) {
appendSubscriptionItemForFile("notifications.revision.group.doc", params, group, "[revision:" + i + "]", revision, revisionDate, coach);
} else {
appendSubscriptionItemForFile("notifications.revision.individual.doc", params, assessedIdentity, "[revision:" + i + "]", revision, revisionDate, coach);
}
}
}
}
} else if (checkRevisionLoop(TaskProcess.revision, i, taskRevisions)) {
// corrections of the coach
File correctionDirectory;
VFSContainer correctionContainer;
if (group != null) {
correctionDirectory = gtaManager.getRevisedDocumentsCorrectionsDirectory(courseEnv, gtaNode, i, group);
correctionContainer = gtaManager.getRevisedDocumentsCorrectionsContainer(courseEnv, gtaNode, i, group);
} else {
correctionDirectory = gtaManager.getRevisedDocumentsCorrectionsDirectory(courseEnv, gtaNode, i, assessedIdentity);
correctionContainer = gtaManager.getRevisedDocumentsCorrectionsContainer(courseEnv, gtaNode, i, assessedIdentity);
}
Date correctionDate = getRevisionLoopDate(TaskProcess.revision, i, taskRevisions);
if (sendNotificationDueDate) {
if (task.getRevisionsDueDate() != null) {
String[] params = new String[] { getTaskName(task), displayName, formatter.formatDateAndTime(task.getRevisionsDueDate()) };
if (group != null) {
appendSubscriptionItem("notifications.correction.duedate", params, group, correctionDate, coach);
} else {
appendSubscriptionItem("notifications.correction.duedate", params, assessedIdentity, correctionDate, coach);
}
} else {
String[] params = new String[] { getTaskName(task), displayName };
if (group != null) {
appendSubscriptionItem("notifications.correction", params, group, correctionDate, coach);
} else {
appendSubscriptionItem("notifications.correction", params, assessedIdentity, correctionDate, coach);
}
}
sendNotificationDueDate = false;
}
File[] corrections = correctionDirectory.listFiles(SystemFileFilter.FILES_ONLY);
for (File correction : corrections) {
String author = getAuthor(correction, correctionContainer);
String[] params = new String[] { getTaskName(task), displayName, correction.getName(), author };
if (group != null) {
appendSubscriptionItemForFile("notifications.correction.doc", params, group, "[correction:" + i + "]", correction, correctionDate, coach);
} else {
appendSubscriptionItemForFile("notifications.correction.doc", params, assessedIdentity, "[correction:" + i + "]", correction, correctionDate, coach);
}
}
}
}
}
}
}
Aggregations