Program: 69657
Project: 69657
Buggy source:
@Override public StatisticAssessment getAssessmentStatistics(QTIStatisticSearchParams searchParams){
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str").append(QTIStatisticResultSet.class.getName()).append("String_Node_Str");
  decorateRSet(sb,searchParams);
  sb.append("String_Node_Str");
  TypedQuery<Object[]> rawDataQuery=dbInstance.getCurrentEntityManager().createQuery(sb.toString(),Object[].class);
  decorateRSetQuery(rawDataQuery,searchParams);
  List<Object[]> rawDatas=rawDataQuery.getResultList();
  int numOfPassed=0;
  int numOfFailed=0;
  double totalDuration=0.0;
  double maxScore=0.0;
  double minScore=Double.MAX_VALUE;
  double[] scores=new double[rawDatas.size()];
  long[] durationMinutes=new long[rawDatas.size()];
  long minDuration=Integer.MAX_VALUE;
  long maxDuration=0;
  int dataPos=0;
  for (  Object[] rawData : rawDatas) {
    Boolean passed=(Boolean)rawData[2];
    if (passed != null) {
      if (passed.booleanValue()) {
        numOfPassed++;
      }
 else {
        numOfFailed++;
      }
    }
    Float score=(Float)rawData[0];
    if (score != null) {
      double scored=score.doubleValue();
      scores[dataPos]=scored;
      maxScore=Math.max(maxScore,scored);
      minScore=Math.min(minScore,scored);
    }
    Long duration=(Long)rawData[1];
    if (duration != null) {
      double durationd=duration.doubleValue();
      long durationMinute=Math.round(durationd / 60000.0d);
      durationMinutes[dataPos]=durationMinute;
      totalDuration+=durationd;
      minDuration=Math.min(minDuration,durationMinute);
      maxDuration=Math.max(maxDuration,durationMinute);
    }
    dataPos++;
  }
  Statistics statisticsHelper=new Statistics(scores);
  int numOfParticipants=rawDatas.size();
  StatisticAssessment stats=new StatisticAssessment();
  stats.setNumOfParticipants(numOfParticipants);
  stats.setNumOfPassed(numOfPassed);
  stats.setNumOfFailed(numOfFailed);
  long averageDuration=Math.round(totalDuration / numOfParticipants);
  stats.setAverageDuration(averageDuration);
  stats.setAverage(statisticsHelper.getMean());
  double range=maxScore - minScore;
  stats.setRange(range);
  stats.setMaxScore(maxScore);
  stats.setMinScore(minScore);
  stats.setStandardDeviation(statisticsHelper.getStdDev());
  stats.setMedian(statisticsHelper.median());
  stats.setMode(statisticsHelper.mode());
  stats.setDurations(durationMinutes);
  stats.setScores(scores);
  return stats;
}

Fixed version (ground truth):
@Override public StatisticAssessment getAssessmentStatistics(QTIStatisticSearchParams searchParams){
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str").append(QTIStatisticResultSet.class.getName()).append("String_Node_Str");
  decorateRSet(sb,searchParams);
  sb.append("String_Node_Str");
  TypedQuery<Object[]> rawDataQuery=dbInstance.getCurrentEntityManager().createQuery(sb.toString(),Object[].class);
  decorateRSetQuery(rawDataQuery,searchParams);
  List<Object[]> rawDatas=rawDataQuery.getResultList();
  int numOfPassed=0;
  int numOfFailed=0;
  double totalDuration=0.0;
  double maxScore=0.0;
  double minScore=Double.MAX_VALUE;
  double[] scores=new double[rawDatas.size()];
  long[] durationMinutes=new long[rawDatas.size()];
  long minDuration=Integer.MAX_VALUE;
  long maxDuration=0;
  int dataPos=0;
  for (  Object[] rawData : rawDatas) {
    Boolean passed=(Boolean)rawData[2];
    if (passed != null) {
      if (passed.booleanValue()) {
        numOfPassed++;
      }
 else {
        numOfFailed++;
      }
    }
    Float score=(Float)rawData[0];
    if (score != null) {
      double scored=score.doubleValue();
      scores[dataPos]=scored;
      maxScore=Math.max(maxScore,scored);
      minScore=Math.min(minScore,scored);
    }
    Long duration=(Long)rawData[1];
    if (duration != null) {
      double durationd=duration.doubleValue();
      long durationMinute=Math.round(durationd / 60000.0d);
      durationMinutes[dataPos]=durationMinute;
      totalDuration+=durationd;
      minDuration=Math.min(minDuration,durationMinute);
      maxDuration=Math.max(maxDuration,durationMinute);
    }
    dataPos++;
  }
  if (rawDatas.size() == 0) {
    minScore=0;
  }
  Statistics statisticsHelper=new Statistics(scores);
  int numOfParticipants=rawDatas.size();
  StatisticAssessment stats=new StatisticAssessment();
  stats.setNumOfParticipants(numOfParticipants);
  stats.setNumOfPassed(numOfPassed);
  stats.setNumOfFailed(numOfFailed);
  long averageDuration=Math.round(totalDuration / numOfParticipants);
  stats.setAverageDuration(averageDuration);
  stats.setAverage(statisticsHelper.getMean());
  double range=maxScore - minScore;
  stats.setRange(range);
  stats.setMaxScore(maxScore);
  stats.setMinScore(minScore);
  stats.setStandardDeviation(statisticsHelper.getStdDev());
  stats.setMedian(statisticsHelper.median());
  stats.setMode(statisticsHelper.mode());
  stats.setDurations(durationMinutes);
  stats.setScores(scores);
  return stats;
}