From 029f93132b14f10ceaa209271f1fdbd5b04f6403 Mon Sep 17 00:00:00 2001
From: srosse <stephane.rosse@frentix.com>
Date: Thu, 21 Jan 2021 11:32:40 +0100
Subject: [PATCH] OO-5239: renames the user directory of test results export

---
 .../QTI21ResultsExportMediaResource.java      | 26 +++++++++-----
 .../resultexport/_content/qtiListing.html     | 34 +++++++++----------
 .../resultexport/_content/qtiUserlisting.html | 12 +++----
 3 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/src/main/java/org/olat/ims/qti21/resultexport/QTI21ResultsExportMediaResource.java b/src/main/java/org/olat/ims/qti21/resultexport/QTI21ResultsExportMediaResource.java
index 7bd4e0b8a51..25b95e9b3f8 100644
--- a/src/main/java/org/olat/ims/qti21/resultexport/QTI21ResultsExportMediaResource.java
+++ b/src/main/java/org/olat/ims/qti21/resultexport/QTI21ResultsExportMediaResource.java
@@ -63,7 +63,6 @@ import org.olat.core.gui.util.SyntheticUserRequest;
 import org.olat.core.gui.util.WindowControlMocker;
 import org.olat.core.id.Identity;
 import org.olat.core.id.Roles;
-import org.olat.core.id.UserConstants;
 import org.olat.core.logging.Tracing;
 import org.olat.core.util.FileUtils;
 import org.olat.core.util.Formatter;
@@ -284,12 +283,24 @@ public class QTI21ResultsExportMediaResource implements MediaResource {
 			if(identity == null || identity.getStatus() == null || identity.getStatus().equals(Identity.STATUS_DELETED)) {
 				continue;
 			}
-			String lastNameOrAnoymous = identity.getUser().getLastName();
-			if(!StringHelper.containsNonWhitespace(lastNameOrAnoymous)) {
-				lastNameOrAnoymous = "anonym";
+			String nickname = identity.getUser().getNickName();
+			String firstName = identity.getUser().getFirstName();
+			String lastNameOrAnonymous = identity.getUser().getLastName();
+			if(!StringHelper.containsNonWhitespace(lastNameOrAnonymous)) {
+				lastNameOrAnonymous = "anonym";
 			}
-			String lastname = StringHelper.transformDisplayNameToFileSystemName(lastNameOrAnoymous);
-			String idDir = exportFolderName + "/" + DATA + lastname + "_" + identity.getKey();
+			String nameOrAnonymous = lastNameOrAnonymous;
+			if(StringHelper.containsNonWhitespace(firstName)) {
+				nameOrAnonymous += "_" + firstName;
+			}
+			if(StringHelper.containsNonWhitespace(nickname)) {
+				nameOrAnonymous += "_" + nickname;
+			} else {
+				nameOrAnonymous += "_" + identity.getKey();
+			}
+			
+			String names = StringHelper.transformDisplayNameToFileSystemName(nameOrAnonymous);
+			String idDir = exportFolderName + "/" + DATA + names;
 			idDir = idDir.endsWith(SEP) ? idDir : idDir + SEP;
 			createZipDirectory(zout, idDir);				
 			
@@ -307,8 +318,7 @@ public class QTI21ResultsExportMediaResource implements MediaResource {
 			
 			String linkToUser = idDir.replace(exportFolderName + "/", "") + "index.html";
 			String memberEmail = userManager.getUserDisplayEmail(identity, ureq.getLocale());
-			AssessedMember member = new AssessedMember(identity.getUser().getProperty(UserConstants.NICKNAME, null),
-					lastNameOrAnoymous, identity.getUser().getFirstName(),
+			AssessedMember member = new AssessedMember(nickname, lastNameOrAnonymous, firstName,
 					memberEmail, assessments.size(), passed, score, linkToUser);
 			
 			String singleUserInfoHTML = createResultListingHTML(assessments, assessmentDocuments, member);
diff --git a/src/main/java/org/olat/ims/qti21/resultexport/_content/qtiListing.html b/src/main/java/org/olat/ims/qti21/resultexport/_content/qtiListing.html
index ffeffa5b9c1..ec085c0cccc 100644
--- a/src/main/java/org/olat/ims/qti21/resultexport/_content/qtiListing.html
+++ b/src/main/java/org/olat/ims/qti21/resultexport/_content/qtiListing.html
@@ -21,13 +21,13 @@
 		<table id='oneUser' class='table table-striped table-hover'>
 			<thead>
 				<tr>
-					<th>$t.translate("table.all.username")</th>
-					<th>$t.translate("table.all.lastname")</th>
-					<th>$t.translate("table.all.firstname")</th>
-					<th>$t.translate("table.user.email")</th>
-					<th>$t.translate("table.all.node.score")</th>
-					<th>$t.translate("table.all.node.passed")</th>
-					<th>$t.translate("table.all.tries")</th>
+					<th scope="col">$t.translate("table.all.username")</th>
+					<th scope="col">$t.translate("table.all.lastname")</th>
+					<th scope="col">$t.translate("table.all.firstname")</th>
+					<th scope="col">$t.translate("table.user.email")</th>
+					<th scope="col">$t.translate("table.all.node.score")</th>
+					<th scope="col">$t.translate("table.all.node.passed")</th>
+					<th scope="col">$t.translate("table.all.tries")</th>
 				</tr>
 			</thead>
 			<tbody>
@@ -48,17 +48,17 @@
 		<table id='results' class='table table-striped table-hover'>
 			<thead>
 				<tr>
-					<th colspan="8">$t.translate("table.test.sessions")</th>
+					<th colspan="8" scope="col">$t.translate("table.test.sessions")</th>
 				</tr>
 				<tr>
-					<th>$t.translate("table.user.id")</th>
-					<th>$t.translate("table.user.date")</th>
-					<th>$t.translate("table.user.duration")</th>
-					<th>$t.translate("table.user.score")</th>
-					<th>$t.translate("table.user.manualScore")</th>
-					<th>$t.translate("table.user.finalScore")</th>
-					<th>$t.translate("table.all.passed")</th>
-					<th>$t.translate("button.show")</th>					
+					<th scope="col">$t.translate("table.user.id")</th>
+					<th scope="col">$t.translate("table.user.date")</th>
+					<th scope="col">$t.translate("table.user.duration")</th>
+					<th scope="col">$t.translate("table.user.score")</th>
+					<th scope="col">$t.translate("table.user.manualScore")</th>
+					<th scope="col">$t.translate("table.user.finalScore")</th>
+					<th scope="col">$t.translate("table.all.passed")</th>
+					<th scope="col">$t.translate("button.show")</th>					
 				</tr>
 			</thead>
 			<tbody>
@@ -84,7 +84,7 @@
 		<table id='assessmentDocuments' class='table table-striped table-hover'>
 			<thead>
 				<tr>
-					<th>$t.translate("assessment.docs")</th>
+					<th scope="col">$t.translate("assessment.docs")</th>
 				</tr>
 			</thead>
 			<tbody>
diff --git a/src/main/java/org/olat/ims/qti21/resultexport/_content/qtiUserlisting.html b/src/main/java/org/olat/ims/qti21/resultexport/_content/qtiUserlisting.html
index bf87ab2ad02..7a0ba6e2d4a 100644
--- a/src/main/java/org/olat/ims/qti21/resultexport/_content/qtiUserlisting.html
+++ b/src/main/java/org/olat/ims/qti21/resultexport/_content/qtiUserlisting.html
@@ -11,12 +11,12 @@
 		<table id='allUsers' class='table table-striped table-hover'>
 			<thead>
 				<tr>
-					<th>$t.translate("table.all.username")</th>
-					<th>$t.translate("table.all.lastname")</th>
-					<th>$t.translate("table.all.firstname")</th>
-					<th>$t.translate("table.all.score")</th>
-					<th>$t.translate("table.all.passed")</th>
-					<th>$t.translate("table.all.tries")</th>
+					<th scope="col">$t.translate("table.all.username")</th>
+					<th scope="col">$t.translate("table.all.lastname")</th>
+					<th scope="col">$t.translate("table.all.firstname")</th>
+					<th scope="col">$t.translate("table.all.score")</th>
+					<th scope="col">$t.translate("table.all.passed")</th>
+					<th scope="col">$t.translate("table.all.tries")</th>
 				</tr>
 			</thead>
 			<tbody>
-- 
GitLab