Search in sources :

Example 6 with RecertificationTimeUnit

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();
}
Also used : RecertificationTimeUnit(org.olat.course.certificate.RecertificationTimeUnit) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 7 with RecertificationTimeUnit

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;
    }
}
Also used : RecertificationTimeUnit(org.olat.course.certificate.RecertificationTimeUnit) Calendar(java.util.Calendar) Date(java.util.Date)

Example 8 with RecertificationTimeUnit

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;
    }
}
Also used : RecertificationTimeUnit(org.olat.course.certificate.RecertificationTimeUnit) Calendar(java.util.Calendar) Date(java.util.Date)

Aggregations

RecertificationTimeUnit (org.olat.course.certificate.RecertificationTimeUnit)8 Calendar (java.util.Calendar)2 Date (java.util.Date)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 ILoggingAction (org.olat.core.logging.activity.ILoggingAction)2 EventBus (org.olat.core.util.event.EventBus)2 ICourse (org.olat.course.ICourse)2 CourseConfigEvent (org.olat.course.config.CourseConfigEvent)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2