use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
the class GTAManagerImpl method getAssignmentDueDate.
@Override
public DueDate getAssignmentDueDate(TaskRef assignedTask, IdentityRef assessedIdentity, BusinessGroup assessedGroup, GTACourseNode cNode, RepositoryEntry courseEntry, boolean withIndividualDueDate) {
DueDate assignmentDueDate = null;
Date dueDate = cNode.getModuleConfiguration().getDateValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE);
boolean relativeDate = cNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_RELATIVE_DATES);
if ((relativeDate || dueDate != null) && withIndividualDueDate && assignedTask != null && assignedTask.getAssignmentDueDate() != null) {
assignmentDueDate = new DueDate(false, assignedTask.getAssignmentDueDate());
} else if (relativeDate) {
int numOfDays = cNode.getModuleConfiguration().getIntegerSafe(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE_RELATIVE, -1);
String relativeTo = cNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE_RELATIVE_TO);
if (numOfDays >= 0 && StringHelper.containsNonWhitespace(relativeTo)) {
assignmentDueDate = getReferenceDate(numOfDays, relativeTo, assignedTask, assessedIdentity, assessedGroup, courseEntry);
}
} else if (dueDate != null) {
assignmentDueDate = new DueDate(false, dueDate);
}
return assignmentDueDate;
}
use of org.olat.course.nodes.gta.model.DueDate 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.model.DueDate in project openolat by klemens.
the class GTAManagerImpl method getSubmissionDueDate.
@Override
public DueDate getSubmissionDueDate(TaskRef assignedTask, IdentityRef assessedIdentity, BusinessGroup assessedGroup, GTACourseNode cNode, RepositoryEntry courseEntry, boolean withIndividualDueDate) {
DueDate submissionDueDate = null;
Date dueDate = cNode.getModuleConfiguration().getDateValue(GTACourseNode.GTASK_SUBMIT_DEADLINE);
boolean relativeDate = cNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_RELATIVE_DATES);
if ((relativeDate || dueDate != null) && withIndividualDueDate && assignedTask != null && assignedTask.getSubmissionDueDate() != null) {
submissionDueDate = new DueDate(false, assignedTask.getSubmissionDueDate());
} else if (relativeDate) {
int numOfDays = cNode.getModuleConfiguration().getIntegerSafe(GTACourseNode.GTASK_SUBMIT_DEADLINE_RELATIVE, -1);
String relativeTo = cNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_SUBMIT_DEADLINE_RELATIVE_TO);
if (numOfDays >= 0 && StringHelper.containsNonWhitespace(relativeTo)) {
submissionDueDate = getReferenceDate(numOfDays, relativeTo, assignedTask, assessedIdentity, assessedGroup, courseEntry);
}
} else if (dueDate != null) {
submissionDueDate = new DueDate(false, dueDate);
}
return submissionDueDate;
}
use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
the class GTANotifications method isSolutionVisible.
private boolean isSolutionVisible(Identity assessedIdentity, BusinessGroup assessedGroup, Task task) {
if (task != null) {
RepositoryEntry re = courseEnv.getCourseGroupManager().getCourseEntry();
DueDate availableDate = gtaManager.getSolutionDueDate(task, assessedIdentity, assessedGroup, gtaNode, re, true);
boolean visible = availableDate == null || (availableDate.getDueDate() != null && availableDate.getDueDate().compareTo(new Date()) <= 0);
if (visible) {
if (task.getTaskStatus() == TaskProcess.solution || task.getTaskStatus() == TaskProcess.grading || task.getTaskStatus() == TaskProcess.graded) {
// step solution or beyond
return true;
} else if ((task == null || task.getTaskStatus() == TaskProcess.assignment || task.getTaskStatus() == TaskProcess.submit || task.getTaskStatus() == TaskProcess.review || task.getTaskStatus() == TaskProcess.correction || task.getTaskStatus() == TaskProcess.revision) && gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION_VISIBLE_ALL, false)) {
// steps before solution only if configured to
return true;
}
}
}
return false;
}
use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
the class GTANotifications method createParticipantSolutionItems.
private boolean createParticipantSolutionItems(Task task, Identity assessedIdentity, BusinessGroup group) {
// copy solutions
if (gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION)) {
RepositoryEntry re = courseEnv.getCourseGroupManager().getCourseEntry();
DueDate dueDate = gtaManager.getSolutionDueDate(task, assessedIdentity, group, gtaNode, re, true);
Date solutionDate = null;
if (dueDate == null) {
if (inStep(task, TaskProcess.solution, TaskProcess.grading, TaskProcess.graded)) {
solutionDate = task.getSolutionDate();
} else {
return false;
}
} else if (dueDate != null && dueDate.getDueDate() != null) {
if (task == null) {
if (inStep(task, TaskProcess.assignment, TaskProcess.submit, TaskProcess.review, TaskProcess.correction, TaskProcess.revision) && !dueDate.isRelative() && gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION_VISIBLE_ALL, false)) {
solutionDate = dueDate.getDueDate();
} else {
return false;
}
} else {
solutionDate = dueDate.getDueDate();
}
} else if (task != null) {
solutionDate = task.getSolutionDate();
}
if (solutionDate != null) {
if (task.getSolutionDate() != null && task.getSolutionDate().after(solutionDate)) {
solutionDate = task.getSolutionDate();
}
File solutionDirectory = gtaManager.getSolutionsDirectory(courseEnv, gtaNode);
VFSContainer solutionContainer = gtaManager.getSolutionsContainer(courseEnv, gtaNode);
File[] solutions = solutionDirectory.listFiles(SystemFileFilter.FILES_ONLY);
for (File solution : solutions) {
Date date = solutionDate;
// check if there are new solutions too
cal.setTimeInMillis(solution.lastModified());
Date modificationDate = cal.getTime();
if (date.before(modificationDate)) {
date = modificationDate;
}
if (date.after(compareDate)) {
String author = getAuthor(solution, solutionContainer);
if (task != null) {
String[] params = new String[] { getTaskName(task), displayName, solution.getName(), author };
appendSubscriptionItemForFile("notifications.solution.task", params, assessedIdentity, "[solution:0]", solution, date, false);
} else {
String[] params = new String[] { displayName, solution.getName(), author };
appendSubscriptionItemForFile("notifications.solution", params, assessedIdentity, "[solution:0]", solution, date, false);
}
}
}
return true;
}
}
return false;
}
Aggregations