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);
}
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());
}
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;
}
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);
}
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());
}
}
Aggregations