Search in sources :

Example 31 with DueDate

use of org.olat.course.nodes.gta.model.DueDate in project OpenOLAT by OpenOLAT.

the class GTACoachController method backToSubmission.

private void backToSubmission(Task assignedTask) {
    if (config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT) && assignedTask != null) {
        Date now = new Date();
        DueDate dueDate = getSubmissionDueDate(assignedTask);
        if (!coachCourseEnv.isCourseReadOnly() && (dueDate == null || dueDate.getDueDate() == null || now.before(dueDate.getDueDate()))) {
            backToSubmissionLink = LinkFactory.createButton("coach.back.to.submission", mainVC, this);
            backToSubmissionLink.setUserObject(assignedTask);
        }
    }
}
Also used : DueDate(org.olat.course.nodes.gta.model.DueDate) Date(java.util.Date) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 32 with DueDate

use of org.olat.course.nodes.gta.model.DueDate in project OpenOLAT by OpenOLAT.

the class GTACoachedParticipantListController method updateModel.

protected void updateModel(UserRequest ureq) {
    RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
    List<TaskLight> tasks = gtaManager.getTasksLight(entry, gtaNode);
    Map<Long, TaskLight> identityToTasks = new HashMap<>(tasks.size());
    for (TaskLight task : tasks) {
        if (task.getIdentityKey() != null) {
            identityToTasks.put(task.getIdentityKey(), task);
        }
    }
    List<IdentityMark> marks = gtaManager.getMarks(entry, gtaNode, ureq.getIdentity());
    Map<Long, IdentityMark> identityToMarks = new HashMap<>(marks.size());
    for (IdentityMark mark : marks) {
        if (mark.getParticipant() != null) {
            identityToMarks.put(mark.getParticipant().getKey(), mark);
        }
    }
    List<AssessmentEntry> assessments = assessmentService.loadAssessmentEntriesBySubIdent(entry, gtaNode.getIdent());
    Map<Long, AssessmentEntry> identityToAssessments = new HashMap<>(assessments.size());
    for (AssessmentEntry assessment : assessments) {
        if (assessment.getIdentity() != null) {
            identityToAssessments.put(assessment.getIdentity().getKey(), assessment);
        }
    }
    List<CoachedIdentityRow> rows = new ArrayList<>(assessableIdentities.size());
    for (UserPropertiesRow assessableIdentity : assessableIdentities) {
        IdentityMark mark = identityToMarks.get(assessableIdentity.getIdentityKey());
        if (markedOnly && mark == null)
            continue;
        FormLink markLink = uifactory.addFormLink("mark_" + assessableIdentity.getIdentityKey(), "mark", "", null, null, Link.NONTRANSLATED);
        markLink.setIconLeftCSS(mark != null ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
        markLink.setUserObject(assessableIdentity.getIdentityKey());
        TaskLight task = identityToTasks.get(assessableIdentity.getIdentityKey());
        Date submissionDueDate = null;
        if (task == null || task.getTaskStatus() == null || task.getTaskStatus() == TaskProcess.assignment) {
            IdentityRef identityRef = new IdentityRefImpl(assessableIdentity.getIdentityKey());
            DueDate dueDate = gtaManager.getSubmissionDueDate(task, identityRef, null, gtaNode, entry, true);
            if (dueDate != null) {
                submissionDueDate = dueDate.getDueDate();
            }
        }
        Date syntheticSubmissionDate = null;
        boolean hasSubmittedDocument = false;
        if (task != null && task.getTaskStatus() != null && task.getTaskStatus() != TaskProcess.assignment && task.getTaskStatus() != TaskProcess.submit) {
            syntheticSubmissionDate = getSyntheticSubmissionDate(task);
            if (syntheticSubmissionDate != null) {
                hasSubmittedDocument = hasSubmittedDocument(task);
            }
        }
        int numSubmittedDocs = task != null && task.getSubmissionNumOfDocs() != null ? task.getSubmissionNumOfDocs() : 0;
        AssessmentEntry assessment = identityToAssessments.get(assessableIdentity.getIdentityKey());
        Boolean userVisibility = assessment != null ? assessment.getUserVisibility() : null;
        BigDecimal score = assessment != null ? assessment.getScore() : null;
        Boolean passed = assessment != null ? assessment.getPassed() : null;
        rows.add(new CoachedIdentityRow(assessableIdentity, task, submissionDueDate, syntheticSubmissionDate, hasSubmittedDocument, markLink, userVisibility, score, passed, numSubmittedDocs));
    }
    tableModel.setObjects(rows);
    tableEl.reset();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) IdentityRef(org.olat.basesecurity.IdentityRef) TaskLight(org.olat.course.nodes.gta.TaskLight) UserPropertiesRow(org.olat.user.UserPropertiesRow) DueDate(org.olat.course.nodes.gta.model.DueDate) IdentityMark(org.olat.course.nodes.gta.IdentityMark) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date) DueDate(org.olat.course.nodes.gta.model.DueDate) BigDecimal(java.math.BigDecimal)

Example 33 with DueDate

use of org.olat.course.nodes.gta.model.DueDate in project OpenOLAT by OpenOLAT.

the class GTAParticipantController method stepAssignment.

@Override
protected Task stepAssignment(UserRequest ureq, Task assignedTask) {
    assignedTask = super.stepAssignment(ureq, assignedTask);
    if (TaskHelper.inOrNull(assignedTask, TaskProcess.assignment)) {
        mainVC.contextPut("assignmentCssClass", "o_active");
        if (stepPreferences != null) {
            // assignment is very important, open it always
            stepPreferences.setAssignement(Boolean.TRUE);
        }
        // assignment open?
        DueDate dueDate = getAssignementDueDate(assignedTask);
        if (dueDate != null && dueDate.getDueDate() != null && dueDate.getDueDate().compareTo(new Date()) < 0) {
            // assignment is closed
            mainVC.contextPut("assignmentClosed", Boolean.TRUE);
        } else if (userCourseEnv.isCourseReadOnly()) {
            showAssignedTask(ureq, assignedTask);
        } else {
            List<TaskDefinition> availableTasks = gtaManager.getTaskDefinitions(courseEnv, gtaNode);
            // assignment auto or manual
            String assignmentType = config.getStringValue(GTACourseNode.GTASK_ASSIGNEMENT_TYPE);
            if (GTACourseNode.GTASK_ASSIGNEMENT_TYPE_AUTO.equals(assignmentType)) {
                AssignmentResponse response;
                if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
                    response = gtaManager.assignTaskAutomatically(taskList, assessedGroup, courseEnv, gtaNode);
                } else {
                    response = gtaManager.assignTaskAutomatically(taskList, assessedIdentity, courseEnv, gtaNode);
                }
                if (response == null || response.getStatus() == AssignmentResponse.Status.error) {
                    showError("task.assignment.error");
                } else if (response == null || response.getStatus() == AssignmentResponse.Status.noMoreTasks) {
                    showError("error.nomoretasks");
                } else if (response == null || response.getStatus() == AssignmentResponse.Status.ok) {
                    if (response != null) {
                        assignedTask = response.getTask();
                    }
                    showInfo("task.successfully.assigned");
                    showAssignedTask(ureq, assignedTask);
                }
            } else if (GTACourseNode.GTASK_ASSIGNEMENT_TYPE_MANUAL.equals(assignmentType)) {
                availableTaskCtrl = new GTAAvailableTaskController(ureq, getWindowControl(), availableTasks, taskList, assessedGroup, assessedIdentity, courseEnv, gtaNode);
                listenTo(availableTaskCtrl);
                mainVC.put("availableTasks", availableTaskCtrl.getInitialComponent());
            }
        }
    } else {
        mainVC.contextPut("assignmentCssClass", "o_done");
        showAssignedTask(ureq, assignedTask);
    }
    return assignedTask;
}
Also used : AssignmentResponse(org.olat.course.nodes.gta.AssignmentResponse) List(java.util.List) DueDate(org.olat.course.nodes.gta.model.DueDate) Date(java.util.Date) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 34 with DueDate

use of org.olat.course.nodes.gta.model.DueDate 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;
}
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 35 with DueDate

use of org.olat.course.nodes.gta.model.DueDate in project OpenOLAT by OpenOLAT.

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)

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