use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
the class GTAParticipantController method resetTask.
@Override
protected void resetTask(UserRequest ureq, Task task) {
resetTaskButton.setUserObject(task);
DueDate assignmentDueDate = getAssignementDueDate(task);
boolean allowed = task != null && (StringHelper.containsNonWhitespace(task.getTaskName()) || (!StringHelper.containsNonWhitespace(task.getTaskName()) && task.getTaskStatus() == TaskProcess.submit)) && (task.getTaskStatus() == TaskProcess.assignment || task.getTaskStatus() == TaskProcess.submit) && task.getAllowResetDate() != null && (assignmentDueDate == null || assignmentDueDate.getDueDate() == null || assignmentDueDate.getDueDate().after(new Date())) && GTACourseNode.GTASK_ASSIGNEMENT_TYPE_MANUAL.equals(gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_ASSIGNEMENT_TYPE));
resetTaskButton.setVisible(allowed);
}
use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
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;
}
use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
the class GTACoachedGroupListController method updateModel.
protected void updateModel() {
RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
List<TaskLight> tasks = gtaManager.getTasksLight(entry, gtaNode);
Map<Long, TaskLight> groupToTasks = new HashMap<>();
for (TaskLight task : tasks) {
if (task.getBusinessGroupKey() != null) {
groupToTasks.put(task.getBusinessGroupKey(), task);
}
}
List<CoachedGroupRow> rows = new ArrayList<>(coachedGroups.size());
for (BusinessGroup group : coachedGroups) {
TaskLight task = groupToTasks.get(group.getKey());
Date submissionDueDate = null;
if (task == null || task.getTaskStatus() == null || task.getTaskStatus() == TaskProcess.assignment) {
DueDate dueDate = gtaManager.getSubmissionDueDate(task, null, group, 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 = this.hasSubmittedDocument(task);
}
}
rows.add(new CoachedGroupRow(group, task, submissionDueDate, syntheticSubmissionDate, hasSubmittedDocument));
}
tableModel.setObjects(rows);
tableEl.reset();
}
use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
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();
}
use of org.olat.course.nodes.gta.model.DueDate in project OpenOLAT by OpenOLAT.
the class GTAAbstractController method formatDueDate.
/**
* User friendly format, 2015-06-20 00:00 will be rendered as 2015-06-20
* if @param userDeadLine is false (for solution,e.g) and 2015-06-20
* if @param userDeadLine is true (meaning the user have the whole day
* to do the job until the deadline at midnight).
* @param dueDate
* @param user deadline
* @return
*/
protected String formatDueDate(DueDate dueDate, boolean userDeadLine) {
Date date = dueDate.getDueDate();
Calendar cal = Calendar.getInstance();
cal.setTime(date);
String formattedDate;
if (cal.get(Calendar.HOUR_OF_DAY) == 0 && cal.get(Calendar.MINUTE) == 0) {
if (userDeadLine) {
cal.add(Calendar.DATE, -1);
}
formattedDate = Formatter.getInstance(getLocale()).formatDate(cal.getTime());
} else {
formattedDate = Formatter.getInstance(getLocale()).formatDateAndTime(date);
}
return formattedDate;
}
Aggregations