use of org.olat.course.nodes.gta.GTARelativeToDates in project openolat by klemens.
the class GTAManagerImpl method getReferenceDate.
@Override
public DueDate getReferenceDate(int numOfDays, String relativeTo, TaskRef assignedTask, IdentityRef assessedIdentity, BusinessGroup assessedGroup, RepositoryEntry courseEntry) {
DueDate dueDate = null;
if (numOfDays >= 0 && StringHelper.containsNonWhitespace(relativeTo)) {
GTARelativeToDates rel = GTARelativeToDates.valueOf(relativeTo);
Date referenceDate = null;
String messageKey = null;
String messageArg = null;
switch(rel) {
case courseStart:
{
RepositoryEntryLifecycle lifecycle = getRepositoryEntryLifecycle(courseEntry);
if (lifecycle != null && lifecycle.getValidFrom() != null) {
referenceDate = lifecycle.getValidFrom();
}
break;
}
case courseLaunch:
{
if (assessedIdentity != null) {
referenceDate = userCourseInformationsManager.getInitialLaunchDate(courseEntry, assessedIdentity);
} else {
referenceDate = userCourseInformationsManager.getInitialParticipantLaunchDate(courseEntry, assessedGroup);
}
break;
}
case enrollment:
{
if (assessedIdentity != null) {
referenceDate = repositoryService.getEnrollmentDate(courseEntry, assessedIdentity);
} else {
referenceDate = getEnrollmentDate(assessedGroup);
}
break;
}
case assignment:
{
if (assignedTask != null) {
referenceDate = assignedTask.getAssignmentDate();
} else {
messageKey = "relative.to.assignment.message";
messageArg = Integer.toString(numOfDays);
}
break;
}
}
if (referenceDate != null) {
Calendar cal = Calendar.getInstance();
cal.setTime(referenceDate);
cal.add(Calendar.DATE, numOfDays);
dueDate = new DueDate(true, cal.getTime());
} else if (messageKey != null) {
dueDate = new DueDate(true, messageKey, messageArg);
}
}
return dueDate;
}
use of org.olat.course.nodes.gta.GTARelativeToDates in project OpenOLAT by OpenOLAT.
the class GTAManagerImpl method getReferenceDate.
@Override
public DueDate getReferenceDate(int numOfDays, String relativeTo, TaskRef assignedTask, IdentityRef assessedIdentity, BusinessGroup assessedGroup, RepositoryEntry courseEntry) {
DueDate dueDate = null;
if (numOfDays >= 0 && StringHelper.containsNonWhitespace(relativeTo)) {
GTARelativeToDates rel = GTARelativeToDates.valueOf(relativeTo);
Date referenceDate = null;
String messageKey = null;
String messageArg = null;
switch(rel) {
case courseStart:
{
RepositoryEntryLifecycle lifecycle = getRepositoryEntryLifecycle(courseEntry);
if (lifecycle != null && lifecycle.getValidFrom() != null) {
referenceDate = lifecycle.getValidFrom();
}
break;
}
case courseLaunch:
{
if (assessedIdentity != null) {
referenceDate = userCourseInformationsManager.getInitialLaunchDate(courseEntry, assessedIdentity);
} else {
referenceDate = userCourseInformationsManager.getInitialParticipantLaunchDate(courseEntry, assessedGroup);
}
break;
}
case enrollment:
{
if (assessedIdentity != null) {
referenceDate = repositoryService.getEnrollmentDate(courseEntry, assessedIdentity);
} else {
referenceDate = getEnrollmentDate(assessedGroup);
}
break;
}
case assignment:
{
if (assignedTask != null) {
referenceDate = assignedTask.getAssignmentDate();
} else {
messageKey = "relative.to.assignment.message";
messageArg = Integer.toString(numOfDays);
}
break;
}
}
if (referenceDate != null) {
Calendar cal = Calendar.getInstance();
cal.setTime(referenceDate);
cal.add(Calendar.DATE, numOfDays);
dueDate = new DueDate(true, cal.getTime());
} else if (messageKey != null) {
dueDate = new DueDate(true, messageKey, messageArg);
}
}
return dueDate;
}
Aggregations