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