Search in sources :

Example 1 with CertificateLight

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

the class CertificatesManagerTest method loadCertificate.

@Test
public void loadCertificate() {
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("cer-1");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(identity);
    dbInstance.commitAndCloseSession();
    CertificateInfos certificateInfos = new CertificateInfos(identity, 5.0f, Boolean.TRUE);
    Certificate certificate = certificatesManager.generateCertificate(certificateInfos, entry, null, false);
    Assert.assertNotNull(certificate);
    dbInstance.commitAndCloseSession();
    // full
    Certificate reloadedCertificate = certificatesManager.getCertificateById(certificate.getKey());
    Assert.assertNotNull(reloadedCertificate);
    Assert.assertEquals(certificate, reloadedCertificate);
    Assert.assertNotNull(reloadedCertificate.getUuid());
    Assert.assertEquals(certificate.getUuid(), reloadedCertificate.getUuid());
    Assert.assertEquals(entry.getDisplayname(), reloadedCertificate.getCourseTitle());
    Assert.assertEquals(identity, reloadedCertificate.getIdentity());
    // light
    CertificateLight reloadedLight = certificatesManager.getCertificateLightById(certificate.getKey());
    Assert.assertNotNull(reloadedLight);
    Assert.assertEquals(certificate.getKey(), reloadedLight.getKey());
    Assert.assertEquals(entry.getDisplayname(), reloadedLight.getCourseTitle());
    Assert.assertEquals(identity.getKey(), reloadedLight.getIdentityKey());
    Assert.assertEquals(entry.getOlatResource().getKey(), reloadedLight.getOlatResourceKey());
    // uuid
    Certificate reloadedUuid = certificatesManager.getCertificateByUuid(certificate.getUuid());
    Assert.assertNotNull(reloadedUuid);
    Assert.assertEquals(certificate, reloadedUuid);
    Assert.assertEquals(entry.getDisplayname(), reloadedUuid.getCourseTitle());
    Assert.assertEquals(identity, reloadedUuid.getIdentity());
    // boolean
    boolean has = certificatesManager.hasCertificate(identity, entry.getOlatResource().getKey());
    Assert.assertTrue(has);
}
Also used : CertificateInfos(org.olat.course.certificate.model.CertificateInfos) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) CertificateLight(org.olat.course.certificate.CertificateLight) Certificate(org.olat.course.certificate.Certificate) Test(org.junit.Test)

Example 2 with CertificateLight

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

the class CertificatesManagerTest method loadLastCertificate.

@Test
public void loadLastCertificate() {
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("cer-1");
    RepositoryEntry entry = JunitTestHelper.deployBasicCourse(identity);
    dbInstance.commitAndCloseSession();
    CertificateInfos certificateInfos = new CertificateInfos(identity, 5.0f, Boolean.TRUE);
    Certificate certificate = certificatesManager.generateCertificate(certificateInfos, entry, null, false);
    Assert.assertNotNull(certificate);
    dbInstance.commitAndCloseSession();
    // per resource
    Certificate reloadedCertificate = certificatesManager.getLastCertificate(identity, entry.getOlatResource().getKey());
    Assert.assertNotNull(reloadedCertificate);
    Assert.assertEquals(certificate, reloadedCertificate);
    // all
    List<CertificateLight> allCertificates = certificatesManager.getLastCertificates(identity);
    Assert.assertNotNull(allCertificates);
    Assert.assertEquals(1, allCertificates.size());
    CertificateLight allCertificate = allCertificates.get(0);
    Assert.assertEquals(certificate.getKey(), allCertificate.getKey());
    Assert.assertEquals(entry.getDisplayname(), allCertificate.getCourseTitle());
    Assert.assertEquals(identity.getKey(), allCertificate.getIdentityKey());
    Assert.assertEquals(entry.getOlatResource().getKey(), allCertificate.getOlatResourceKey());
}
Also used : CertificateInfos(org.olat.course.certificate.model.CertificateInfos) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) CertificateLight(org.olat.course.certificate.CertificateLight) Certificate(org.olat.course.certificate.Certificate) Test(org.junit.Test)

Example 3 with CertificateLight

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

the class GroupController method loadModel.

private List<EfficiencyStatementEntry> loadModel() {
    List<EfficiencyStatementEntry> allGroup = coachingService.getGroup(group, userPropertyHandlers, getLocale());
    List<CertificateLight> certificates = certificatesManager.getLastCertificates(group);
    ConcurrentMap<IdentityResourceKey, CertificateLight> certificateMap = new ConcurrentHashMap<>();
    for (CertificateLight certificate : certificates) {
        IdentityResourceKey key = new IdentityResourceKey(certificate.getIdentityKey(), certificate.getOlatResourceKey());
        certificateMap.put(key, certificate);
    }
    model.setObjects(allGroup, certificateMap);
    tableEl.reloadData();
    tableEl.reset();
    return allGroup;
}
Also used : EfficiencyStatementEntry(org.olat.modules.coach.model.EfficiencyStatementEntry) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CertificateLight(org.olat.course.certificate.CertificateLight) IdentityResourceKey(org.olat.modules.coach.model.IdentityResourceKey)

Example 4 with CertificateLight

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

the class GroupController method updateCertificate.

private void updateCertificate(Long certificateKey) {
    CertificateLight certificate = certificatesManager.getCertificateLightById(certificateKey);
    model.putCertificate(certificate);
}
Also used : CertificateLight(org.olat.course.certificate.CertificateLight)

Example 5 with CertificateLight

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

the class DownloadCertificateCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
    if (renderer == null) {
        if (cellValue instanceof CertificateLight) {
            renderExcel(target, (CertificateLight) cellValue);
        } else if (cellValue instanceof CertificateLightPack) {
            CertificateLightPack pack = (CertificateLightPack) cellValue;
            renderExcel(target, pack.getCertificate());
        }
    } else if (cellValue instanceof CertificateLight) {
        CertificateLight certificate = (CertificateLight) cellValue;
        if (assessedIdentity == null) {
            IdentityRef idRef = new IdentityRefImpl(certificate.getIdentityKey());
            render(target, certificate, idRef, translator.getLocale());
        } else {
            render(target, certificate, assessedIdentity, translator.getLocale());
        }
    } else if (cellValue instanceof CertificateLightPack) {
        CertificateLightPack pack = (CertificateLightPack) cellValue;
        render(target, pack.getCertificate(), pack.getIdentity(), translator.getLocale());
    }
}
Also used : IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) CertificateLightPack(org.olat.course.certificate.model.CertificateLightPack) IdentityRef(org.olat.basesecurity.IdentityRef) CertificateLight(org.olat.course.certificate.CertificateLight)

Aggregations

CertificateLight (org.olat.course.certificate.CertificateLight)24 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)8 EfficiencyStatementEntry (org.olat.modules.coach.model.EfficiencyStatementEntry)6 IdentityResourceKey (org.olat.modules.coach.model.IdentityResourceKey)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 Test (org.junit.Test)4 Identity (org.olat.core.id.Identity)4 Certificate (org.olat.course.certificate.Certificate)4 CertificateInfos (org.olat.course.certificate.model.CertificateInfos)4 CertificateAndEfficiencyStatement (org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 IdentityRef (org.olat.basesecurity.IdentityRef)2 IdentityRefImpl (org.olat.basesecurity.model.IdentityRefImpl)2 UserEfficiencyStatementLight (org.olat.course.assessment.model.UserEfficiencyStatementLight)2 CertificateLightPack (org.olat.course.certificate.model.CertificateLightPack)2 AssessedIdentityElementRow (org.olat.modules.assessment.ui.AssessedIdentityElementRow)2 AssessmentToolContainer (org.olat.modules.assessment.ui.AssessmentToolContainer)2 IdentityRepositoryEntryKey (org.olat.modules.coach.model.IdentityRepositoryEntryKey)2