use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
the class EditMultipleDueDatesController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
ModuleConfiguration config = gtaNode.getModuleConfiguration();
assignmentDueDateEl = uifactory.addDateChooser("assignment.duedate", null, formLayout);
assignmentDueDateEl.setDateChooserTimeEnabled(true);
DueDate standardAssignmentDueDate = gtaManager.getAssignmentDueDate(null, null, null, gtaNode, courseEntry, false);
setDueDateExplanation(assignmentDueDateEl, standardAssignmentDueDate);
assignmentDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT));
submissionDueDateEl = uifactory.addDateChooser("submission.duedate", null, formLayout);
submissionDueDateEl.setDateChooserTimeEnabled(true);
DueDate standardSubmissionDueDate = gtaManager.getSubmissionDueDate(null, null, null, gtaNode, courseEntry, false);
setDueDateExplanation(submissionDueDateEl, standardSubmissionDueDate);
boolean submissionDeadline = config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT);
submissionDueDateEl.setVisible(submissionDeadline);
if (submissionDeadline) {
for (Task task : tasks) {
if (task.getTaskStatus().ordinal() > TaskProcess.submit.ordinal()) {
StaticTextElement warningReopenEl = uifactory.addStaticTextElement("reopen", translate("warning.reopen"), formLayout);
warningReopenEl.setElementCssClass("o_gta_reopen_warning");
warningReopenEl.setLabel(null, null);
break;
}
}
}
revisionDueDateEl = uifactory.addDateChooser("revisions.duedate", null, formLayout);
revisionDueDateEl.setDateChooserTimeEnabled(true);
revisionDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD));
solutionDueDateEl = uifactory.addDateChooser("solution.duedate", null, formLayout);
solutionDueDateEl.setDateChooserTimeEnabled(true);
DueDate standardSolutionDueDate = gtaManager.getSolutionDueDate(null, null, null, gtaNode, courseEntry, false);
setDueDateExplanation(solutionDueDateEl, standardSolutionDueDate);
solutionDueDateEl.setVisible(config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION));
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
uifactory.addFormSubmitButton("save", buttonsCont);
}
use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
the class GTAAbstractController method stepAssignment.
protected Task stepAssignment(@SuppressWarnings("unused") UserRequest ureq, Task assignedTask) {
DueDate dueDate = getAssignementDueDate(assignedTask);
if (dueDate != null) {
if (dueDate.getDueDate() != null) {
Date date = dueDate.getDueDate();
String dateAsString = formatDueDate(dueDate, true);
mainVC.contextPut("assignmentDueDate", dateAsString);
mainVC.contextRemove("assignmentDueDateMsg");
if (assignedTask != null && StringHelper.containsNonWhitespace(assignedTask.getTaskName()) && assignedTask.getTaskStatus() == TaskProcess.assignment && date.compareTo(new Date()) < 0) {
// push to the next step if the task is blocked in assignment (it's a security)
assignedTask = gtaManager.nextStep(assignedTask, gtaNode, Role.auto);
}
} else if (dueDate.getMessageKey() != null) {
mainVC.contextPut("assignmentDueDateMsg", translate(dueDate.getMessageKey(), dueDate.getMessageArg()));
mainVC.contextRemove("assignmentDueDate");
}
}
return assignedTask;
}
use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
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;
}
use of org.olat.course.nodes.gta.model.DueDate in project openolat by klemens.
the class GTAAbstractController method stepRevision.
protected Task stepRevision(@SuppressWarnings("unused") UserRequest ureq, Task assignedTask) {
if (assignedTask != null && assignedTask.getRevisionsDueDate() != null) {
Date date = assignedTask.getRevisionsDueDate();
String dateAsString = formatDueDate(new DueDate(false, date), false);
mainVC.contextPut("revisionDueDate", dateAsString);
if (assignedTask != null && assignedTask.getTaskStatus() == TaskProcess.revision && date.compareTo(new Date()) < 0) {
// push to the next step
int numOfDocs = getNumberOfRevisionDocuments(assignedTask);
assignedTask = gtaManager.submitRevisions(assignedTask, gtaNode, numOfDocs, Role.auto);
doUpdateAttempts();
}
}
return assignedTask;
}
Aggregations