Search in sources :

Example 11 with DueDate

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;
}
Also used : TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) DueDate(org.olat.course.nodes.gta.model.DueDate) Date(java.util.Date) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 12 with DueDate

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;
}
Also used : GTARelativeToDates(org.olat.course.nodes.gta.GTARelativeToDates) RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) Calendar(java.util.Calendar) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) DueDate(org.olat.course.nodes.gta.model.DueDate) Date(java.util.Date) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 13 with 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;
}
Also used : TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) DueDate(org.olat.course.nodes.gta.model.DueDate) Date(java.util.Date) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 14 with DueDate

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;
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) DueDate(org.olat.course.nodes.gta.model.DueDate) Date(java.util.Date) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 15 with DueDate

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;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) DueDate(org.olat.course.nodes.gta.model.DueDate) File(java.io.File) Date(java.util.Date) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Aggregations

DueDate (org.olat.course.nodes.gta.model.DueDate)44 Date (java.util.Date)38 TaskRevisionDate (org.olat.course.nodes.gta.TaskRevisionDate)14 TaskDueDate (org.olat.course.nodes.gta.TaskDueDate)12 RepositoryEntry (org.olat.repository.RepositoryEntry)10 File (java.io.File)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 ArrayList (java.util.ArrayList)4 Calendar (java.util.Calendar)4 HashMap (java.util.HashMap)4 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 TaskLight (org.olat.course.nodes.gta.TaskLight)4 ModuleConfiguration (org.olat.modules.ModuleConfiguration)4 BigDecimal (java.math.BigDecimal)2 List (java.util.List)2 IdentityRef (org.olat.basesecurity.IdentityRef)2 IdentityRefImpl (org.olat.basesecurity.model.IdentityRefImpl)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2