Uploaded image for project: 'OpenOLAT'
  1. OpenOLAT
  2. OO-2004

Identities appear multiple times when exporting course results

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.4.10
    • Fix Version/s: 10.5
    • Component/s: Course
    • Labels:
      None

      Description

      When exporting the course results in the archiver, identities which are both course members and group members have two records in the exported file. This is because they are added two times to the userList in ScoreAccountingHelper.loadUsers().
      My suggestion is to use a Set instead of List because an object (Identity) can only appear once in Set.
      This is the patch:

      diff --git a/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java b/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java
      --- a/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java
      +++ b/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java
      @@ -416,21 +418,20 @@
       		List<BusinessGroup> groups = gm.getAllBusinessGroups();
       		
       		BusinessGroupService businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
      -		List<Identity> userList = businessGroupService.getMembers(groups, GroupRoles.participant.name());
      -		userList = new ArrayList<>(new HashSet<>(userList));
      +		HashSet<Identity> userSet = new HashSet<>(businessGroupService.getMembers(groups, GroupRoles.participant.name()));
       		OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, courseEnv.getCourseResourceableId());
       		RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(ores, false);
       		if(re != null) {
       			RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
      -			userList.addAll(repositoryService.getMembers(re, GroupRoles.participant.name()));
      +			userSet.addAll(repositoryService.getMembers(re, GroupRoles.participant.name()));
       		}
       
      -		List<Identity> assessedList = courseEnv.getCoursePropertyManager().getAllIdentitiesWithCourseAssessmentData(userList);
      +		List<Identity> assessedList = courseEnv.getCoursePropertyManager().getAllIdentitiesWithCourseAssessmentData(userSet);
       		if(assessedList.size() > 0) {
      -			assessedList.removeAll(userList);//deduplicate
      -			userList.addAll(assessedList);
      +			assessedList.removeAll(userSet);//deduplicate
      +			userSet.addAll(assessedList);
       		}
      -		return userList;
      +		return new ArrayList<Identity>(userSet);
       	}
       	
       	public static List<Identity> loadUsers(CourseEnvironment courseEnv, ArchiveOptions options) {
      

        Attachments

          Activity

            People

            Assignee:
            srosse Stéphane Rossé
            Reporter:
            stephan Stephan Clemenz
            Tester:
            Stephan Clemenz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m