Search in sources :

Example 6 with CertificateLight

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;
        }
    }
}
Also used : CertificateAndEfficiencyStatement(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement) CertificateLight(org.olat.course.certificate.CertificateLight)

Example 7 with CertificateLight

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);
}
Also used : HashMap(java.util.HashMap) CertificateAndEfficiencyStatement(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement) ArrayList(java.util.ArrayList) UserEfficiencyStatementLight(org.olat.course.assessment.model.UserEfficiencyStatementLight) CertificateLight(org.olat.course.certificate.CertificateLight)

Example 8 with CertificateLight

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;
}
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 9 with CertificateLight

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);
}
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 10 with CertificateLight

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());
}
Also used : AssessmentToolContainer(org.olat.modules.assessment.ui.AssessmentToolContainer) AssessedIdentityElementRow(org.olat.modules.assessment.ui.AssessedIdentityElementRow) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Date(java.util.Date) 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