use of org.olat.course.certificate.CertificateLight in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 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 klemens.
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 klemens.
the class STIdentityListCourseNodeController method loadModel.
@Override
protected void loadModel(UserRequest ureq) {
Map<Long, Date> initialLaunchDates = userInfosMgr.getInitialLaunchDates(getCourseRepositoryEntry().getOlatResource());
super.loadModel(ureq);
List<AssessedIdentityElementRow> rows = usersTableModel.getObjects();
for (AssessedIdentityElementRow row : rows) {
Date initialLaunchDate = initialLaunchDates.get(row.getIdentityKey());
row.setInitialCourseLaunchDate(initialLaunchDate);
}
AssessmentToolContainer toolContainer = getToolContainer();
if (toolContainer.getCertificateMap() == null) {
List<CertificateLight> certificates = certificatesManager.getLastCertificates(getCourseRepositoryEntry().getOlatResource());
ConcurrentMap<Long, CertificateLight> certificateMap = new ConcurrentHashMap<>();
for (CertificateLight certificate : certificates) {
certificateMap.put(certificate.getIdentityKey(), certificate);
}
toolContainer.setCertificateMap(certificateMap);
}
usersTableModel.setCertificateMap(toolContainer.getCertificateMap());
}
Aggregations