Search in sources :

Example 16 with AssessmentChangedEvent

use of org.olat.course.assessment.AssessmentChangedEvent in project OpenOLAT by OpenOLAT.

the class CourseAssessmentManagerImpl method saveNodeComment.

@Override
public void saveNodeComment(CourseNode courseNode, Identity identity, Identity assessedIdentity, String comment) {
    ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
    AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
    nodeAssessment.setComment(comment);
    assessmentService.updateAssessmentEntry(nodeAssessment);
    // node log
    UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
    am.appendToUserNodeLog(courseNode, identity, assessedIdentity, "COMMENT set to: " + comment);
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_USER_COMMENT_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_USERCOMMENT_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiUserComment, "", StringHelper.stripLineBreaks(comment)));
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 17 with AssessmentChangedEvent

use of org.olat.course.assessment.AssessmentChangedEvent in project OpenOLAT by OpenOLAT.

the class CourseAssessmentManagerImpl method saveNodeAttempts.

@Override
public void saveNodeAttempts(CourseNode courseNode, Identity identity, Identity assessedIdentity, Integer attempts, Role by) {
    ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
    AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
    if (by == Role.coach) {
        nodeAssessment.setLastCoachModified(new Date());
    } else if (by == Role.user) {
        nodeAssessment.setLastUserModified(new Date());
    }
    nodeAssessment.setAttempts(attempts);
    assessmentService.updateAssessmentEntry(nodeAssessment);
    // node log
    UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
    am.appendToUserNodeLog(courseNode, identity, assessedIdentity, "ATTEMPTS set to: " + String.valueOf(attempts));
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date)

Example 18 with AssessmentChangedEvent

use of org.olat.course.assessment.AssessmentChangedEvent in project openolat by klemens.

the class NewCachePersistingAssessmentManager method saveNodeAttempts.

/**
 * @see org.olat.course.assessment.AssessmentManager#saveNodeAttempts(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, org.olat.core.id.Identity,
 *      java.lang.Integer)
 */
public void saveNodeAttempts(final CourseNode courseNode, final Identity identity, final Identity assessedIdentity, final Integer attempts) {
    // A note on updating the EfficiencyStatement:
    // In the equivalent method incrementNodeAttempts() in this class, the following code is executed:
    // // Update users efficiency statement
    // EfficiencyStatementManager esm =	EfficiencyStatementManager.getInstance();
    // esm.updateUserEfficiencyStatement(userCourseEnv);
    // One would expect that saveNodeAttempts would also have to update the EfficiencyStatement - or
    // the caller of this method would have to make sure that this happens in the same transaction.
    // While this is not explicitly so, implicitly it is: currently the only user this method is
    // the AssessmentEditController - which as the 2nd last method calls into saveScoreEvaluation
    // - which in turn does update the EfficiencyStatement - at which point we're happy and everything works fine.
    // But it seems like this mechanism is a bit unobvious and might well be worth some refactoring...
    ICourse course = CourseFactory.loadCourse(ores);
    final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerExecutor() {

        public void execute() {
            Property attemptsProperty = cpm.findCourseNodeProperty(courseNode, assessedIdentity, null, ATTEMPTS);
            if (attemptsProperty == null) {
                attemptsProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, ATTEMPTS, null, new Long(attempts.intValue()), null, null);
                cpm.saveProperty(attemptsProperty);
            } else {
                attemptsProperty.setLongValue(new Long(attempts.intValue()));
                cpm.updateProperty(attemptsProperty);
            }
            // add to cache
            putPropertyIntoCache(assessedIdentity, attemptsProperty);
        }
    });
    // node log
    UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
    am.appendToUserNodeLog(courseNode, identity, assessedIdentity, ATTEMPTS + " set to: " + String.valueOf(attempts));
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 19 with AssessmentChangedEvent

use of org.olat.course.assessment.AssessmentChangedEvent in project openolat by klemens.

the class NewCachePersistingAssessmentManager method saveNodeComment.

/**
 * @see org.olat.course.assessment.AssessmentManager#saveNodeComment(org.olat.course.nodes.CourseNode,
 *      org.olat.core.id.Identity, org.olat.core.id.Identity,
 *      java.lang.String)
 */
public void saveNodeComment(final CourseNode courseNode, final Identity identity, final Identity assessedIdentity, final String comment) {
    ICourse course = CourseFactory.loadCourse(ores);
    final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerExecutor() {

        public void execute() {
            Property commentProperty = cpm.findCourseNodeProperty(courseNode, assessedIdentity, null, COMMENT);
            if (commentProperty == null) {
                commentProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, COMMENT, null, null, null, comment);
                cpm.saveProperty(commentProperty);
            } else {
                commentProperty.setTextValue(comment);
                cpm.updateProperty(commentProperty);
            }
            // add to cache
            putPropertyIntoCache(assessedIdentity, commentProperty);
        }
    });
    // node log
    UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
    am.appendToUserNodeLog(courseNode, identity, assessedIdentity, COMMENT + " set to: " + comment);
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_USER_COMMENT_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_USERCOMMENT_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiUserComment, "", StringHelper.stripLineBreaks(comment)));
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 20 with AssessmentChangedEvent

use of org.olat.course.assessment.AssessmentChangedEvent in project openolat by klemens.

the class NewCachePersistingAssessmentManager method incrementNodeAttempts.

private void incrementNodeAttempts(final CourseNode courseNode, final Identity identity, final UserCourseEnvironment userCourseEnv, boolean logActivity) {
    ICourse course = CourseFactory.loadCourse(ores);
    final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    long attempts = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(identity), new SyncerCallback<Long>() {

        public Long execute() {
            long attempts = incrementNodeAttemptsProperty(courseNode, identity, cpm);
            if (courseNode instanceof AssessableCourseNode) {
                // Update users efficiency statement
                EfficiencyStatementManager esm = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
                esm.updateUserEfficiencyStatement(userCourseEnv);
            }
            return attempts;
        }
    });
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, identity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    if (logActivity) {
        // user activity logging
        ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(identity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)26 ICourse (org.olat.course.ICourse)22 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)12 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)12 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)10 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)10 Date (java.util.Date)6 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)6 Property (org.olat.properties.Property)6 EfficiencyStatementManager (org.olat.course.assessment.manager.EfficiencyStatementManager)4 CertificateTemplate (org.olat.course.certificate.CertificateTemplate)4 CertificateInfos (org.olat.course.certificate.model.CertificateInfos)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 OLATResourceableJustBeforeDeletedEvent (org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent)2 EfficiencyStatement (org.olat.course.assessment.EfficiencyStatement)2