Search in sources :

Example 16 with CertificateLight

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

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

Example 18 with CertificateLight

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

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

Example 20 with CertificateLight

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);
}
Also used : 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