use of org.olat.course.certificate.CertificateLight in project openolat by klemens.
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 klemens.
the class CertificateAndEfficiencyStatementListController method updateStatement.
private void updateStatement(Long resourceKey, Long certificateKey) {
List<CertificateAndEfficiencyStatement> statements = tableModel.getObjects();
for (int i = statements.size(); i-- > 0; ) {
CertificateAndEfficiencyStatement statement = statements.get(i);
if (resourceKey.equals(statement.getResourceKey())) {
CertificateLight certificate = certificatesManager.getCertificateLightById(certificateKey);
statement.setCertificate(certificate);
break;
}
}
}
use of org.olat.course.certificate.CertificateLight in project openolat by klemens.
the class CertificateAndEfficiencyStatementListController method loadModel.
private void loadModel() {
Map<Long, CertificateAndEfficiencyStatement> resourceKeyToStatments = new HashMap<>();
List<CertificateAndEfficiencyStatement> statments = new ArrayList<>();
List<UserEfficiencyStatementLight> efficiencyStatementsList = esm.findEfficiencyStatementsLight(assessedIdentity);
for (UserEfficiencyStatementLight efficiencyStatement : efficiencyStatementsList) {
CertificateAndEfficiencyStatement wrapper = new CertificateAndEfficiencyStatement();
wrapper.setDisplayName(efficiencyStatement.getShortTitle());
wrapper.setPassed(efficiencyStatement.getPassed());
wrapper.setScore(efficiencyStatement.getScore());
wrapper.setEfficiencyStatementKey(efficiencyStatement.getKey());
wrapper.setResourceKey(efficiencyStatement.getArchivedResourceKey());
wrapper.setLastModified(efficiencyStatement.getLastModified());
statments.add(wrapper);
resourceKeyToStatments.put(efficiencyStatement.getArchivedResourceKey(), wrapper);
}
List<CertificateLight> certificates = certificatesManager.getLastCertificates(assessedIdentity);
for (CertificateLight certificate : certificates) {
Long resourceKey = certificate.getOlatResourceKey();
CertificateAndEfficiencyStatement wrapper = resourceKeyToStatments.get(resourceKey);
if (wrapper == null) {
wrapper = new CertificateAndEfficiencyStatement();
wrapper.setDisplayName(certificate.getCourseTitle());
resourceKeyToStatments.put(resourceKey, wrapper);
statments.add(wrapper);
} else {
if (!StringHelper.containsNonWhitespace(wrapper.getDisplayName())) {
wrapper.setDisplayName(certificate.getCourseTitle());
}
wrapper.setResourceKey(resourceKey);
}
if (resourceKey != null && wrapper.getResourceKey() == null) {
wrapper.setResourceKey(resourceKey);
}
wrapper.setCertificate(certificate);
}
for (CertificateAndEfficiencyStatement statment : statments) {
if (!StringHelper.containsNonWhitespace(statment.getDisplayName()) && statment.getResourceKey() != null) {
String displayName = repositoryManager.lookupDisplayNameByResourceKey(statment.getResourceKey());
statment.setDisplayName(displayName);
}
}
tableModel.setObjects(statments);
}
use of org.olat.course.certificate.CertificateLight in project openolat by klemens.
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());
}
}
use of org.olat.course.certificate.CertificateLight in project openolat by klemens.
the class StudentCoursesController method updateCertificate.
private void updateCertificate(Long certificateKey) {
CertificateLight certificate = certificatesManager.getCertificateLightById(certificateKey);
model.putCertificate(certificate);
}
Aggregations