Search in sources :

Example 11 with AssessmentChangedEvent

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

the class NewCachePersistingAssessmentManager method saveNodeCoachComment.

/**
 * @see org.olat.course.assessment.AssessmentManager#saveNodeCoachComment(org.olat.course.nodes.CourseNode,
 *      org.olat.core.id.Identity, java.lang.String)
 */
public void saveNodeCoachComment(final CourseNode courseNode, 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, COACH_COMMENT);
            if (commentProperty == null) {
                commentProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, COACH_COMMENT, null, null, null, comment);
                cpm.saveProperty(commentProperty);
            } else {
                commentProperty.setTextValue(comment);
                cpm.updateProperty(commentProperty);
            }
            // add to cache
            putPropertyIntoCache(assessedIdentity, commentProperty);
        }
    });
    // olat::: no node log here? (because what we did above is a node log with custom text AND by a coach)?
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_COACH_COMMENT_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_COACHCOMMENT_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiCoachComment, "", StringHelper.stripLineBreaks(comment)));
}
Also used : 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 12 with AssessmentChangedEvent

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

the class CourseAssessmentManagerImpl method incrementNodeAttemptsInBackground.

@Override
public void incrementNodeAttemptsInBackground(CourseNode courseNode, Identity assessedIdentity, UserCourseEnvironment userCourseEnv) {
    ICourse course = CourseFactory.loadCourse(cgm.getCourseEntry());
    AssessmentEntry nodeAssessment = getOrCreate(assessedIdentity, courseNode);
    int attempts = nodeAssessment.getAttempts() == null ? 1 : nodeAssessment.getAttempts().intValue() + 1;
    nodeAssessment.setAttempts(attempts);
    assessmentService.updateAssessmentEntry(nodeAssessment);
    if (courseNode instanceof AssessableCourseNode) {
        // Update users efficiency statement
        efficiencyStatementManager.updateUserEfficiencyStatement(userCourseEnv);
    }
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Example 13 with AssessmentChangedEvent

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

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 14 with AssessmentChangedEvent

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

the class RunMainController method event.

/**
 * implementation of listener which listens to publish events
 *
 * @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event)
 */
@Override
public void event(Event event) {
    if (event instanceof PublishEvent) {
        PublishEvent pe = (PublishEvent) event;
        if (course.getResourceableId().equals(pe.getPublishedCourseResId())) {
            processPublishEvent(pe);
        }
    } else if (event instanceof OLATResourceableJustBeforeDeletedEvent) {
        OLATResourceableJustBeforeDeletedEvent ojde = (OLATResourceableJustBeforeDeletedEvent) event;
        // registered only to one event, but good style.
        if (ojde.targetEquals(course, true)) {
            doDisposeAfterEvent();
        }
    } else if (event instanceof AssessmentChangedEvent) {
        AssessmentChangedEvent ace = (AssessmentChangedEvent) event;
        Identity identity = uce.getIdentityEnvironment().getIdentity();
        // reevaluate the changed node if the event changed the current user
        if (ace.getIdentityKey().equals(identity.getKey())) {
            String assessmentChangeType = ace.getCommand();
            // do not re-evaluate things if only comment has been changed
            if (assessmentChangeType.equals(AssessmentChangedEvent.TYPE_SCORE_EVAL_CHANGED) || assessmentChangeType.equals(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED)) {
                // LD: do not recalculate the score now, but at the next click, since the event comes before DB commit
                // uce.getScoreAccounting().evaluateAll();
                assessmentChangedEventReceived = true;
            }
            // raise a flag to indicate refresh
            needsRebuildAfterRunDone = true;
        }
    }
}
Also used : PublishEvent(org.olat.course.editor.PublishEvent) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent) Identity(org.olat.core.id.Identity)

Example 15 with AssessmentChangedEvent

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

the class EfficiencyStatementManager method updateUserEfficiencyStatement.

public void updateUserEfficiencyStatement(Identity assessedIdentity, final CourseEnvironment courseEnv, List<AssessmentNodeData> assessmentNodeList, AssessmentNodesLastModified lastModifications, final RepositoryEntry repoEntry) {
    List<Map<String, Object>> assessmentNodes = AssessmentHelper.assessmentNodeDataListToMap(assessmentNodeList);
    EfficiencyStatement efficiencyStatement = new EfficiencyStatement();
    efficiencyStatement.setAssessmentNodes(assessmentNodes);
    efficiencyStatement.setCourseTitle(courseEnv.getCourseTitle());
    efficiencyStatement.setCourseRepoEntryKey(repoEntry.getKey());
    String userInfos = userManager.getUserDisplayName(assessedIdentity);
    efficiencyStatement.setDisplayableUserInfo(userInfos);
    efficiencyStatement.setLastUpdated(System.currentTimeMillis());
    if (lastModifications != null) {
        if (lastModifications.getLastUserModified() != null) {
            efficiencyStatement.setLastUserModified(lastModifications.getLastUserModified().getTime());
        }
        if (lastModifications.getLastCoachModified() != null) {
            efficiencyStatement.setLastCoachModified(lastModifications.getLastCoachModified().getTime());
        }
    }
    boolean debug = log.isDebug();
    UserEfficiencyStatementImpl efficiencyProperty = getUserEfficiencyStatementFull(repoEntry, assessedIdentity);
    if (assessmentNodes != null) {
        if (efficiencyProperty == null) {
            // create new
            efficiencyProperty = new UserEfficiencyStatementImpl();
            efficiencyProperty.setIdentity(assessedIdentity);
            efficiencyProperty.setCourseRepoKey(repoEntry.getKey());
            if (repoEntry != null) {
                efficiencyProperty.setResource(repoEntry.getOlatResource());
                efficiencyProperty.setCourseRepoKey(repoEntry.getKey());
            }
            efficiencyProperty.setShortTitle(courseEnv.getRunStructure().getRootNode().getShortTitle());
            efficiencyProperty.setTitle(courseEnv.getRunStructure().getRootNode().getLongTitle());
            fillEfficiencyStatement(efficiencyStatement, lastModifications, efficiencyProperty);
            dbInstance.getCurrentEntityManager().persist(efficiencyProperty);
            if (debug) {
                log.debug("creating new efficiency statement property::" + efficiencyProperty.getKey() + " for id::" + assessedIdentity.getName() + " repoEntry::" + repoEntry.getKey());
            }
        } else {
            // update existing
            if (debug) {
                log.debug("updating efficiency statement property::" + efficiencyProperty.getKey() + " for id::" + assessedIdentity.getName() + " repoEntry::" + repoEntry.getKey());
            }
            efficiencyProperty.setShortTitle(courseEnv.getRunStructure().getRootNode().getShortTitle());
            efficiencyProperty.setTitle(courseEnv.getRunStructure().getRootNode().getLongTitle());
            fillEfficiencyStatement(efficiencyStatement, lastModifications, efficiencyProperty);
            dbInstance.getCurrentEntityManager().merge(efficiencyProperty);
        }
    } else {
        if (efficiencyProperty != null) {
            // remove existing since now empty efficiency statements
            if (debug) {
                log.debug("removing efficiency statement property::" + efficiencyProperty.getKey() + " for id::" + assessedIdentity.getName() + " repoEntry::" + repoEntry.getKey() + " since empty");
            }
            dbInstance.getCurrentEntityManager().remove(efficiencyProperty);
        }
    // else nothing to create and nothing to delete
    }
    // send modified event to everybody
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_EFFICIENCY_STATEMENT_CHANGED, assessedIdentity);
    OLATResourceable courseOres = OresHelper.createOLATResourceableInstance(CourseModule.class, courseEnv.getCourseResourceableId());
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, courseOres);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) UserEfficiencyStatementImpl(org.olat.course.assessment.model.UserEfficiencyStatementImpl) Map(java.util.Map) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement)

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