use of org.olat.course.certificate.CertificatesManager in project OpenOLAT by OpenOLAT.
the class CertificationWebService method deleteCertificateInfo.
@DELETE
@Path("{identityKey}")
public Response deleteCertificateInfo(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, @Context HttpServletRequest request) {
if (!isAdmin(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
Identity identity = baseSecurity.loadIdentityByKey(identityKey);
if (identity == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", resourceKey);
OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
OLATResource resource = resourceManager.findResourceable(courseOres);
if (resource == null) {
resource = resourceManager.findResourceById(resourceKey);
}
if (resource == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
Certificate certificate = certificatesManager.getLastCertificate(identity, resource.getKey());
if (certificate == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
certificatesManager.deleteCertificate(certificate);
return Response.ok().build();
}
use of org.olat.course.certificate.CertificatesManager in project OpenOLAT by OpenOLAT.
the class CertificationWebService method getCertificateInfo.
@HEAD
@Path("{identityKey}")
@Produces({ "application/pdf" })
public Response getCertificateInfo(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, @Context HttpServletRequest request) {
if (!isAdmin(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
Identity identity = baseSecurity.loadIdentityByKey(identityKey);
if (identity == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", resourceKey);
OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
OLATResource resource = resourceManager.findResourceable(courseOres);
if (resource == null) {
resource = resourceManager.findResourceById(resourceKey);
}
if (resource == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
Certificate certificate = certificatesManager.getLastCertificate(identity, resource.getKey());
if (certificate == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
VFSLeaf certificateFile = certificatesManager.getCertificateLeaf(certificate);
if (certificateFile == null || !certificateFile.exists()) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
return Response.ok().build();
}
use of org.olat.course.certificate.CertificatesManager in project OpenOLAT by OpenOLAT.
the class UserCourseEnvironmentImpl method hasEfficiencyStatementOrCertificate.
@Override
public boolean hasEfficiencyStatementOrCertificate(boolean update) {
if (certification == null || update) {
EfficiencyStatementManager efficiencyStatementManager = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
boolean hasStatement = efficiencyStatementManager.hasUserEfficiencyStatement(getCourseRepositoryEntry().getKey(), identityEnvironment.getIdentity());
if (hasStatement) {
certification = Boolean.TRUE;
} else {
CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
certification = certificatesManager.hasCertificate(identityEnvironment.getIdentity(), getCourseRepositoryEntry().getOlatResource().getKey());
}
}
return certification.booleanValue();
}
use of org.olat.course.certificate.CertificatesManager in project OpenOLAT by OpenOLAT.
the class NewCachePersistingAssessmentManager method saveScoreEvaluation.
/**
* @see org.olat.course.assessment.AssessmentManager#saveScoreEvaluation(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, org.olat.core.id.Identity, org.olat.course.run.scoring.ScoreEvaluation)
*/
public void saveScoreEvaluation(final CourseNode courseNode, final Identity identity, final Identity assessedIdentity, final ScoreEvaluation scoreEvaluation, final UserCourseEnvironment userCourseEnv, final boolean incrementUserAttempts) {
final ICourse course = CourseFactory.loadCourse(ores);
final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
final RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
// o_clusterREVIEW we could sync on a element finer than course, e.g. the composite course+assessIdentity.
// +: concurrency would be higher
// -: many entries (num of courses * visitors of given course) in the locktable.
// we could also sync on the assessedIdentity.
Long attempts = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerCallback<Long>() {
public Long execute() {
Long attempts = null;
Float score = scoreEvaluation.getScore();
Boolean passed = scoreEvaluation.getPassed();
saveNodeScore(courseNode, assessedIdentity, score, cpm);
saveNodePassed(courseNode, assessedIdentity, passed, cpm);
saveAssessmentID(courseNode, assessedIdentity, scoreEvaluation.getAssessmentID(), cpm);
if (incrementUserAttempts) {
attempts = incrementNodeAttemptsProperty(courseNode, assessedIdentity, cpm);
}
if (courseNode instanceof AssessableCourseNode) {
userCourseEnv.getScoreAccounting().evaluateAll();
// Update users efficiency statement
EfficiencyStatementManager esm = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
esm.updateUserEfficiencyStatement(userCourseEnv);
}
if (passed != null && passed.booleanValue() && course.getCourseConfig().isAutomaticCertificationEnabled()) {
CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
if (certificatesManager.isCertificationAllowed(assessedIdentity, courseEntry)) {
CertificateTemplate template = null;
Long templateId = course.getCourseConfig().getCertificateTemplate();
if (templateId != null) {
template = certificatesManager.getTemplateById(templateId);
}
CertificateInfos certificateInfos = new CertificateInfos(assessedIdentity, score, passed);
certificatesManager.generateCertificate(certificateInfos, courseEntry, template, true);
}
}
return attempts;
}
});
// node log
UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, SCORE + " set to: " + String.valueOf(scoreEvaluation.getScore()));
if (scoreEvaluation.getPassed() != null) {
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, PASSED + " set to: " + scoreEvaluation.getPassed().toString());
} else {
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, PASSED + " set to \"undefined\"");
}
if (scoreEvaluation.getAssessmentID() != null) {
am.appendToUserNodeLog(courseNode, assessedIdentity, assessedIdentity, ASSESSMENT_ID + " set to: " + scoreEvaluation.getAssessmentID().toString());
}
// notify about changes
AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_SCORE_EVAL_CHANGED, assessedIdentity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
// user activity logging
if (scoreEvaluation.getScore() != null) {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_SCORE_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiScore, "", String.valueOf(scoreEvaluation.getScore())));
}
if (scoreEvaluation.getPassed() != null) {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed, "", String.valueOf(scoreEvaluation.getPassed())));
} else {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed, "", "undefined"));
}
if (incrementUserAttempts && attempts != null) {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(identity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
}
use of org.olat.course.certificate.CertificatesManager in project openolat by klemens.
the class NewCachePersistingAssessmentManager method saveScoreEvaluation.
/**
* @see org.olat.course.assessment.AssessmentManager#saveScoreEvaluation(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, org.olat.core.id.Identity, org.olat.course.run.scoring.ScoreEvaluation)
*/
public void saveScoreEvaluation(final CourseNode courseNode, final Identity identity, final Identity assessedIdentity, final ScoreEvaluation scoreEvaluation, final UserCourseEnvironment userCourseEnv, final boolean incrementUserAttempts) {
final ICourse course = CourseFactory.loadCourse(ores);
final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
final RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
// o_clusterREVIEW we could sync on a element finer than course, e.g. the composite course+assessIdentity.
// +: concurrency would be higher
// -: many entries (num of courses * visitors of given course) in the locktable.
// we could also sync on the assessedIdentity.
Long attempts = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerCallback<Long>() {
public Long execute() {
Long attempts = null;
Float score = scoreEvaluation.getScore();
Boolean passed = scoreEvaluation.getPassed();
saveNodeScore(courseNode, assessedIdentity, score, cpm);
saveNodePassed(courseNode, assessedIdentity, passed, cpm);
saveAssessmentID(courseNode, assessedIdentity, scoreEvaluation.getAssessmentID(), cpm);
if (incrementUserAttempts) {
attempts = incrementNodeAttemptsProperty(courseNode, assessedIdentity, cpm);
}
if (courseNode instanceof AssessableCourseNode) {
userCourseEnv.getScoreAccounting().evaluateAll();
// Update users efficiency statement
EfficiencyStatementManager esm = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
esm.updateUserEfficiencyStatement(userCourseEnv);
}
if (passed != null && passed.booleanValue() && course.getCourseConfig().isAutomaticCertificationEnabled()) {
CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
if (certificatesManager.isCertificationAllowed(assessedIdentity, courseEntry)) {
CertificateTemplate template = null;
Long templateId = course.getCourseConfig().getCertificateTemplate();
if (templateId != null) {
template = certificatesManager.getTemplateById(templateId);
}
CertificateInfos certificateInfos = new CertificateInfos(assessedIdentity, score, passed);
certificatesManager.generateCertificate(certificateInfos, courseEntry, template, true);
}
}
return attempts;
}
});
// node log
UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, SCORE + " set to: " + String.valueOf(scoreEvaluation.getScore()));
if (scoreEvaluation.getPassed() != null) {
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, PASSED + " set to: " + scoreEvaluation.getPassed().toString());
} else {
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, PASSED + " set to \"undefined\"");
}
if (scoreEvaluation.getAssessmentID() != null) {
am.appendToUserNodeLog(courseNode, assessedIdentity, assessedIdentity, ASSESSMENT_ID + " set to: " + scoreEvaluation.getAssessmentID().toString());
}
// notify about changes
AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_SCORE_EVAL_CHANGED, assessedIdentity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
// user activity logging
if (scoreEvaluation.getScore() != null) {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_SCORE_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiScore, "", String.valueOf(scoreEvaluation.getScore())));
}
if (scoreEvaluation.getPassed() != null) {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed, "", String.valueOf(scoreEvaluation.getPassed())));
} else {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed, "", "undefined"));
}
if (incrementUserAttempts && attempts != null) {
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(identity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
}
Aggregations