Search in sources :

Example 21 with ICourse

use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.

the class AssessedIdentityCertificatesController method doGenerateCertificate.

private void doGenerateCertificate(UserRequest ureq) {
    ICourse course = CourseFactory.loadCourse(resource);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    Identity assessedIdentity = assessedUserCourseEnv.getIdentityEnvironment().getIdentity();
    ScoreEvaluation scoreEval = assessedUserCourseEnv.getScoreAccounting().getScoreEvaluation(rootNode);
    RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    CertificateTemplate template = null;
    Long templateKey = course.getCourseConfig().getCertificateTemplate();
    if (templateKey != null) {
        template = certificatesManager.getTemplateById(templateKey);
    }
    Float score = scoreEval == null ? null : scoreEval.getScore();
    Boolean passed = scoreEval == null ? null : scoreEval.getPassed();
    CertificateInfos certificateInfos = new CertificateInfos(assessedIdentity, score, passed);
    certificatesManager.generateCertificate(certificateInfos, courseEntry, template, true);
    loadList();
    showInfo("msg.certificate.pending");
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) CertificateTemplate(org.olat.course.certificate.CertificateTemplate) CertificateInfos(org.olat.course.certificate.model.CertificateInfos) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Example 22 with ICourse

use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.

the class CertificatesManagerImpl method getDateNextRecertification.

@Override
public Date getDateNextRecertification(Certificate certificate, RepositoryEntry entry) {
    ICourse course = CourseFactory.loadCourse(entry);
    CourseConfig config = course.getCourseEnvironment().getCourseConfig();
    return getDateNextRecertification(certificate, config);
}
Also used : ICourse(org.olat.course.ICourse) CourseConfig(org.olat.course.config.CourseConfig)

Example 23 with ICourse

use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.

the class CertificatesManagerImpl method markPublisherNews.

public void markPublisherNews(Identity ident, OLATResource courseResource) {
    ICourse course = CourseFactory.loadCourse(courseResource);
    SubscriptionContext subsContext = getSubscriptionContext(course);
    if (subsContext != null) {
        notificationsManager.markPublisherNews(subsContext, ident, true);
    }
}
Also used : ICourse(org.olat.course.ICourse) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext)

Example 24 with ICourse

use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.

the class CertificatesManagerImpl method isCertificationAllowed.

@Override
public boolean isCertificationAllowed(Identity identity, RepositoryEntry entry) {
    boolean allowed = false;
    try {
        ICourse course = CourseFactory.loadCourse(entry);
        CourseConfig config = course.getCourseEnvironment().getCourseConfig();
        if (config.isRecertificationEnabled()) {
            Certificate certificate = getLastCertificate(identity, entry.getOlatResource().getKey());
            if (certificate == null) {
                allowed = true;
            } else {
                Calendar cal = Calendar.getInstance();
                Date now = cal.getTime();
                Date nextCertificationDate = getDateNextRecertification(certificate, config);
                allowed = (nextCertificationDate != null ? nextCertificationDate.before(now) : false);
            }
        } else {
            allowed = !hasCertificate(identity, entry.getOlatResource().getKey());
        }
    } catch (CorruptedCourseException e) {
        log.error("", e);
    }
    return allowed;
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) Calendar(java.util.Calendar) ICourse(org.olat.course.ICourse) Date(java.util.Date) CourseConfig(org.olat.course.config.CourseConfig) Certificate(org.olat.course.certificate.Certificate)

Example 25 with ICourse

use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.

the class IdentityListCourseNodeController method doSetVisibility.

private void doSetVisibility(UserRequest ureq, Boolean visibility, List<AssessedIdentityElementRow> rows) {
    ICourse course = CourseFactory.loadCourse(courseEntry);
    AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
    for (AssessedIdentityElementRow row : rows) {
        Identity assessedIdentity = securityManager.loadIdentityByKey(row.getIdentityKey());
        Roles roles = securityManager.getRoles(assessedIdentity);
        IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, roles);
        UserCourseEnvironment assessedUserCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment(), coachCourseEnv.isCourseReadOnly());
        assessedUserCourseEnv.getScoreAccounting().evaluateAll();
        ScoreEvaluation scoreEval = assessableCourseNode.getUserScoreEvaluation(assessedUserCourseEnv);
        ScoreEvaluation doneEval = new ScoreEvaluation(scoreEval.getScore(), scoreEval.getPassed(), scoreEval.getAssessmentStatus(), visibility, scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), scoreEval.getCurrentRunStatus(), scoreEval.getAssessmentID());
        assessableCourseNode.updateUserScoreEvaluation(doneEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
    }
    loadModel(ureq);
}
Also used : CalculatedAssessableCourseNode(org.olat.course.nodes.CalculatedAssessableCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessedIdentityElementRow(org.olat.modules.assessment.ui.AssessedIdentityElementRow) ICourse(org.olat.course.ICourse) Roles(org.olat.core.id.Roles) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Aggregations

ICourse (org.olat.course.ICourse)674 Identity (org.olat.core.id.Identity)262 RepositoryEntry (org.olat.repository.RepositoryEntry)246 CourseNode (org.olat.course.nodes.CourseNode)182 Test (org.junit.Test)158 ArrayList (java.util.ArrayList)102 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)90 Date (java.util.Date)84 URI (java.net.URI)76 HttpResponse (org.apache.http.HttpResponse)76 OLATResource (org.olat.resource.OLATResource)64 File (java.io.File)62 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)52 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)52 Produces (javax.ws.rs.Produces)48 Roles (org.olat.core.id.Roles)44 Path (javax.ws.rs.Path)42 UserRequest (org.olat.core.gui.UserRequest)42 INode (org.olat.core.util.nodes.INode)40 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)40