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