Program: 69546
Project: 69546
Buggy source:
/** 
 * @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();
  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().scoreInfoChanged((AssessableCourseNode)courseNode,scoreEvaluation);
        EfficiencyStatementManager esm=EfficiencyStatementManager.getInstance();
        esm.updateUserEfficiencyStatement(userCourseEnv);
      }
      if (scoreEvaluation.getPassed() && course.getCourseConfig().isAutomaticCertificationEnabled()) {
        CertificatesManager certificatesManager=CoreSpringFactory.getImpl(CertificatesManager.class);
        if (certificatesManager.isRecertificationAllowed(assessedIdentity,courseEntry)) {
          CertificateTemplate template=null;
          Long templateId=course.getCourseConfig().getCertificateTemplate();
          if (templateId != null) {
            template=certificatesManager.getTemplateById(templateId);
          }
          CertificateInfos certificateInfos=new CertificateInfos(assessedIdentity,score,passed);
          MailerResult result=new MailerResult();
          certificatesManager.generateCertificate(certificateInfos,courseEntry,template,result);
        }
      }
      return attempts;
    }
  }
);
  UserNodeAuditManager am=course.getCourseEnvironment().getAuditManager();
  am.appendToUserNodeLog(courseNode,identity,assessedIdentity,SCORE + "String_Node_Str" + String.valueOf(scoreEvaluation.getScore()));
  if (scoreEvaluation.getPassed() != null) {
    am.appendToUserNodeLog(courseNode,identity,assessedIdentity,PASSED + "String_Node_Str" + scoreEvaluation.getPassed().toString());
  }
 else {
    am.appendToUserNodeLog(courseNode,identity,assessedIdentity,PASSED + "String_Node_Str");
  }
  if (scoreEvaluation.getAssessmentID() != null) {
    am.appendToUserNodeLog(courseNode,assessedIdentity,assessedIdentity,ASSESSMENT_ID + "String_Node_Str" + scoreEvaluation.getAssessmentID().toString());
  }
  AssessmentChangedEvent ace=new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_SCORE_EVAL_CHANGED,assessedIdentity);
  CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace,course);
  if (scoreEvaluation.getScore() != null) {
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_SCORE_UPDATED,getClass(),LoggingResourceable.wrap(assessedIdentity),LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiScore,"String_Node_Str",String.valueOf(scoreEvaluation.getScore())));
  }
  if (scoreEvaluation.getPassed() != null) {
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED,getClass(),LoggingResourceable.wrap(assessedIdentity),LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed,"String_Node_Str",String.valueOf(scoreEvaluation.getPassed())));
  }
 else {
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED,getClass(),LoggingResourceable.wrap(assessedIdentity),LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed,"String_Node_Str","String_Node_Str"));
  }
  if (incrementUserAttempts && attempts != null) {
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED,getClass(),LoggingResourceable.wrap(identity),LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts,"String_Node_Str",String.valueOf(attempts)));
  }
}

Fixed version (ground truth):
/** 
 * @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();
  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().scoreInfoChanged((AssessableCourseNode)courseNode,scoreEvaluation);
        EfficiencyStatementManager esm=EfficiencyStatementManager.getInstance();
        esm.updateUserEfficiencyStatement(userCourseEnv);
      }
      if (passed != null && passed.booleanValue() && course.getCourseConfig().isAutomaticCertificationEnabled()) {
        CertificatesManager certificatesManager=CoreSpringFactory.getImpl(CertificatesManager.class);
        if (certificatesManager.isRecertificationAllowed(assessedIdentity,courseEntry)) {
          CertificateTemplate template=null;
          Long templateId=course.getCourseConfig().getCertificateTemplate();
          if (templateId != null) {
            template=certificatesManager.getTemplateById(templateId);
          }
          CertificateInfos certificateInfos=new CertificateInfos(assessedIdentity,score,passed);
          MailerResult result=new MailerResult();
          certificatesManager.generateCertificate(certificateInfos,courseEntry,template,result);
        }
      }
      return attempts;
    }
  }
);
  UserNodeAuditManager am=course.getCourseEnvironment().getAuditManager();
  am.appendToUserNodeLog(courseNode,identity,assessedIdentity,SCORE + "String_Node_Str" + String.valueOf(scoreEvaluation.getScore()));
  if (scoreEvaluation.getPassed() != null) {
    am.appendToUserNodeLog(courseNode,identity,assessedIdentity,PASSED + "String_Node_Str" + scoreEvaluation.getPassed().toString());
  }
 else {
    am.appendToUserNodeLog(courseNode,identity,assessedIdentity,PASSED + "String_Node_Str");
  }
  if (scoreEvaluation.getAssessmentID() != null) {
    am.appendToUserNodeLog(courseNode,assessedIdentity,assessedIdentity,ASSESSMENT_ID + "String_Node_Str" + scoreEvaluation.getAssessmentID().toString());
  }
  AssessmentChangedEvent ace=new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_SCORE_EVAL_CHANGED,assessedIdentity);
  CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace,course);
  if (scoreEvaluation.getScore() != null) {
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_SCORE_UPDATED,getClass(),LoggingResourceable.wrap(assessedIdentity),LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiScore,"String_Node_Str",String.valueOf(scoreEvaluation.getScore())));
  }
  if (scoreEvaluation.getPassed() != null) {
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED,getClass(),LoggingResourceable.wrap(assessedIdentity),LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed,"String_Node_Str",String.valueOf(scoreEvaluation.getPassed())));
  }
 else {
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED,getClass(),LoggingResourceable.wrap(assessedIdentity),LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed,"String_Node_Str","String_Node_Str"));
  }
  if (incrementUserAttempts && attempts != null) {
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED,getClass(),LoggingResourceable.wrap(identity),LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts,"String_Node_Str",String.valueOf(attempts)));
  }
}