Search in sources :

Example 1 with RecertificationTimeUnit

use of org.olat.course.certificate.RecertificationTimeUnit in project OpenOLAT by OpenOLAT.

the class CourseConfig method getRecertificationTimelapseUnit.

public RecertificationTimeUnit getRecertificationTimelapseUnit() {
    String timelapseUnit = (String) configuration.get(RECERTIFICATION_TIMELAPSE_UNIT);
    RecertificationTimeUnit timeUnit = null;
    if (StringHelper.containsNonWhitespace(timelapseUnit)) {
        timeUnit = RecertificationTimeUnit.valueOf(timelapseUnit);
    }
    return timeUnit;
}
Also used : RecertificationTimeUnit(org.olat.course.certificate.RecertificationTimeUnit)

Example 2 with RecertificationTimeUnit

use of org.olat.course.certificate.RecertificationTimeUnit in project OpenOLAT by OpenOLAT.

the class CertificatesOptionsController method doChangeConfig.

private void doChangeConfig(UserRequest ureq) {
    OLATResourceable courseOres = entry.getOlatResource();
    if (CourseFactory.isCourseEditSessionOpen(courseOres.getResourceableId())) {
        showWarning("error.editoralreadylocked", new String[] { "???" });
        return;
    }
    ICourse course = CourseFactory.openCourseEditSession(courseOres.getResourceableId());
    courseConfig = course.getCourseEnvironment().getCourseConfig();
    boolean enableEfficiencyStatment = efficencyEl.isSelected(0);
    boolean updateStatement = courseConfig.isEfficencyStatementEnabled() != enableEfficiencyStatment;
    courseConfig.setEfficencyStatementIsEnabled(enableEfficiencyStatment);
    Collection<String> certificationOptions = pdfCertificatesEl.getSelectedKeys();
    courseConfig.setAutomaticCertificationEnabled(certificationOptions.contains(PDFCertificatesOptions.auto.name()));
    courseConfig.setManualCertificationEnabled(certificationOptions.contains(PDFCertificatesOptions.manual.name()));
    if (selectedTemplate != null) {
        Long templateId = selectedTemplate.getKey();
        courseConfig.setCertificateTemplate(templateId);
    } else {
        courseConfig.setCertificateTemplate(null);
    }
    boolean recertificationEnabled = reCertificationEl.isEnabled() && reCertificationEl.isAtLeastSelected(1);
    courseConfig.setRecertificationEnabled(recertificationEnabled);
    if (recertificationEnabled) {
        int timelapse = reCertificationTimelapseEl.getIntValue();
        courseConfig.setRecertificationTimelapse(timelapse);
        if (reCertificationTimelapseUnitEl.isOneSelected()) {
            String selectedUnit = reCertificationTimelapseUnitEl.getSelectedKey();
            RecertificationTimeUnit timeUnit = RecertificationTimeUnit.valueOf(selectedUnit);
            courseConfig.setRecertificationTimelapseUnit(timeUnit);
        } else {
            courseConfig.setRecertificationTimelapseUnit(RecertificationTimeUnit.month);
        }
    } else {
        courseConfig.setRecertificationTimelapse(0);
        courseConfig.setRecertificationTimelapseUnit(null);
    }
    CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
    CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
    if (updateStatement) {
        if (enableEfficiencyStatment) {
            // first create the efficiencies, send event to agency (all courses add link)
            RepositoryEntry courseRe = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            List<Identity> identitiesWithData = course.getCourseEnvironment().getCoursePropertyManager().getAllIdentitiesWithCourseAssessmentData(null);
            efficiencyStatementManager.updateEfficiencyStatements(courseRe, identitiesWithData);
        } else {
            // delete really the efficiencies of the users.
            RepositoryEntry courseRepoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
            efficiencyStatementManager.deleteEfficiencyStatementsFromCourse(courseRepoEntry.getKey());
        }
        // inform everybody else
        EventBus eventBus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
        CourseConfigEvent courseConfigEvent = new CourseConfigEvent(CourseConfigType.efficiencyStatement, course.getResourceableId());
        eventBus.fireEventToListenersOf(courseConfigEvent, course);
        ILoggingAction loggingAction = enableEfficiencyStatment ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_EFFICIENCY_STATEMENT_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_EFFICIENCY_STATEMENT_DISABLED;
        ThreadLocalUserActivityLogger.log(loggingAction, getClass());
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : CourseConfigEvent(org.olat.course.config.CourseConfigEvent) OLATResourceable(org.olat.core.id.OLATResourceable) ILoggingAction(org.olat.core.logging.activity.ILoggingAction) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) EventBus(org.olat.core.util.event.EventBus) RecertificationTimeUnit(org.olat.course.certificate.RecertificationTimeUnit) Identity(org.olat.core.id.Identity)

Example 3 with RecertificationTimeUnit

use of org.olat.course.certificate.RecertificationTimeUnit in project openolat by klemens.

the class CourseConfig method getRecertificationTimelapseUnit.

public RecertificationTimeUnit getRecertificationTimelapseUnit() {
    String timelapseUnit = (String) configuration.get(RECERTIFICATION_TIMELAPSE_UNIT);
    RecertificationTimeUnit timeUnit = null;
    if (StringHelper.containsNonWhitespace(timelapseUnit)) {
        timeUnit = RecertificationTimeUnit.valueOf(timelapseUnit);
    }
    return timeUnit;
}
Also used : RecertificationTimeUnit(org.olat.course.certificate.RecertificationTimeUnit)

Example 4 with RecertificationTimeUnit

use of org.olat.course.certificate.RecertificationTimeUnit in project openolat by klemens.

the class CertificatesOptionsController method doChangeConfig.

private void doChangeConfig(UserRequest ureq) {
    OLATResourceable courseOres = entry.getOlatResource();
    if (CourseFactory.isCourseEditSessionOpen(courseOres.getResourceableId())) {
        showWarning("error.editoralreadylocked", new String[] { "???" });
        return;
    }
    ICourse course = CourseFactory.openCourseEditSession(courseOres.getResourceableId());
    courseConfig = course.getCourseEnvironment().getCourseConfig();
    boolean enableEfficiencyStatment = efficencyEl.isSelected(0);
    boolean updateStatement = courseConfig.isEfficencyStatementEnabled() != enableEfficiencyStatment;
    courseConfig.setEfficencyStatementIsEnabled(enableEfficiencyStatment);
    Collection<String> certificationOptions = pdfCertificatesEl.getSelectedKeys();
    courseConfig.setAutomaticCertificationEnabled(certificationOptions.contains(PDFCertificatesOptions.auto.name()));
    courseConfig.setManualCertificationEnabled(certificationOptions.contains(PDFCertificatesOptions.manual.name()));
    if (selectedTemplate != null) {
        Long templateId = selectedTemplate.getKey();
        courseConfig.setCertificateTemplate(templateId);
    } else {
        courseConfig.setCertificateTemplate(null);
    }
    boolean recertificationEnabled = reCertificationEl.isEnabled() && reCertificationEl.isAtLeastSelected(1);
    courseConfig.setRecertificationEnabled(recertificationEnabled);
    if (recertificationEnabled) {
        int timelapse = reCertificationTimelapseEl.getIntValue();
        courseConfig.setRecertificationTimelapse(timelapse);
        if (reCertificationTimelapseUnitEl.isOneSelected()) {
            String selectedUnit = reCertificationTimelapseUnitEl.getSelectedKey();
            RecertificationTimeUnit timeUnit = RecertificationTimeUnit.valueOf(selectedUnit);
            courseConfig.setRecertificationTimelapseUnit(timeUnit);
        } else {
            courseConfig.setRecertificationTimelapseUnit(RecertificationTimeUnit.month);
        }
    } else {
        courseConfig.setRecertificationTimelapse(0);
        courseConfig.setRecertificationTimelapseUnit(null);
    }
    CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
    CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
    if (updateStatement) {
        if (enableEfficiencyStatment) {
            // first create the efficiencies, send event to agency (all courses add link)
            RepositoryEntry courseRe = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            List<Identity> identitiesWithData = course.getCourseEnvironment().getCoursePropertyManager().getAllIdentitiesWithCourseAssessmentData(null);
            efficiencyStatementManager.updateEfficiencyStatements(courseRe, identitiesWithData);
        } else {
            // delete really the efficiencies of the users.
            RepositoryEntry courseRepoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
            efficiencyStatementManager.deleteEfficiencyStatementsFromCourse(courseRepoEntry.getKey());
        }
        // inform everybody else
        EventBus eventBus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
        CourseConfigEvent courseConfigEvent = new CourseConfigEvent(CourseConfigType.efficiencyStatement, course.getResourceableId());
        eventBus.fireEventToListenersOf(courseConfigEvent, course);
        ILoggingAction loggingAction = enableEfficiencyStatment ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_EFFICIENCY_STATEMENT_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_EFFICIENCY_STATEMENT_DISABLED;
        ThreadLocalUserActivityLogger.log(loggingAction, getClass());
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : CourseConfigEvent(org.olat.course.config.CourseConfigEvent) OLATResourceable(org.olat.core.id.OLATResourceable) ILoggingAction(org.olat.core.logging.activity.ILoggingAction) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) EventBus(org.olat.core.util.event.EventBus) RecertificationTimeUnit(org.olat.course.certificate.RecertificationTimeUnit) Identity(org.olat.core.id.Identity)

Example 5 with RecertificationTimeUnit

use of org.olat.course.certificate.RecertificationTimeUnit in project openolat by klemens.

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)

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