use of org.olat.course.certificate.RecertificationTimeUnit in project OpenOLAT by OpenOLAT.
the class CertificatesOptionsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("options.certificates.title");
setFormTitleIconCss("o_icon o_icon_certificate");
setFormDescription("options.certificates.descr");
setFormContextHelp("Course Settings#_leistungsnachweis");
formLayout.setElementCssClass("o_sel_course_certificates");
boolean effEnabled = courseConfig.isEfficencyStatementEnabled();
boolean managedEff = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.efficencystatement);
efficencyEl = uifactory.addCheckboxesHorizontal("effIsOn", "chkbx.efficency.onoff", formLayout, new String[] { "xx" }, new String[] { "" });
efficencyEl.addActionListener(FormEvent.ONCHANGE);
efficencyEl.select("xx", effEnabled);
efficencyEl.setEnabled(editable && !managedEff);
String[] pdfCertificatesOptionsValues = new String[] { translate("pdf.certificates.auto"), translate("pdf.certificates.manual") };
pdfCertificatesEl = uifactory.addCheckboxesVertical("pdf.certificates", formLayout, pdfCertificatesOptionsKeys, pdfCertificatesOptionsValues, 1);
pdfCertificatesEl.addActionListener(FormEvent.ONCHANGE);
pdfCertificatesEl.select(PDFCertificatesOptions.auto.name(), courseConfig.isAutomaticCertificationEnabled());
pdfCertificatesEl.select(PDFCertificatesOptions.manual.name(), courseConfig.isManualCertificationEnabled());
pdfCertificatesEl.setEnabled(editable && !managedEff);
String templatePage = velocity_root + "/select_certificate.html";
templateCont = FormLayoutContainer.createCustomFormLayout("template.cont", getTranslator(), templatePage);
templateCont.setRootForm(mainForm);
templateCont.contextPut("mapperUrl", mapperUrl);
formLayout.add(templateCont);
templateCont.setLabel("pdf.certificates.template", null);
selectTemplateLink = uifactory.addFormLink("select", templateCont, Link.BUTTON);
selectTemplateLink.setEnabled(editable);
Long templateId = courseConfig.getCertificateTemplate();
boolean hasTemplate = templateId != null && templateId.longValue() > 0;
if (hasTemplate) {
selectedTemplate = certificatesManager.getTemplateById(templateId);
if (selectedTemplate != null) {
templateCont.contextPut("templateName", selectedTemplate.getName());
} else {
templateCont.contextPut("templateName", translate("default.template"));
}
} else {
templateCont.contextPut("templateName", translate("default.template"));
}
previewTemplateLink = LinkFactory.createButton("preview", templateCont.getFormItemComponent(), this);
previewTemplateLink.setTarget("preview");
boolean reCertificationEnabled = courseConfig.isRecertificationEnabled();
reCertificationEl = uifactory.addCheckboxesHorizontal("recertification", formLayout, new String[] { "xx" }, new String[] { "" });
reCertificationEl.addActionListener(FormEvent.ONCHANGE);
reCertificationEl.setEnabled(editable);
if (reCertificationEnabled) {
reCertificationEl.select("xx", true);
}
String recertificationPage = velocity_root + "/recertification.html";
recertificationCont = FormLayoutContainer.createCustomFormLayout("timelapse.cont", getTranslator(), recertificationPage);
recertificationCont.setRootForm(mainForm);
formLayout.add(recertificationCont);
int timelapse = courseConfig.getRecertificationTimelapse();
reCertificationTimelapseEl = uifactory.addIntegerElement("timelapse", null, timelapse, recertificationCont);
reCertificationTimelapseEl.setDomReplacementWrapperRequired(false);
reCertificationTimelapseEl.setDisplaySize(4);
reCertificationTimelapseEl.setEnabled(editable);
String[] timelapseUnitValues = new String[] { translate("recertification.day"), translate("recertification.week"), translate("recertification.month"), translate("recertification.year") };
RecertificationTimeUnit timelapseUnit = courseConfig.getRecertificationTimelapseUnit();
reCertificationTimelapseUnitEl = uifactory.addDropdownSingleselect("timelapse.unit", null, recertificationCont, timelapseUnitKeys, timelapseUnitValues, null);
reCertificationTimelapseUnitEl.setDomReplacementWrapperRequired(false);
reCertificationTimelapseUnitEl.setEnabled(editable);
if (timelapseUnit != null) {
reCertificationTimelapseUnitEl.select(timelapseUnit.name(), true);
} else {
reCertificationTimelapseUnitEl.select(RecertificationTimeUnit.month.name(), true);
}
if (editable) {
FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonCont.setRootForm(mainForm);
formLayout.add(buttonCont);
uifactory.addFormSubmitButton("save", buttonCont);
}
updateUI();
}
use of org.olat.course.certificate.RecertificationTimeUnit in project OpenOLAT by OpenOLAT.
the class CertificatesManagerImpl method getDateNextRecertification.
private Date getDateNextRecertification(Certificate certificate, CourseConfig config) {
if (config.isRecertificationEnabled() && certificate != null) {
int time = config.getRecertificationTimelapse();
RecertificationTimeUnit timeUnit = config.getRecertificationTimelapseUnit();
Date date = certificate.getCreationDate();
Calendar cal = Calendar.getInstance();
cal.setTime(date);
switch(timeUnit) {
case day:
cal.add(Calendar.DATE, time);
break;
case week:
cal.add(Calendar.DATE, time * 7);
break;
case month:
cal.add(Calendar.MONTH, time);
break;
case year:
cal.add(Calendar.YEAR, time);
break;
}
Date nextCertification = cal.getTime();
return nextCertification;
} else {
return null;
}
}
use of org.olat.course.certificate.RecertificationTimeUnit in project openolat by klemens.
the class CertificatesManagerImpl method getDateNextRecertification.
private Date getDateNextRecertification(Certificate certificate, CourseConfig config) {
if (config.isRecertificationEnabled() && certificate != null) {
int time = config.getRecertificationTimelapse();
RecertificationTimeUnit timeUnit = config.getRecertificationTimelapseUnit();
Date date = certificate.getCreationDate();
Calendar cal = Calendar.getInstance();
cal.setTime(date);
switch(timeUnit) {
case day:
cal.add(Calendar.DATE, time);
break;
case week:
cal.add(Calendar.DATE, time * 7);
break;
case month:
cal.add(Calendar.MONTH, time);
break;
case year:
cal.add(Calendar.YEAR, time);
break;
}
Date nextCertification = cal.getTime();
return nextCertification;
} else {
return null;
}
}
Aggregations